MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr) { ptrA id(mir_t2a_cp(psr->id.t, CP_UTF8)); ptrA name(mir_t2a_cp(psr->firstName.t, CP_UTF8)); ptrA surname(mir_t2a_cp(psr->lastName.t, CP_UTF8)); if (id == NULL) return NULL; facebook_user fbu; fbu.user_id = id; if (name != NULL) fbu.real_name = name; if (surname != NULL) { fbu.real_name += " "; fbu.real_name += surname; } if (fbu.user_id.find_first_not_of("0123456789") != std::string::npos) { MessageBox(0, TranslateT("Facebook ID must be numeric value."), m_tszUserName, MB_ICONERROR | MB_OK); return NULL; } bool add_temporarily = (flags & PALF_TEMPORARY); MCONTACT hContact = AddToContactList(&fbu, CONTACT_NONE, false, add_temporarily); // Reset NotOnList flag if present and we're adding this contact not temporarily if (hContact && !add_temporarily && db_get_b(hContact, "CList", "NotOnList", 0)) { db_unset(hContact, "CList", "Hidden"); db_unset(hContact, "CList", "NotOnList"); } return hContact; }
int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam) { GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam); char *text; char *id; if (strcmp(hook->pDest->pszModule,m_szModuleName)) return 0; switch(hook->pDest->iType) { case GC_USER_MESSAGE: { text = mir_t2a_cp(hook->ptszText,CP_UTF8); std::string msg = text; id = mir_t2a_cp(hook->pDest->ptszID,CP_UTF8); std::string chat_id = id; mir_free(text); mir_free(id); if (isOnline()) { MCONTACT hContact = this->ContactIDToHContact(chat_id); if (hContact) { debugLogA("**Chat - Outgoing message: %s", text); this->SendMsg(hContact, IS_CHAT, msg.c_str()); // #TODO Move to SendMsgWorker, otherwise all messages are "acknowledged" by Miranda GCDEST gcd = { m_szModuleName, hook->pDest->ptszID, GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = mir_a2t(this->nick.c_str()); gce.ptszUID = mir_a2t(this->jid.c_str()); gce.time = time(NULL); gce.ptszText = hook->ptszText; gce.bIsMe = TRUE; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free((void*)gce.ptszUID); mir_free((void*)gce.ptszNick); } } break; } case GC_USER_LEAVE: case GC_SESSION_TERMINATE: { break; } } return 0; }
int FacebookProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam) { GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam); char *text; char *id; if (strcmp(hook->pDest->pszModule,m_szModuleName)) return 0; switch(hook->pDest->iType) { case GC_USER_MESSAGE: { text = mir_t2a_cp(hook->ptszText,CP_UTF8); std::string msg = text; id = mir_t2a_cp(hook->pDest->ptszID,CP_UTF8); std::string chat_id = id; mir_free(text); mir_free(id); if (isOnline()) { LOG("**Chat - Outgoing message: %s", text); ForkThread(&FacebookProto::SendChatMsgWorker, this, new send_chat(chat_id, msg) ); } break; } case GC_USER_LEAVE: case GC_SESSION_TERMINATE: { break; } } return 0; }
MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr) { ptrA id( mir_t2a_cp(psr->id, CP_UTF8)); ptrA name( mir_t2a_cp(psr->firstName, CP_UTF8)); ptrA surname( mir_t2a_cp(psr->lastName, CP_UTF8)); if (id == NULL) return NULL; facebook_user fbu; fbu.user_id = id; if (name != NULL) fbu.real_name = name; if (surname != NULL) { fbu.real_name += " "; fbu.real_name += surname; } if (fbu.user_id.find_first_not_of("0123456789") != std::string::npos) { MessageBox(0, TranslateT("Facebook ID must be numeric value."), m_tszUserName, MB_ICONERROR | MB_OK); return NULL; } MCONTACT hContact = AddToContactList(&fbu, CONTACT_NONE); if (hContact) { if (flags & PALF_TEMPORARY) { db_set_b(hContact, "Clist", "Hidden", 1); db_set_b(hContact, "Clist", "NotOnList", 1); } else if (db_get_b(hContact, "CList", "NotOnList", 0)) { db_unset(hContact, "CList", "Hidden"); db_unset(hContact, "CList", "NotOnList"); } } return hContact; }
void* IEView::getSelection(IEVIEWEVENT *event) { mir_free(selectedText); selectedText = getSelection(); if (mir_wstrlen(selectedText) == 0) return NULL; if (event->dwFlags & IEEF_NO_UNICODE) { int cp = CP_ACP; if (event->cbSize >= IEVIEWEVENT_SIZE_V2) cp = event->codepage; char *str = mir_t2a_cp(selectedText, cp); mir_free(selectedText); selectedText = (BSTR)str; } return (void*)selectedText; }
int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK*)lParam; if (!gch) { return 1; } else if (mir_strcmp(gch->pDest->pszModule, m_szModuleName) != 0) { return 0; } ptrA chat_id(mir_t2a(gch->pDest->ptszID)); switch (gch->pDest->iType) { case GC_USER_MESSAGE: { OnSendChatMessage(gch->pDest->ptszID, gch->ptszText); break; } case GC_USER_PRIVMESS: { MCONTACT hContact = FindContact(_T2A(gch->ptszUID)); if (hContact == NULL) { hContact = AddContact(_T2A(gch->ptszUID), true); setWord(hContact, "Status", ID_STATUS_ONLINE); db_set_b(hContact, "CList", "Hidden", 1); setTString(hContact, "Nick", gch->ptszUID); db_set_dw(hContact, "Ignore", "Mask1", 0); } CallService(MS_MSG_SENDMESSAGET, hContact, 0); break; } case GC_USER_LOGMENU: { switch (gch->dwData) { case 10: { CSkypeInviteDlg dlg(this); if(!dlg.DoModal()) { break; } MCONTACT hContact = dlg.m_hContact; if (hContact != NULL) { ptrA username(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)); SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, username, "User", m_szServer)); } break; } case 20: OnLeaveChatRoom(FindChatRoom(chat_id), NULL); break; case 30: CMString newTopic = ChangeTopicForm(); if (!newTopic.IsEmpty()) SendRequest(new SetChatPropertiesRequest(m_szRegToken, chat_id, "topic", ptrA(mir_utf8encodeT(newTopic.GetBuffer())), m_szServer)); break; } break; } case GC_USER_NICKLISTMENU: { ptrA user_id; if (gch->dwData == 10 || gch->dwData == 30 || gch->dwData == 40) { user_id = mir_t2a_cp(gch->ptszUID, CP_UTF8); } switch (gch->dwData) { case 10: SendRequest(new KickUserRequest(m_szRegToken, chat_id, user_id, m_szServer)); break; case 30: SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, user_id, "Admin", m_szServer)); break; case 40: SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, user_id, "User", m_szServer)); break; } break; } } return 0; }