void CSametimeProto::LoadOptions() { DBVARIANT dbv; if (!db_get_utf(0, m_szModuleName, "ServerName", &dbv)) { strncpy(options.server_name, dbv.pszVal, LSTRINGLEN); db_free(&dbv); } if (!db_get_utf(0, m_szModuleName, "stid", &dbv)) { strncpy(options.id, dbv.pszVal, LSTRINGLEN); db_free(&dbv); } if (!db_get_utf(0, m_szModuleName, "Password", &dbv)) { strncpy(options.pword, dbv.pszVal, LSTRINGLEN); db_free(&dbv); } options.port = db_get_dw(0, m_szModuleName, "ServerPort", DEFAULT_PORT); options.encrypt_session = (db_get_b(0, m_szModuleName, "EncryptSession", 0) == 1); options.client_id = db_get_dw(0, m_szModuleName, "ClientID", DEFAULT_ID); options.client_versionMajor = db_get_dw(0, m_szModuleName, "ClientVersionMajor", DEFAULT_CV_MAJOR); DWORD defaultCVMinor; if (db_get_b(0, m_szModuleName, "UseOldClientVer", 0) == 1){ // if sb have checked old deprecated option 'Use old client version' respect it defaultCVMinor = 0x001d; } else { defaultCVMinor = DEFAULT_CV_MINOR; } options.client_versionMinor = db_get_dw(0, m_szModuleName, "ClientVersionMinor", defaultCVMinor); // one time options conversion if (db_get_b(0, m_szModuleName, "UseOldClientVer", -1) != -1){ db_unset(0, m_szModuleName, "UseOldClientVer"); db_set_dw(0, m_szModuleName, "ClientVersionMajor", options.client_versionMajor); db_set_dw(0, m_szModuleName, "ClientVersionMinor", options.client_versionMinor); } options.get_server_contacts = (db_get_b(0, m_szModuleName, "GetServerContacts", 1) == 1); options.add_contacts = (db_get_b(0, m_szModuleName, "AutoAddContacts", 0) == 1); options.idle_as_away = (db_get_b(0, m_szModuleName, "IdleAsAway", 1) == 1); // if popups not installed, will be changed to 'ED_BAL' (balloons) in main.cpp, modules loaded options.err_method = (ErrorDisplay)db_get_b(0, m_szModuleName, "ErrorDisplay", ED_POP); // funny logic :) ... try to avoid message boxes // if want baloons but no balloons, try popups // if want popups but no popups, try baloons // if, after that, you want balloons but no balloons, revert to message boxes if (options.err_method == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) options.err_method = ED_POP; if (options.err_method == ED_POP && !ServiceExists(MS_POPUP_SHOWMESSAGE)) options.err_method = ED_BAL; if (options.err_method == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) options.err_method = ED_MB; debugLog(_T("LoadOptions() loaded: ServerName:len=[%d], id:len=[%d], pword:len=[%d]"), options.server_name == NULL ? -1 : mir_strlen(options.server_name), options.id == NULL ? -1 : mir_strlen(options.id), options.pword == NULL ? -1 : mir_strlen(options.pword)); debugLog(_T("LoadOptions() loaded: port=[%d], encrypt_session=[%d], ClientID=[%d], ClientVersionMajor=[%d], ClientVersionMinor=[%d]"), options.port, options.encrypt_session, options.client_id, options.client_versionMajor, options.client_versionMinor); debugLog(_T("LoadOptions() loaded: get_server_contacts=[%d], add_contacts=[%d], idle_as_away=[%d], err_method=[%d]"), options.get_server_contacts, options.add_contacts, options.idle_as_away, options.err_method); }
int CSametimeProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)wParam; debugLog(_T("CSametimeProto::PrebuildContactMenu() hContact=[%x]"), hContact); CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(mi); mi.flags = CMIM_FLAGS | (db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 1 ? 0 : CMIF_HIDDEN); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hLeaveChatMenuItem, (LPARAM)&mi); // if user is already in our meeting, bool not_present = true; DBVARIANT dbv; if (my_conference && !db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { char* user_id = dbv.pszVal; GList *members, *mem; members = mem = mwConference_getMembers(my_conference); for (;mem;mem=mem->next) { if (my_login_info && strcmp(user_id, ((mwLoginInfo *)mem->data)->user_id) == 0) { not_present = false; break; } } g_list_free(members); db_free(&dbv); } mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | (db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0 && not_present ? 0 : CMIF_HIDDEN); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hCreateChatMenuItem, (LPARAM)&mi); return 0; }
void CJabberProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen) { int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName); DWORD dwAttributes = GetFileAttributes(pszDest); if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) CreateDirectoryTreeT(pszDest); pszDest[ tPathLen++ ] = '\\'; const TCHAR* szFileType = ProtoGetAvatarExtension( getByte(hContact, "AvatarType", PA_FORMAT_PNG)); if (hContact != NULL) { char str[ 256 ]; DBVARIANT dbv; if (!db_get_utf(hContact, m_szModuleName, "jid", &dbv)) { strncpy(str, dbv.pszVal, sizeof str); str[ sizeof(str)-1 ] = 0; db_free(&dbv); } else _i64toa((LONG_PTR)hContact, str, 10); mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S%s"), ptrA(JabberSha1(str)), szFileType); } else if (m_ThreadInfo != NULL) { mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@%S avatar%s"), m_ThreadInfo->username, m_ThreadInfo->server, szFileType); } else { ptrA res1( getStringA("LoginName")), res2( getStringA("LoginServer")); mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S@%S avatar%s"), (res1) ? (LPSTR)res1 : "noname", (res2) ? (LPSTR)res2 : m_szModuleName, szFileType); } }
void CSametimeProto::UserListCreate() { debugLog(_T("CSametimeProto::UserListCreate() start")); mwServiceAware_unsetAttribute(service_aware, mwAttribute_SPEAKERS); mwServiceAware_unsetAttribute(service_aware, mwAttribute_MICROPHONE); mwServiceAware_unsetAttribute(service_aware, mwAttribute_VIDEO_CAMERA); mwServiceAware_setAttributeBoolean(service_aware, mwAttribute_AV_PREFS_SET, TRUE); mwServiceAware_setAttributeBoolean(service_aware, mwAttribute_FILE_TRANSFER, TRUE); aware_list = mwAwareList_new(service_aware, &mwAwareList_handler); // add all contacts DBVARIANT dbv; mwAwareIdBlock id_block; GList *gl = 0; for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0 /*&& proto && !mir_strcmp( PROTO, proto)*/) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal) { if (GetAwareIdFromContact(hContact, &id_block)) { // add user to aware list gl = g_list_prepend(0, &id_block); mwAwareList_addAware(aware_list, gl); free(id_block.user); g_list_free(gl); } } db_free(&dbv); } } } // add self - might be necessary for some servers if (!db_get_utf(0, m_szModuleName, "stid", &dbv)) { id_block.type = mwAware_USER; id_block.user = dbv.pszVal; id_block.community = 0; gl = g_list_prepend(0, &id_block); mwAwareList_addAware(aware_list, gl); g_list_free(gl); db_free(&dbv); } }
INT_PTR CAimProto::AddToServerList(WPARAM hContact, LPARAM) { if (m_state != 1) return 0; DBVARIANT dbv; if (!db_get_utf(hContact, MOD_KEY_CL, OTH_KEY_GP, &dbv) && dbv.pszVal[0]) { add_contact_to_group(hContact, dbv.pszVal); db_free(&dbv); } else add_contact_to_group(hContact, AIM_DEFAULT_GROUP); return 0; }
int CAimProto::OnDbSettingChanged(WPARAM wParam,LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; if (strcmp(cws->szModule, MOD_KEY_CL) == 0 && state == 1 && wParam) { HANDLE hContact = (HANDLE)wParam; if (strcmp(cws->szSetting, AIM_KEY_NL) == 0) { if (cws->value.type == DBVT_DELETED) { DBVARIANT dbv; if (!db_get_utf(hContact, MOD_KEY_CL, OTH_KEY_GP, &dbv) && dbv.pszVal[0]) { add_contact_to_group(hContact, dbv.pszVal); db_free(&dbv); } else add_contact_to_group(hContact, AIM_DEFAULT_GROUP); } } else if (strcmp(cws->szSetting, "MyHandle") == 0) { char* name; switch (cws->value.type) { case DBVT_DELETED: set_local_nick(hContact, NULL, NULL); break; case DBVT_ASCIIZ: name = mir_utf8encode(cws->value.pszVal); set_local_nick(hContact, name, NULL); mir_free(name); break; case DBVT_UTF8: set_local_nick(hContact, cws->value.pszVal, NULL); break; case DBVT_WCHAR: name = mir_utf8encodeW(cws->value.pwszVal); set_local_nick(hContact, name, NULL); mir_free(name); break; } } } return 0; }
MCONTACT CSametimeProto::FindContactByUserId(const char* id) { DBVARIANT dbv; for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal && mir_strcmp(id, dbv.pszVal) == 0) { db_free(&dbv); return hContact; } db_free(&dbv); } } return 0; }
int __cdecl CAimProto::AuthRequest(MCONTACT hContact, const TCHAR* szMessage) { //Not a real authrequest- only used b/c we don't know the group until now. if (state != 1) return 1; DBVARIANT dbv; if (!db_get_utf(hContact, MOD_KEY_CL, OTH_KEY_GP, &dbv) && dbv.pszVal[0]) { add_contact_to_group(hContact, dbv.pszVal); db_free(&dbv); } else add_contact_to_group(hContact, AIM_DEFAULT_GROUP); return 0; }
bool CSametimeProto::GetAwareIdFromContact(MCONTACT hContact, mwAwareIdBlock* id_block) { char *proto = GetContactProto(hContact); DBVARIANT dbv; if (proto && !mir_strcmp(m_szModuleName, proto)) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal) { id_block->type = mwAware_USER; id_block->user = _strdup(dbv.pszVal); id_block->community = 0; db_free(&dbv); return true; } db_free(&dbv); } } return false; }
void LoadOptions() { options.default_policy = db_get_w(0, MODULENAME, "DefaultPolicy", OTRL_POLICY_OPPORTUNISTIC); // deal with changed flags in proto.h and new interpretation of 'manual' mode (see common.h) switch(options.default_policy) { case OTRL_POLICY_MANUAL: options.default_policy = OTRL_POLICY_MANUAL_MOD; break; case OTRL_POLICY_OPPORTUNISTIC: case OTRL_POLICY_MANUAL_MOD: case OTRL_POLICY_ALWAYS: case OTRL_POLICY_NEVER: break; default: options.default_policy = OTRL_POLICY_OPPORTUNISTIC; break; } options.err_method = (ErrorDisplay)db_get_w(0, MODULENAME, "ErrorDisplay", ED_POP); options.prefix_messages = (db_get_b(0, MODULENAME, "PrefixMessages", 0) == 1); options.msg_inline = (db_get_b(0, MODULENAME, "MsgInline", 0) == 1); options.msg_popup = (db_get_b(0, MODULENAME, "MsgPopup", 1) == 1); options.delete_history = (db_get_b(0, MODULENAME, "NoHistory", 0) == 1); options.delete_systeminfo = (db_get_b(0, MODULENAME, "NoSystemHistory", 0) == 1); options.autoshow_verify = (db_get_b(0, MODULENAME, "AutoShowVerify", 1) == 1); DBVARIANT dbv; if (!db_get_utf(0, MODULENAME, "Prefix", &dbv)) { mir_strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN); db_free(&dbv); } else mir_strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN); options.end_offline = (db_get_b(0, MODULENAME, "EndOffline", 1) == 1); options.end_window_close = (db_get_b(0, MODULENAME, "EndWindowClose", 0) == 1); options.bHavePopups = 0 != ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_SHOWMESSAGE); options.bHaveSecureIM = 0 != ServiceExists("SecureIM/IsContactSecured"); options.bHaveButtonsBar = 0 != ServiceExists(MS_BB_ADDBUTTON); LoadFilenames(); }
INT_PTR Meta_Convert(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; char *group = 0; // Get some information about the selected contact. if ( !db_get_utf((HANDLE)wParam, "CList", "Group", &dbv)) { group = _strdup(dbv.pszVal); db_free(&dbv); } // Create a new metacontact HANDLE hMetaContact = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); if (hMetaContact) { db_set_dw(hMetaContact, META_PROTO, META_ID,nextMetaID); db_set_dw(hMetaContact, META_PROTO, "NumContacts",0); db_set_dw(NULL, META_PROTO, "NextMetaID", ++nextMetaID); // Add the MetaContact protocol to the new meta contact CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hMetaContact, (LPARAM)META_PROTO); if (group) db_set_utf(hMetaContact, "CList", "Group", group); // Assign the contact to the MetaContact just created (and make default). if ( !Meta_Assign((HANDLE)wParam, hMetaContact, TRUE)) { MessageBox(0, TranslateT("There was a problem in assigning the contact to the MetaContact"), TranslateT("Error"), MB_ICONEXCLAMATION); CallService(MS_DB_CONTACT_DELETE, (WPARAM)hMetaContact, 0); return 0; } // hide the contact if clist groups disabled (shouldn't create one anyway since menus disabled) if ( !Meta_IsEnabled()) db_set_b(hMetaContact, "CList", "Hidden", 1); } free(group); return (INT_PTR)hMetaContact; }
bool Omegle_client::start() { handle_entry( "start" ); this->server_ = get_server(); //parent->debugLogA("Chosing server %s", this->server_.c_str()); //std::string log = Translate("Chosing server: ") + this->server_; //parent->UpdateChat(NULL, log.c_str()); std::string data; if (this->spy_mode_) { //// get last server from list, which is for spy mode //this->server_ = servers[SIZEOF(servers)-1]; if (this->question_.empty()) { data = "&wantsspy=1"; } else { data = "&ask=" + utils::url::encode(this->question_); data += "&cansavequestion="; data += db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_REUSE_QUESTION, 0) ? "1" : "0"; } } else if ( db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_MEET_COMMON, 0)) { DBVARIANT dbv; if (!db_get_utf(NULL, parent->m_szModuleName, OMEGLE_KEY_INTERESTS, &dbv)) { std::string topics = dbv.pszVal; std::string topic; db_free(&dbv); std::string::size_type pos = 0; std::string::size_type pos2 = 0; while ((pos2 = topics.find(",", pos)) != std::string::npos) { topic = topics.substr(pos, pos2 - pos); topic = utils::text::trim(topic); if (!topic.empty()) { if (pos > 0) data += ","; data += "\"" + topic + "\""; } pos = pos2 + 1; } topic = topics.substr(pos); topic = utils::text::trim(topic); if (!topic.empty()) { if (pos > 0) data += ","; data += "\"" + topic + "\""; } parent->debugLogA("TOPICS: %s", data.c_str()); if (!data.empty()) { data = "[" + data + "]"; data = "&topics=" + utils::url::encode(data); } //// get any server but last, which is for spy mode //this->server_ = get_server(true); } } if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_SERVER_INFO, 0)) { std::string count = get_page( OMEGLE_REQUEST_COUNT ); if (!count.empty()) { char str[255]; mir_snprintf(str, sizeof(str), Translate("Connected to server %s. There are %s users online now."), server_.c_str(), count.c_str()); TCHAR *msg = mir_a2t(str); parent->UpdateChat(NULL, msg); mir_free(msg); } } else { char str[255]; mir_snprintf(str, sizeof(str), Translate("Connected to server %s."), server_.c_str()); TCHAR *msg = mir_a2t(str); parent->UpdateChat(NULL, msg); mir_free(msg); } // Send validation http::response resp = flap( OMEGLE_REQUEST_START, NULL, &data ); switch ( resp.code ) { case HTTP_CODE_FAKE_DISCONNECTED: { // If is is only timeout error, try login once more if ( handle_error( "start" )) return start(); else return false; } case HTTP_CODE_OK: { if (!resp.data.empty()) { this->chat_id_ = resp.data.substr(1,resp.data.length()-2); this->state_ = STATE_WAITING; return handle_success( "start" ); } else { return handle_error( "start", FORCE_DISCONNECT ); } } default: return handle_error( "start", FORCE_DISCONNECT ); } }
bool Omegle_client::events() { HANDLE_ENTRY; std::string data = "id=" + this->chat_id_; // Get update http::response resp = flap(OMEGLE_REQUEST_EVENTS, &data); // Return switch (resp.code) { case HTTP_CODE_OK: { if (resp.data == "null") { // Everything is OK, no new message received -- OR it is a problem // TODO: if we are waiting for Stranger with common likes, then we should try standard Stranger if this takes too long return HANDLE_ERROR(false); } else if (resp.data == "fail") { // Something went wrong return HANDLE_ERROR(false); } JSONROOT root(resp.data.c_str()); if (root == NULL) return HANDLE_ERROR(false); bool newStranger = false; bool waiting = false; for (size_t i = 0; i < json_size(root); i++) { JSONNode *item = json_at(root, i); if (item == NULL) continue; std::string name = _T2A(json_as_string(json_at(item, 0))); if (name == "waiting") { // We are just waiting for new Stranger waiting = true; } else if (name == "identDigests") { // We get some comma separated hashes, I'm not sure what for } else if (name == "statusInfo") { JSONNode *data = json_at(item, 1); // We got some object as second parameter //data["antinudepercent"]; // probably 1 by default //data["antinudeservers"]; // array of server names, like "waw3.omegle.com" //data["rtmfp"]; // some rtmfp protocol address //data["servers"]; // array of server names, like "front5.omegle.com" //data["spyeeQueueTime"]; // some float number, e.g. 0.0701999903 //data["spyQueueTime"]; // some float number, e.g. 4.7505000114 //data["timestamp"]; // e.g. 1445336566.0196209 // We got info about count of connected people there ptrT count(json_as_string(json_get(data, "count"))); TCHAR strT[255]; mir_sntprintf(strT, TranslateT("On whole Omegle are %s strangers online now."), count); parent->UpdateChat(NULL, strT); } else if (name == "serverMessage") { ptrT message(json_as_string(json_at(item, 1))); parent->UpdateChat(NULL, TranslateTS(message)); } else if (name == "connected") { // Stranger connected if (this->spy_mode_ && !this->question_.empty()) { parent->AddChatContact(TranslateT("Stranger 1")); parent->AddChatContact(TranslateT("Stranger 2")); this->state_ = STATE_SPY; } else { parent->AddChatContact(TranslateT("Stranger")); this->state_ = STATE_ACTIVE; } newStranger = true; waiting = false; } else if (name == "commonLikes") { std::tstring likes = TranslateT("You and the Stranger both like: "); JSONNode *items = json_at(item, 1); size_t size = json_size(items); for (size_t i = 0; i < size; i++) { likes += ptrT(json_as_string(json_at(items, i))); if (i < size - 1) likes += _T(", "); } parent->debugLog(_T("Got common likes: '%s'"), likes.c_str()); parent->SetTopic(likes.c_str()); } else if (name == "question") { ptrT question(json_as_string(json_at(item, 1))); parent->SetTopic(question); } else if (name == "typing" || name == "spyTyping") { // Stranger is typing, not supported by chat module yet SkinPlaySound("StrangerTyp"); StatusTextData st = { 0 }; st.cbSize = sizeof(st); st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("typing_on")); ptrT who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_tstrdup(_T("Stranger"))); mir_sntprintf(st.tszText, TranslateT("%s is typing."), TranslateTS(who)); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)&st); } else if (name == "stoppedTyping" || name == "spyStoppedTyping") { // Stranger stopped typing, not supported by chat module yet SkinPlaySound("StrangerTypStop"); StatusTextData st = { 0 }; st.cbSize = sizeof(st); st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("typing_off")); ptrT who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_tstrdup(_T("Stranger"))); mir_sntprintf(st.tszText, TranslateT("%s stopped typing."), TranslateTS(who)); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)&st); } else if (name == "gotMessage") { CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL); // Play sound as we received message SkinPlaySound("StrangerMessage"); if (state_ == STATE_ACTIVE) { ptrT msg(json_as_string(json_at(item, 1))); parent->UpdateChat(TranslateT("Stranger"), msg); } } else if (name == "spyMessage") { CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL); // Play sound as we received message SkinPlaySound("StrangerMessage"); if (state_ == STATE_SPY) { ptrT stranger(json_as_string(json_at(item, 1))); ptrT msg(json_as_string(json_at(item, 2))); parent->UpdateChat(stranger, msg); } } else if (name == "strangerDisconnected") { CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL); // Stranger disconnected if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0)) { SkinPlaySound("StrangerChange"); parent->NewChat(); } else parent->StopChat(false); } else if (name == "spyDisconnected") { CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), NULL); ptrT stranger(json_as_string(json_at(item, 1))); TCHAR strT[255]; mir_sntprintf(strT, TranslateT("%s disconnected."), TranslateTS(stranger)); parent->UpdateChat(NULL, strT); // Stranger disconnected if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0)) { SkinPlaySound("StrangerChange"); parent->NewChat(); } else parent->StopChat(false); } else if (name == "recaptchaRequired") { // Nothing to do with recaptcha parent->UpdateChat(NULL, TranslateT("Recaptcha is required.\nOpen http://omegle.com , solve Recaptcha and try again.")); parent->StopChat(false); } else if (name == "recaptchaRejected") { // Nothing to do with recaptcha parent->StopChat(false); } else if (name == "error") { ptrT error(json_as_string(json_at(item, 1))); TCHAR strT[255]; mir_sntprintf(strT, TranslateT("Error: %s"), TranslateTS(error)); parent->UpdateChat(NULL, strT); } } if (newStranger && !spy_mode_) { // We got new stranger in this event, lets say him "Hi message" if enabled if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_HI_ENABLED, 0)) { DBVARIANT dbv; if (!db_get_utf(NULL, parent->m_szModuleName, OMEGLE_KEY_HI, &dbv)) { std::vector<std::string> messages; utils::text::explode(std::string(dbv.pszVal), "\r\n", &messages); db_free(&dbv); int pos = rand() % messages.size(); std::string *message = new std::string(messages.at(pos)); parent->debugLogA("**Chat - saying Hi! message"); parent->ForkThread(&OmegleProto::SendMsgWorker, message); } else parent->debugLogA("**Chat - Hi message is enabled but not used"); } } if (waiting) { // If we are only waiting in this event... parent->UpdateChat(NULL, TranslateT("We are still waiting...")); } return HANDLE_SUCCESS; } case HTTP_CODE_FAKE_DISCONNECTED: // timeout return HANDLE_SUCCESS; case HTTP_CODE_FAKE_ERROR: default: return HANDLE_ERROR(false); } }
INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { SessionAnnounceDialogProc_arg* arg = (SessionAnnounceDialogProc_arg*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); CSametimeProto *proto; switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); arg = (SessionAnnounceDialogProc_arg*)lParam; proto = arg->proto; proto->debugLog(_T("SessionAnnounceDialogProc WM_INITDIALOG")); SendDlgItemMessage(hwndDlg, IDC_LST_ANTO, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); { LVCOLUMN lvc; // Initialize the LVCOLUMN structure. // The mask specifies that the format, width, text, and // subitem members of the structure are valid. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.iSubItem = 0; lvc.pszText = TranslateT("Recipients"); lvc.cx = 300; // width of column in pixels ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_LST_ANTO), 0, &lvc); } //enumerate plugins, fill in list { ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_LST_ANTO)); LVITEM lvI; // Some code to create the list-view control. // Initialize LVITEM members that are common to all items. lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_NORECOMPUTE;// | LVIF_IMAGE; lvI.iItem = 0; lvI.iSubItem = 0; for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) { if (db_get_b(hContact, proto->m_szModuleName, "ChatRoom", 0) == 0 && db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { lvI.lParam = (LPARAM)hContact; lvI.pszText = pcli->pfnGetContactDisplayName(hContact, 0); ListView_InsertItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI); lvI.iItem++; } } } } return 0; case WM_CLOSE: proto = arg->proto; proto->debugLog(_T("SessionAnnounceDialogProc WM_CLOSE")); mir_free(arg); DestroyWindow(hwndDlg); break; case WM_COMMAND: proto = arg->proto; if (HIWORD(wParam) == BN_CLICKED) { int size; switch (LOWORD(wParam)) { case IDC_BUT_SELALL: size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, true); return 0; case IDC_BUT_SELINV: size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, !ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)); return 0; case IDOK: proto->debugLog(_T("SessionAnnounceDialogProc IDOK BN_CLICKED")); { // build SendAnnouncementFunc_arg SendAnnouncementFunc_arg* safArg = (SendAnnouncementFunc_arg*)mir_calloc(sizeof(SendAnnouncementFunc_arg)); DBVARIANT dbv; LVITEM lvI = { 0 }; char id[1024]; mir_strcpy(id, "@U"); // documentation says prepend '@U' to usernames and '@G' to notes group names - but char *p = id + 2; // it's wrong - it works for a list of user id's with no prefix - so we'll do both // build recipient list safArg->recipients = 0; int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); int send_count = 0; for (int i = 0; i < size; i++) { if (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)) { lvI.iItem = i; lvI.iSubItem = 0; lvI.mask = LVIF_PARAM; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI); if (!db_get_utf((MCONTACT)lvI.lParam, proto->m_szModuleName, "stid", &dbv)) { safArg->recipients = g_list_prepend(safArg->recipients, _strdup(dbv.pszVal)); mir_strcpy(p, dbv.pszVal); safArg->recipients = g_list_prepend(safArg->recipients, _strdup(id)); send_count++; db_free(&dbv); } } } if (send_count > 0) { GetDlgItemText(hwndDlg, IDC_ED_ANMSG, safArg->msg, MAX_MESSAGE_SIZE); safArg->proto = proto; SendAnnouncementFunc sendAnnouncementFunc = arg->sendAnnouncementFunc; sendAnnouncementFunc(safArg); } // clean up recipient list if (safArg->recipients) { for (GList *rit = safArg->recipients; rit; rit = rit->next) { free(rit->data); } g_list_free(safArg->recipients); } mir_free(safArg); DestroyWindow(hwndDlg); } return 0; case IDCANCEL: DestroyWindow(hwndDlg); return 0; } } break; } return 0; }
int CMsnProto::getStringUtf(MCONTACT hContact, const char* name, DBVARIANT* result) { return db_get_utf(hContact, m_szModuleName, name, result); }
void mwAwareList_on_aware(mwAwareList* list, mwAwareSnapshot* aware) { CSametimeProto* proto = getProtoFromMwAwareList(list);; MCONTACT hContact = proto->FindContactByUserId(aware->id.user); char* group = 0; DBVARIANT dbv; // update self - necessary for some servers if (aware->online && !db_get_utf(0, proto->m_szModuleName, "stid", &dbv) && mir_strcmp(aware->id.user, dbv.pszVal) == 0) { int new_status = ID_STATUS_OFFLINE; switch (aware->status.status) { case mwStatus_ACTIVE: new_status = ID_STATUS_ONLINE; break; case mwStatus_AWAY: new_status = ID_STATUS_AWAY; break; case mwStatus_IDLE: new_status = ID_STATUS_IDLE; break; case mwStatus_BUSY: new_status = ID_STATUS_DND; break; case mwStatus_IN_MEETING: // link 'in meeting' Sametime status new_status = ID_STATUS_OCCUPIED; // with 'Occupied' MIR_NG status break; } if (new_status != ID_STATUS_IDLE) //SetSessionStatus(new_status); proto->UpdateSelfStatus(); db_free(&dbv); } if (hContact && !db_get_utf(hContact, "CList", "Group", &dbv)) { group = _strdup(dbv.pszVal); db_free(&dbv); } if (aware->group && (!group || mir_strcmp(aware->group, group) || !hContact)) { // dynamic group member we're not already aware of // resolve server alias to user id via resolver mwSametimeList* user_list = mwSametimeList_new(); mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_DYNAMIC, aware->group); char buff[256]; mir_snprintf(buff, "GA_%s", aware->group); if (!db_get_utf(0, proto->szProtoGroups, buff, &dbv)) { mwSametimeGroup_setAlias(stgroup, dbv.pszVal); db_free(&dbv); } GList* query = g_list_prepend(0, aware->id.user); mwServiceResolve_resolve(proto->service_resolve, query, mwResolveFlag_USERS, mwResolve_handler_dyngroup_callback, (gpointer)stgroup, 0); g_list_free(query); } else if (hContact) { if (aware->online) { int new_status = ID_STATUS_OFFLINE; switch (aware->status.status) { case mwStatus_ACTIVE: new_status = ID_STATUS_ONLINE; db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0); db_set_w(hContact, proto->m_szModuleName, "Status", new_status); break; case mwStatus_AWAY: new_status = ID_STATUS_AWAY; db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0); db_set_w(hContact, proto->m_szModuleName, "Status", new_status); break; case mwStatus_IDLE: if (proto->options.idle_as_away) { new_status = ID_STATUS_AWAY; db_set_w(hContact, proto->m_szModuleName, "Status", new_status); } db_set_dw(hContact, proto->m_szModuleName, "IdleTS", (DWORD)time(0)); break; case mwStatus_BUSY: new_status = ID_STATUS_DND; db_set_w(hContact, proto->m_szModuleName, "Status", new_status); db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0); break; case mwStatus_IN_MEETING: // link 'in meeting' Sametime status to 'Occipied' MIR_NG status new_status = ID_STATUS_OCCUPIED; db_set_w(hContact, proto->m_szModuleName, "Status", new_status); db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0); break; } } else db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE); if (proto->service_aware) { const char* desc = mwServiceAware_getText(proto->service_aware, &aware->id); if (desc) //db_set_utf(hContact, m_szModuleName, "StatusMsg", desc); db_set_utf(hContact, "CList", "StatusMsg", desc); else //db_set_utf(hContact, m_szModuleName, "StatusMsg", ""); //db_unset(hContact, m_szModuleName, "StatusMsg"); db_unset(hContact, "CList", "StatusMsg"); } } if (group) free(group); }
int CMsnProto::getStringUtf(const char* name, DBVARIANT* result) { return db_get_utf(NULL, m_szModuleName, name, result); }
void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) { debugLog(_T("CSametimeProto::ExportContactsToList() start")); mwSametimeGroup* stgroup = 0; char* group_name; char* group_alias; mwSametimeGroupType group_type; bool group_open; mwSametimeUser* stuser; char* user_alias; char* user_shortName; mwSametimeUserType user_type; DBVARIANT dbv, dbv2; char buff[256]; mwAwareIdBlock id_block; mwIdBlock uid; GList* gl = 0; for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal) { if (GetAwareIdFromContact(hContact, &id_block)) { if (!db_get_utf(hContact, "CList", "Group", &dbv2)) { group_alias = _strdup(dbv2.pszVal); db_free(&dbv2); } else group_alias = _strdup(Translate("None")); if (group_alias) { mir_snprintf(buff, "GT_%s", group_alias); group_type = (mwSametimeGroupType)db_get_b(0, szProtoGroups, buff, (BYTE)mwSametimeGroup_NORMAL); // apparently we don't want to upload contacts in dynamic groups - see gaim sametime plugin comments if (group_type == mwSametimeGroup_DYNAMIC) { db_free(&dbv); free(id_block.user); free(group_alias); hContact = db_find_next(hContact, m_szModuleName); continue; } mir_snprintf(buff, "GN_%s", group_alias); if (!db_get_utf(0, szProtoGroups, buff, &dbv2)) { group_name = _strdup(dbv2.pszVal); db_free(&dbv2); } else group_name = _strdup(group_alias); //group_open = (db_get_b(0, szProtoGroups, buff, 0) == 1); ptrT ptszGroup(mir_utf8decodeT(group_alias)); HANDLE hGroup = Clist_GroupExists(ptszGroup); if (hGroup) { int expanded; CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, (LPARAM)&expanded); group_open = (expanded != 0); } else { mir_snprintf(buff, "GO_%s", group_alias); group_open = (db_get_b(0, szProtoGroups, buff, 0) == 1); } stgroup = 0; stgroup = mwSametimeList_findGroup(user_list, group_name); if (!stgroup) { if (group_name) stgroup = mwSametimeGroup_new(user_list, group_type, group_name); mwSametimeGroup_setAlias(stgroup, group_alias); mwSametimeGroup_setOpen(stgroup, group_open); } free(group_name); free(group_alias); if (!db_get_utf(hContact, m_szModuleName, "Name", &dbv2)) { user_shortName = _strdup(dbv2.pszVal); db_free(&dbv2); } else user_shortName = 0; if (!db_get_utf(hContact, "CList", "MyHandle", &dbv2)) { user_alias = _strdup(dbv2.pszVal); db_free(&dbv2); } else user_alias = 0; user_type = (mwSametimeUserType)db_get_b(hContact, m_szModuleName, "type", (BYTE)mwSametimeUser_NORMAL); uid.user = id_block.user; uid.community = id_block.community; stuser = mwSametimeUser_new(stgroup, user_type, &uid); if (user_shortName) { mwSametimeUser_setShortName(stuser, user_shortName); free(user_shortName); } if (user_alias) { mwSametimeUser_setAlias(stuser, user_alias); free(user_alias); } } free(id_block.user); } } db_free(&dbv); } } }
bool Omegle_client::events( ) { handle_entry( "events" ); std::string data = "id=" + this->chat_id_; // Get update http::response resp = flap( OMEGLE_REQUEST_EVENTS, &data ); // Return switch ( resp.code ) { case HTTP_CODE_OK: { if ( resp.data == "null" ) { // Everything is OK, no new message received -- OR it is a problem // TODO: if we are waiting for Stranger with common likes, then we should try standard Stranger if this takes too long return handle_error( "events" ); } else if ( resp.data == "fail" ) { // Something went wrong return handle_error( "events" ); } std::string::size_type pos = 0; bool newStranger = false; bool waiting = false; if ( resp.data.find( "[\"waiting\"]" ) != std::string::npos ) { // We are just waiting for new Stranger waiting = true; } /*if ( (pos = resp.data.find( "[\"count\"," )) != std::string::npos ) { // We got info about count of connected people there pos += 9; std::string count = utils::text::trim( resp.data.substr(pos, resp.data.find("]", pos) - pos)); char str[255]; mir_snprintf(str, sizeof(str), Translate("On whole Omegle are %s strangers online now."), count.c_str()); TCHAR *msg = mir_a2t_cp(str,CP_UTF8); parent->UpdateChat(NULL, msg); mir_free(msg); }*/ if ( (pos = resp.data.find( "[\"serverMessage\", \"" )) != std::string::npos ) { // We got server message pos += 19; std::string message = utils::text::trim( resp.data.substr(pos, resp.data.find("\"]", pos) - pos)); TCHAR *tstr = Langpack_PcharToTchar(message.c_str()); parent->UpdateChat(NULL, tstr); mir_free(tstr); } if ( resp.data.find( "[\"connected\"]" ) != std::string::npos ) { // Stranger connected if (this->spy_mode_ && !this->question_.empty()) { parent->AddChatContact(TranslateT("Stranger 1")); parent->AddChatContact(TranslateT("Stranger 2")); this->state_ = STATE_SPY; } else { parent->AddChatContact(TranslateT("Stranger")); this->state_ = STATE_ACTIVE; } newStranger = true; waiting = false; } if ( (pos = resp.data.find( "[\"commonLikes\"," )) != std::string::npos ) { pos += 18; std::string like = resp.data.substr(pos, resp.data.find("\"]", pos) - pos); utils::text::replace_all(&like, "\", \"", ", "); parent->debugLogA("Got common likes: '%s'", like.c_str()); like = Translate("You and the Stranger both like: ") + like; TCHAR *msg = mir_a2t(like.c_str()); parent->SetTopic(msg); mir_free(msg); } if ( (pos = resp.data.find( "[\"question\"," )) != std::string::npos ) { pos += 14; std::string question = utils::text::trim( utils::text::special_expressions_decode( utils::text::slashu_to_utf8( resp.data.substr(pos, resp.data.find("\"]", pos) - pos) )) ); TCHAR *msg = mir_a2t_cp(question.c_str(),CP_UTF8); parent->SetTopic(msg); mir_free(msg); } if ( resp.data.find( "[\"typing\"]" ) != std::string::npos || resp.data.find( "[\"spyTyping\"," ) != std::string::npos ) { // Stranger is typing, not supported by chat module yet SkinPlaySound( "StrangerTyp" ); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)TranslateT("Stranger is typing.")); } if ( resp.data.find( "[\"stoppedTyping\"]" ) != std::string::npos || resp.data.find( "[\"spyStoppedTyping\"," ) != std::string::npos ) { // Stranger stopped typing, not supported by chat module yet SkinPlaySound( "StrangerTypStop" ); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)TranslateT("Stranger stopped typing.")); } pos = 0; while ( (pos = resp.data.find( "[\"gotMessage\",", pos )) != std::string::npos ) { pos += 16; std::string message = utils::text::trim( utils::text::special_expressions_decode( utils::text::slashu_to_utf8( resp.data.substr(pos, resp.data.find("\"]", pos) - pos) )) ); if (state_ == STATE_ACTIVE) { TCHAR *msg = mir_a2t_cp(message.c_str(),CP_UTF8); parent->UpdateChat(TranslateT("Stranger"), msg); mir_free(msg); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), 0); } } pos = 0; while ( (pos = resp.data.find( "[\"spyMessage\",", pos )) != std::string::npos ) { pos += 16; std::string message = resp.data.substr(pos, resp.data.find("\"]", pos) - pos); if (state_ == STATE_SPY) { std::string stranger = message.substr(0, message.find("\"")); message = message.substr(stranger.length() + 4); message = utils::text::trim( utils::text::special_expressions_decode( utils::text::slashu_to_utf8( message )) ); stranger = Translate(stranger.c_str()); TCHAR *str = mir_a2t_cp(stranger.c_str(), CP_UTF8); TCHAR *msg = mir_a2t_cp(message.c_str(), CP_UTF8); parent->UpdateChat(str, msg); mir_free(msg); mir_free(str); } } if ( resp.data.find( "[\"strangerDisconnected\"]" ) != std::string::npos ) { // Stranger disconnected if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0)) { SkinPlaySound( "StrangerChange" ); parent->NewChat(); } else parent->StopChat(false); } if ( (pos = resp.data.find( "[\"spyDisconnected\"," )) != std::string::npos ) { pos += 21; std::string stranger = utils::text::trim( utils::text::special_expressions_decode( utils::text::slashu_to_utf8( resp.data.substr(pos, resp.data.find("\"]", pos) - pos) )) ); char str[255]; mir_snprintf(str, sizeof(str), Translate("%s disconnected."), Translate(stranger.c_str())); TCHAR *msg = mir_a2t(str); parent->UpdateChat(NULL, msg); mir_free(msg); // Stranger disconnected if (db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_DONT_STOP, 0)) { SkinPlaySound( "StrangerChange" ); parent->NewChat(); } else parent->StopChat(false); } if ( resp.data.find( "[\"recaptchaRequired\"" ) != std::string::npos ) { // Nothing to do with recaptcha parent->UpdateChat(NULL, TranslateT("Recaptcha is required.\nOpen http://omegle.com , solve Recaptcha and try again.")); parent->StopChat(false); } if ( resp.data.find( "[\"recaptchaRejected\"]" ) != std::string::npos ) { // Nothing to do with recaptcha parent->StopChat(false); } if ( (pos = resp.data.find( "[\"error\"," )) != std::string::npos ) { pos += 11; std::string error = utils::text::trim( utils::text::special_expressions_decode( utils::text::slashu_to_utf8( resp.data.substr(pos, resp.data.find("\"]", pos) - pos) )) ); error = Translate("Error: ") + error; TCHAR *msg = mir_a2t(error.c_str()); parent->UpdateChat(NULL, msg); mir_free(msg); } if (newStranger && state_ != STATE_SPY) { // We got new stranger in this event, lets say him "Hi message" if enabled if ( db_get_b( NULL, parent->m_szModuleName, OMEGLE_KEY_HI_ENABLED, 0 )) { DBVARIANT dbv; if ( !db_get_utf( NULL, parent->m_szModuleName, OMEGLE_KEY_HI, &dbv )) { std::string *message = new std::string(dbv.pszVal); db_free(&dbv); parent->debugLogA("**Chat - saying Hi! message"); parent->ForkThread(&OmegleProto::SendMsgWorker, message); } else parent->debugLogA("**Chat - Hi message is enabled but not used"); } } if (waiting) { // If we are only waiting in this event... parent->UpdateChat(NULL, TranslateT("We are still waiting...")); } return handle_success( "events" ); } case HTTP_CODE_FAKE_DISCONNECTED: // timeout return handle_success( "events" ); case HTTP_CODE_FAKE_ERROR: default: return handle_error( "events" ); } }