int FacebookProto::RemoveFriend(WPARAM wParam,LPARAM lParam) { if (wParam == NULL) { // self contact // CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE)); return 0; } if (isOffline()) return 0; if (MessageBox( 0, TranslateT("Are you sure?"), TranslateT("Delete contact from server list"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 ) != IDYES) return 0; HANDLE hContact = reinterpret_cast<HANDLE>(wParam); DBVARIANT dbv; if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) ) { if (!isOffline()) { std::string* id = new std::string(dbv.pszVal); ForkThread( &FacebookProto::DeleteContactFromServer, this, ( void* )id ); DBFreeVariant(&dbv); if ( !DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0) ) DBWriteContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL)); } } return 0; }
int FacebookProto::AddFriend(WPARAM wParam,LPARAM lParam) { if (wParam == NULL) { // self contact // CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE)); return 0; } if (isOffline()) return 0; HANDLE hContact = reinterpret_cast<HANDLE>(wParam); DBVARIANT dbv; if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) ) { if (!isOffline()) { std::string* id = new std::string(dbv.pszVal); ForkThread( &FacebookProto::AddContactToServer, this, ( void* )id ); DBFreeVariant(&dbv); } } return 0; }
void RenderAf::stopTask( int jobid, int blocknum, int tasknum, int number) { //printf("RenderAf::stopTask: j%d b%d t%d n%d\n", jobid, blocknum, tasknum, number); if( isOffline()) return; m_re.addTaskStop( af::MCTaskPos( jobid, blocknum, tasknum, number)); }
ChannelMessage::ChannelMessage(MessagePacket packet) : Message(packet->id(), QByteArray(), LS("channel"), LS("addChannelMessage")) , m_packet(packet) { setDate(m_packet->date()); setAuthor(m_packet->sender()); m_tab = detectTab(m_packet->sender(), m_packet->dest()); if (!m_packet->internalId().isEmpty()) m_data.insert(kInternalId, ChatId(m_packet->internalId()).toString()); m_data.insert(kCommand, packet->command()); m_data.insert(kDirection, m_packet->sender() == ChatClient::id() ? kOutgoing : kIncoming); /// Если это собственное сообщение, то для него при необходимости устанавливается /// статус "offline" или "rejected". const int status = packet->status(); if (isOffline(status)) m_data.insert(kStatus, kOffline); else if (status != Notice::OK && status != Notice::Found && status < Notice::UserStatus) m_data.insert(kStatus, kRejected); if (status == MessageNotice::Removed) { m_data.insert(kStatus, kRemoved); m_data.insert(kText, QString(LS("<span class='message-removed' data-tr='message-removed'>%1</span> <i class='message-trash'></i>")).arg(WebBridge::i()->translate("message-removed"))); } else m_data.insert(kText, TokenFilter::filter(LS("channel"), packet->text(), 0, packet->id())); if (!packet->oid.isNull()) { m_data.insert(kOID, QString(ChatId::toBase32(packet->oid.byteArray()))); m_data.insert(kMDate, packet->mdate); } }
int FacebookProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) { MCONTACT hContact = MCONTACT(wParam); bool bIsChatroom = isChatRoom(hContact); Menu_ShowItem(g_hContactMenuVisitProfile, !bIsChatroom); Menu_ShowItem(g_hContactMenuVisitFriendship, !bIsChatroom); Menu_ShowItem(g_hContactMenuVisitConversation, true); Menu_ShowItem(g_hContactMenuPostStatus, !bIsChatroom); if (!isOffline() && !bIsChatroom) { bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0; BYTE type = getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0); Menu_ShowItem(g_hContactMenuAuthAsk, ctrlPressed || type == CONTACT_NONE || !type); Menu_ShowItem(g_hContactMenuAuthGrant, ctrlPressed || type == CONTACT_APPROVE); Menu_ShowItem(g_hContactMenuAuthDeny, ctrlPressed || type == CONTACT_APPROVE); Menu_ShowItem(g_hContactMenuAuthRevoke, ctrlPressed || type == CONTACT_FRIEND); Menu_ShowItem(g_hContactMenuAuthCancel, ctrlPressed || type == CONTACT_REQUEST); Menu_ShowItem(g_hContactMenuPoke, true); } return 0; }
INT_PTR FacebookProto::GetNotificationsCount(WPARAM wParam, LPARAM lParam) { if (isOffline()) return 0; return facy.notifications.size(); }
INT_PTR FacebookProto::RefreshBuddyList(WPARAM, LPARAM) { if (!isOffline()) { facy.client_notify(TranslateT("Refreshing buddy list...")); ForkThread(&FacebookProto::ProcessBuddyList, NULL); } return 0; }
INT_PTR FacebookProto::CheckFriendRequests(WPARAM, LPARAM) { if (!isOffline()) { facy.client_notify(TranslateT("Checking friend requests...")); ProcessFriendRequests(NULL); } return 0; }
INT_PTR FacebookProto::CheckNewsfeeds(WPARAM, LPARAM) { if (!isOffline()) { facy.client_notify(TranslateT("Loading newsfeeds...")); facy.last_feeds_update_ = 0; ForkThread(&FacebookProto::ProcessFeeds, NULL); } return 0; }
HANDLE FacebookProto::SearchByEmail(const PROTOCHAR* email) { if (isOffline()) return 0; TCHAR *temail = mir_tstrdup(email); ForkThread(&FacebookProto::SearchAckThread, temail); return temail; }
HANDLE FacebookProto::SearchBasic(const PROTOCHAR* id) { if (isOffline()) return 0; TCHAR *tid = mir_tstrdup(id); ForkThread(&FacebookProto::SearchIdAckThread, tid); return tid; }
int WhatsAppProto::RefreshBuddyList(WPARAM, LPARAM ) { debugLogA(""); if (!isOffline()) { //ForkThread( } return 0; }
HANDLE WhatsAppProto::SearchBasic( const PROTOCHAR* id ) { if (isOffline()) return 0; TCHAR* email = mir_tstrdup(id); ForkThread(&WhatsAppProto::SearchAckThread, email); return email; }
void WhatsAppProto::RequestFriendship(MCONTACT hContact) { if (hContact == NULL || isOffline()) return; ptrA jid(getStringA(hContact, WHATSAPP_KEY_ID)); if (jid) { m_pConnection->sendPresenceSubscriptionRequest((char*)jid); } }
INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam, LPARAM) { if (wParam == NULL || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); ForkThread(&FacebookProto::ApproveContactToServer, hContact); return 0; }
INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam)); ForkThread(&FacebookProto::ApproveContactToServer, hContact); return 0; }
void RenderAf::deregister( JobContainer * jobs, MonitorContainer * monitoring ) { if( isOffline()) { appendLog("Render deregister request - offline already."); return; } appendLog("Render deregister request."); offline( jobs, af::TaskExec::UPRenderDeregister, monitoring); }
HANDLE WhatsAppProto::SearchBasic(const TCHAR* id) { if (isOffline()) return 0; // fake - we always accept search SearchParam *param = new SearchParam(id, GetSerial()); ForkThread(&WhatsAppProto::SearchAckThread, param); return (HANDLE)param->id; }
INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam, LPARAM) { if (wParam == NULL || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); ForkThread(&FacebookProto::CancelFriendsRequest, hContact); return 0; }
INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam)); ForkThread(&FacebookProto::CancelFriendsRequest, hContact); return 0; }
int FacebookProto::Authorize(HANDLE hDbEvent) { if (!hDbEvent || isOffline()) return 1; MCONTACT hContact = HContactFromAuthEvent(hDbEvent); if (hContact == INVALID_CONTACT_ID) return 1; return ApproveFriendship(hContact, NULL); }
int FacebookProto::AuthDeny(MEVENT hDbEvent, const TCHAR *) { if (!hDbEvent || isOffline()) return 1; MCONTACT hContact = HContactFromAuthEvent(hDbEvent); if (hContact == INVALID_CONTACT_ID) return 1; return DenyFriendship(hContact, NULL); }
bool Peer::operator<(Peer const& _p) const { if (isOffline() != _p.isOffline()) return isOffline(); else if (isOffline()) if (m_lastAttempted == _p.m_lastAttempted) return m_failedAttempts < _p.m_failedAttempts; else return m_lastAttempted < _p.m_lastAttempted; else if (m_score == _p.m_score) if (m_rating == _p.m_rating) if (m_failedAttempts == _p.m_failedAttempts) return id < _p.id; else return m_failedAttempts < _p.m_failedAttempts; else return m_rating < _p.m_rating; else return m_score < _p.m_score; }
void OmegleProto::ProcessEvents( void* data ) { if ( data == NULL ) return; std::string* resp = (std::string*)data; if ( isOffline() ) goto exit; LOG("***** Starting processing messages"); CODE_BLOCK_TRY std::vector< Omegle_message* > messages; Omegle_json_parser* p = new Omegle_json_parser( this ); p->parse_messages( data, &messages ); delete p; for(std::vector<Omegle_message*>::size_type i=0; i<messages.size( ); i++) { LOG(" Got message: %s", messages[i]->message_text.c_str()); /* PROTORECVEVENT recv = {}; CCSDATA ccs = {}; recv.flags = PREF_UTF; recv.szMessage = const_cast<char*>(messages[i]->message_text.c_str()); recv.timestamp = static_cast<DWORD>(messages[i]->time); ccs.hContact = hContact; ccs.szProtoService = PSR_MESSAGE; ccs.wParam = ID_STATUS_ONLINE; ccs.lParam = reinterpret_cast<LPARAM>(&recv); CallService(MS_PROTO_CHAINRECV,0,reinterpret_cast<LPARAM>(&ccs));*/ delete messages[i]; } messages.clear(); LOG("***** Messages processed"); CODE_BLOCK_CATCH LOG("***** Error processing messages: %s", e.what()); CODE_BLOCK_END exit: delete resp; }
INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; ForkThread(&FacebookProto::SendPokeWorker, new std::string(id)); return 0; }
INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; ForkThread(&FacebookProto::AddContactToServer, new std::string(id)); return 0; }
int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) { if (!hDbEvent || isOffline()) return 1; MCONTACT hContact = HContactFromAuthEvent(hDbEvent); if (hContact == INVALID_CONTACT_ID) return 1; // TODO: hide from facebook requests list if (db_get_b(hContact, "CList", "NotOnList", 0)) CallService(MS_DB_CONTACT_DELETE, hContact, 0); return 0; }
int FacebookProto::OnDbEventRead(WPARAM contactID, LPARAM dbei) { std::map<MCONTACT, bool>::iterator it = facy.ignore_read.find(contactID); if (it != facy.ignore_read.end()) { if (it->second) // it's TRUE, so we ignore this return 0; else // it's FALSE, so we just remove it from list facy.ignore_read.erase(it); } if ((IsMyContact(contactID, true)) && !isOffline()) { ForkThread(&FacebookProto::ReadMessageWorker, (void*)contactID); } return 0; }
int FacebookProto::OnDbEventRead(WPARAM, LPARAM lParam) { MCONTACT hContact = db_event_getContact((MEVENT)lParam); if (isOffline() || !IsMyContact(hContact, false)) // ignore chats return 0; if (facy.ignore_read.find(hContact) != facy.ignore_read.end()) return 0; // it's there, so we ignore this std::set<MCONTACT> *hContacts = new std::set<MCONTACT>(); hContacts->insert(hContact); ForkThread(&FacebookProto::ReadMessageWorker, (void*)hContacts); return 0; }
int WhatsAppProto::RequestFriendship(WPARAM wParam, LPARAM lParam) { if (wParam == NULL || isOffline()) return 0; MCONTACT hContact = MCONTACT(wParam); DBVARIANT dbv; if ( !getString(hContact, WHATSAPP_KEY_ID, &dbv)) { std::string id(dbv.pszVal); this->connection->sendQueryLastOnline(id); this->connection->sendPresenceSubscriptionRequest(id); db_free(&dbv); } return 0; }