INT_PTR GetCountryList(LPUINT pnListSize, LPIDSTRLIST *pList) { INT_PTR rc = MIR_OK; if (!MyCountries) { CountryListEntry *country; if (!CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&MyCountriesCount, (LPARAM)&country)) { MyCountries = (IDSTRLIST*)mir_alloc(MyCountriesCount * sizeof(IDSTRLIST)); if (MyCountries) { for (UINT i = 0; i < MyCountriesCount; i++) { MyCountries[i].nID = country[i].id; MyCountries[i].pszText = country[i].szName; MyCountries[i].ptszTranslated = Langpack_PcharToTchar(country[i].szName); } // Sort list according translated text and ignore first item. qsort(MyCountries+1, MyCountriesCount-1, sizeof(MyCountries[0]), (int (*)(const void*, const void*))ListSortProc); } else rc = MIR_FAIL; } else rc = MIR_FAIL; } *pnListSize = MyCountriesCount; *pList = MyCountries; return rc; }
INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TMsgQueue *item = (TMsgQueue*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { RECT rc, rcParent; ErrorDlgParam *param = (ErrorDlgParam *)lParam; item = param->item; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)item); if (!param->szMsg || !param->szMsg[0]) SetDlgItemText(hwndDlg, IDC_ERRORTEXT, TranslateT("An unknown error has occurred.")); else { ptrT ptszError(Langpack_PcharToTchar(param->szMsg)); SetDlgItemText(hwndDlg, IDC_ERRORTEXT, ptszError); } SetDlgItemText(hwndDlg, IDC_MSGTEXT, ptrT(mir_utf8decodeT(item->szMsg))); GetWindowRect(hwndDlg, &rc); GetWindowRect(GetParent(hwndDlg), &rcParent); SetWindowPos(hwndDlg, 0, (rcParent.left + rcParent.right - (rc.right - rc.left)) / 2, (rcParent.top + rcParent.bottom - (rc.bottom - rc.top)) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } return TRUE; case WM_DESTROY: mir_free(item->szMsg); mir_free(item); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: SendMessageDirect(ptrT(mir_utf8decodeT(item->szMsg)), item->hContact, GetContactProto(item->hContact)); DestroyWindow(hwndDlg); break; case IDCANCEL: DestroyWindow(hwndDlg); break; } break; } return FALSE; }
static void SvcConstantsTranslateList(LPIDSTRLIST pList, UINT nListCount/*, SortedList *pSorted*/) { if (!pList[0].ptszTranslated) { for (UINT i = 0; i < nListCount; i++) pList[i].ptszTranslated = Langpack_PcharToTchar(pList[i].pszText); // Ignore last item, if it is a "Other" item. if (!mir_strcmp(pList[nListCount-1].pszText, LPGEN("Other"))) nListCount--; // Sort list according translated text and ignore first item. qsort(pList+1, nListCount-1, sizeof(pList[0]), (int (*)(const void*, const void*))ListSortProc); } }
void CMsnProto::MSN_ShowError(const char* msgtext, ...) { TCHAR tBuffer[4096]; va_list tArgs; TCHAR *buf = Langpack_PcharToTchar(msgtext); va_start(tArgs, msgtext); mir_vsntprintf(tBuffer, SIZEOF(tBuffer), buf, tArgs); va_end(tArgs); mir_free(buf); MSN_ShowPopup(m_tszUserName, tBuffer, MSN_ALLOW_MSGBOX | MSN_SHOW_ERROR, NULL); }
static int AddProfileManagerPage(struct DetailsPageInit *opi, OPTIONSDIALOGPAGE *odp) { if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE)) return 1; opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount + 1)); OPTIONSDIALOGPAGE* p = opi->odp + opi->pageCount++; p->cbSize = sizeof(OPTIONSDIALOGPAGE); p->hInstance = odp->hInstance; p->pfnDlgProc = odp->pfnDlgProc; p->position = odp->position; p->ptszTitle = Langpack_PcharToTchar(odp->pszTitle); p->pszGroup = NULL; p->groupPosition = odp->groupPosition; p->hGroupIcon = odp->hGroupIcon; p->hIcon = odp->hIcon; if ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) p->pszTemplate = mir_strdup(odp->pszTemplate); else p->pszTemplate = odp->pszTemplate; return 0; }
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" ); } }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); timerID = 0; { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); mir_subclassWindow(hwndList, PluginListWndProc); HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T(""); col.cx = 40; ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Plugin"); col.cx = 180; ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Name"); col.cx = 180;//max = 220; ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Version"); col.cx = 75; ListView_InsertColumn(hwndList, 3, &col); ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT); // scan the plugin dir for plugins, cos arPluginList.destroy(); szFilter.Empty(); enumPlugins(dialogListPlugins, (WPARAM)hwndDlg, (LPARAM)hwndList); // sort out the headers ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); // dll name int w = ListView_GetColumnWidth(hwndList, 1); if (w > 110) { ListView_SetColumnWidth(hwndList, 1, w = 110); } int max = w < 110 ? 189 + 110 - w : 189; ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); // short name w = ListView_GetColumnWidth(hwndList, 2); if (w > max) ListView_SetColumnWidth(hwndList, 2, max); ListView_SortItems(hwndList, SortPlugins, (LPARAM)hwndDlg); } return TRUE; case WM_NOTIFY: if (lParam) { NMLISTVIEW *hdr = (NMLISTVIEW *)lParam; if (hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) { if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000)) { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM it; it.mask = LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if (!ListView_GetItem(hwndList, &it)) break; PluginListItemData *dat = (PluginListItemData*)it.lParam; if (dat->flags & STATIC_PLUGIN) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // find all another standard plugins by mask and disable them if ((hdr->uNewState == 0x2000) && dat->stdPlugin != 0) { for (int iRow = 0; iRow != -1; iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL)) { if (iRow != hdr->iItem) { // skip the plugin we're standing on LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if (ListView_GetItem(hwndList, &dt)) { PluginListItemData *dat2 = (PluginListItemData*)dt.lParam; if (dat2->stdPlugin & dat->stdPlugin) {// mask differs // the lParam is unset, so when the check is unset the clist block doesnt trigger int iSave = dat2->stdPlugin; dat2->stdPlugin = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK); dat2->stdPlugin = iSave; } } } } } if (bOldMode) ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), TRUE); // this here only in "ghazan mode" SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (hdr->iItem != -1) { int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if (ListView_GetItem(hwndList, &lvi)) { PluginListItemData *dat = (PluginListItemData*)lvi.lParam; TCHAR buf[1024]; ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf)); SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T("")); ptrT tszAuthor(latin2t(sel ? dat->author : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINAUTHOR, tszAuthor); ptrT tszEmail(latin2t(sel ? dat->authorEmail : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINEMAIL, tszEmail); ptrT p(Langpack_PcharToTchar(dat->description)); SetDlgItemText(hwndDlg, IDC_PLUGINLONGINFO, sel ? p : _T("")); ptrT tszCopyright(latin2t(sel ? dat->copyright : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINCPYR, tszCopyright); ptrT tszUrl(latin2t(sel ? dat->homepage : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINURL, tszUrl); if (!equalUUID(miid_last, dat->uuid)) { char szUID[128]; uuidToString(dat->uuid, szUID, sizeof(szUID)); SetDlgItemTextA(hwndDlg, IDC_PLUGINPID, sel ? szUID : ""); } else SetDlgItemText(hwndDlg, IDC_PLUGINPID, sel ? TranslateT("<none>") : _T("")); } } } if (hdr->hdr.code == PSN_APPLY) { bool needRestart = false; TCHAR bufRestart[1024]; int bufLen = mir_sntprintf(bufRestart, _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); for (int iRow = 0; iRow != -1;) { TCHAR buf[1024]; ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); if (!bOldMode && iState != 0x3000) { LVITEM lvi = { 0 }; lvi.mask = LVIF_IMAGE | LVIF_PARAM; lvi.stateMask = -1; lvi.iItem = iRow; lvi.iSubItem = 0; if (ListView_GetItem(hwndList, &lvi)) { lvi.mask = LVIF_IMAGE; PluginListItemData *dat = (PluginListItemData*)lvi.lParam; if (iState == 0x2000) { // enabling plugin if (lvi.iImage == 3 || lvi.iImage == 5) { if (lvi.iImage == 3 && LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } else { // disabling plugin if (lvi.iImage == 2 || lvi.iImage == 4) { if (lvi.iImage == 2 && UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } } } iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } LoadStdPlugins(); ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart); if (needRestart) { mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } } } break; case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { switch (LOWORD(wParam)) { case IDC_GETMOREPLUGINS: Utils_OpenUrl("http://miranda-ng.org/downloads/"); break; case IDC_PLUGINEMAIL: case IDC_PLUGINURL: char buf[512]; char *p = &buf[7]; mir_strcpy(buf, "mailto:"); if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7)) Utils_OpenUrl(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p); break; } } break; case WM_DESTROY: arPluginList.destroy(); RemoveAllItems(GetDlgItem(hwndDlg, IDC_PLUGLIST)); break; } return FALSE; }