/** triggered when someone says something */ void mwServiceConf_on_text(mwConference* conf, mwLoginInfo* user, const char* what) { CSametimeProto* proto = getProtoFromMwConference(conf); proto->debugLog(_T("mwServiceConf_on_text() start")); TCHAR* tszConfId = mir_utf8decodeT(mwConference_getName(conf)); GCDEST gcd = { proto->m_szModuleName }; gcd.ptszID = tszConfId; gcd.iType = GC_EVENT_MESSAGE; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG; TCHAR* textT = mir_utf8decodeT(what); TCHAR* tszUserName = mir_utf8decodeT(user->user_name); TCHAR* tszUserId = mir_utf8decodeT(user->login_id); gce.ptszText = textT; gce.ptszNick = tszUserName; gce.ptszUID = tszUserId; gce.time = (DWORD)time(0); CallService(MS_GC_EVENT, 0, (LPARAM)(GCEVENT *) &gce); mir_free(textT); mir_free(tszUserName); mir_free(tszUserId); mir_free(tszConfId); }
static int icolib_AddIcon(lua_State *L) { const char *name = luaL_checkstring(L, 1); ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2))); ptrT section(mir_utf8decodeT(luaL_optstring(L, 3, MODULE))); ptrT filePath(mir_utf8decodeT(lua_tostring(L, 4))); if (filePath == NULL) { filePath = (TCHAR*)mir_calloc(MAX_PATH + 1); GetModuleFileName(g_hInstance, filePath, MAX_PATH); } SKINICONDESC si = { 0 }; si.flags = SIDF_ALL_TCHAR; si.pszName = mir_utf8decodeA(name); si.description.t = description; si.section.t = section; si.defaultFile.t = filePath; si.hDefaultIcon = GetIcon(IDI_SCRIPT); HANDLE res = IcoLib_AddIcon(&si, g_mLua->GetHLangpack()); lua_pushlightuserdata(L, res); return 1; }
void ShowPopupUtf(const char* line1, const char* line2, int timeout, const MCONTACT hContact) { TCHAR* l1 = (line1) ? mir_utf8decodeT(line1) : NULL; TCHAR* l2 = (line2) ? mir_utf8decodeT(line2) : NULL; ShowPopup(l1, l2, timeout, hContact); if (l1) mir_free(l1); if (l2) mir_free(l2); }
void MakeHotkey(lua_State *L, HOTKEYDESC &hk) { hk.cbSize = sizeof(HOTKEYDESC); lua_getfield(L, -1, "Flags"); hk.dwFlags = lua_tointeger(L, -1); lua_pop(L, 1); if (!(hk.dwFlags & HKD_TCHAR)) hk.dwFlags |= HKD_TCHAR; lua_getfield(L, -1, "Name"); hk.pszName = mir_utf8decodeA(luaL_checkstring(L, -1)); lua_pop(L, 1); lua_getfield(L, -1, "Description"); hk.ptszDescription = mir_utf8decodeT((char*)lua_tostring(L, -1)); lua_pop(L, 1); lua_getfield(L, -1, "Section"); hk.ptszSection = mir_utf8decodeT(luaL_optstring(L, -1, MODULE)); lua_pop(L, 1); lua_getfield(L, -1, "Hotkey"); hk.DefHotKey = lua_tointeger(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "Service"); hk.pszService = mir_utf8decodeA(luaL_checkstring(L, -1)); lua_pop(L, 1); lua_getfield(L, -1, "lParam"); hk.lParam = (LPARAM)lua_touserdata(L, -1); lua_pop(L, 1); }
void CYahooProto::ext_got_search_result(int found, int start, int total, YList *contacts) { struct yahoo_found_contact *yct=NULL; int i=start; YList *en=contacts; LOG(("got search result: ")); LOG(("Found: %d", found)); LOG(("Start: %d", start)); LOG(("Total: %d", total)); PROTOSEARCHRESULT psr = { 0 }; psr.cbSize = sizeof(psr); psr.flags = PSR_TCHAR; psr.reserved[0] = YAHOO_IM_YAHOO; while (en) { yct = ( yahoo_found_contact* )en->data; if (yct == NULL) { LOG(("[%d] Empty record?",i++)); } else { LOG(("[%d] id: '%s', online: %d, age: %d, sex: '%s', location: '%s'", i++, yct->id, yct->online, yct->age, yct->gender, yct->location)); psr.id = mir_utf8decodeT( yct->id ); if (yct->gender[0] != 5) psr.firstName = mir_utf8decodeT( yct->gender ); else psr.firstName = NULL; TCHAR c[10]; if (yct->age > 0) { _itot(yct->age, c,10); psr.lastName = ( TCHAR* )c; } else psr.lastName = NULL; if (yct->location[0] != 5) psr.email = mir_utf8decodeT( yct->location ); else psr.email = NULL; //void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar, // int photo, int yahoo_only) ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr); mir_free(psr.id); mir_free(psr.firstName); mir_free(psr.email); } en = y_list_next(en); } ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0); }
void ext_yahoo_conf_userdecline(int id, const char*, const char *who, const char *room, const char *msg) { TCHAR info[1024]; TCHAR *whot = mir_utf8decodeT(who); TCHAR *msgt = mir_utf8decodeT(msg); mir_sntprintf(info, TranslateT("%s denied invitation with message: %s"), whot, msgt ? msgt : _T("")); GETPROTOBYID(id)->ChatEvent(room, who, GC_EVENT_INFORMATION, info); mir_free(msgt); mir_free(whot); }
static POPUPDATA2* MakePopupData2(lua_State *L) { POPUPDATA2 *ppd = (POPUPDATA2*)mir_calloc(sizeof(POPUPDATA2)); ppd->cbSize = sizeof(POPUPDATA2); lua_pushliteral(L, "Flags"); lua_gettable(L, -2); ppd->flags = lua_tointeger(L, -1); lua_pop(L, 1); if (!(ppd->flags & PU2_TCHAR)) ppd->flags |= PU2_TCHAR; lua_pushliteral(L, "Title"); lua_gettable(L, -2); ppd->lptzTitle = mir_utf8decodeT(lua_tostring(L, -1)); lua_pop(L, 1); lua_pushliteral(L, "Text"); lua_gettable(L, -2); ppd->lptzText = mir_utf8decodeT(luaL_checkstring(L, -1)); lua_pop(L, 1); lua_pushliteral(L, "hContact"); lua_gettable(L, -2); ppd->lchContact = lua_tointeger(L, -1); lua_pop(L, 1); lua_pushliteral(L, "ColorBack"); lua_gettable(L, -2); ppd->colorBack = lua_tonumber(L, -1); lua_pop(L, 1); lua_pushliteral(L, "ColorText"); lua_gettable(L, -2); ppd->colorText = lua_tonumber(L, -1); lua_pop(L, 1); lua_pushliteral(L, "hEvent"); lua_gettable(L, -2); ppd->lchEvent = lua_touserdata(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Timestamp"); lua_gettable(L, -2); ppd->dwTimestamp = lua_tonumber(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Timeout"); lua_gettable(L, -2); ppd->iSeconds = lua_tointeger(L, -1); lua_pop(L, 1); return ppd; }
static int lua_ShellExecute(lua_State *L) { ptrT command(mir_utf8decodeT(lua_tostring(L, 1))); ptrT file(mir_utf8decodeT(lua_tostring(L, 2))); ptrT args(mir_utf8decodeT(lua_tostring(L, 3))); int flags = lua_tointeger(L, 4); ::ShellExecute(NULL, command, file, args, NULL, flags); return 0; }
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; }
void __cdecl SessionAnnounce(struct mwSession* session, struct mwLoginInfo* from, gboolean may_reply, const char* text) { CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); proto->debugLog(_T("SessionAnnounce()")); TCHAR* stzFrom; TCHAR* stzText; TCHAR stzFromBuff[256]; stzFrom = mir_utf8decodeT(from->user_name); stzText = mir_utf8decodeT(text); mir_sntprintf(stzFromBuff, SIZEOF(stzFromBuff), TranslateT("Session announcement - from '%s'"), stzFrom); MessageBox(0, TranslateTS(stzText), stzFromBuff, MB_OK); mir_free(stzText); mir_free(stzFrom); }
static int lua_MessageBox(lua_State *L) { HWND hwnd = (HWND)lua_touserdata(L, 1); ptrT text(mir_utf8decodeT(lua_tostring(L, 2))); ptrT caption(mir_utf8decodeT(lua_tostring(L, 3))); UINT flags = lua_tointeger(L, 4); LANGID langId = GetUserDefaultUILanguage(); DWORD timeout = luaL_optinteger(L, 5, 0xFFFFFFFF); int res = ::MessageBoxTimeout(hwnd, text, caption, flags, langId, timeout); lua_pushinteger(L, res); return 1; }
static int lua_GetIniValue(lua_State *L) { ptrT path(mir_utf8decodeT(luaL_checkstring(L, 1))); ptrT section(mir_utf8decodeT(luaL_checkstring(L, 2))); ptrT key(mir_utf8decodeT(luaL_checkstring(L, 3))); if (lua_isinteger(L, 4)) { int default = lua_tointeger(L, 4); UINT res = ::GetPrivateProfileInt(section, key, default, path); lua_pushinteger(L, res); return 1; }
INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam) { if (!isOnline()) return 1; MCONTACT hContact = MCONTACT(wParam); wall_data *wall = new wall_data(); wall->user_id = ptrA(getStringA(hContact, FACEBOOK_KEY_ID)); wall->isPage = false; if (wall->user_id == facy.self_.user_id) { wall->title = _tcsdup(TranslateT("Own wall")); } else wall->title = getTStringA(hContact, FACEBOOK_KEY_NICK); post_status_data *data = new post_status_data(this, wall); if (wall->user_id == facy.self_.user_id) { for (std::map<std::string, std::string>::iterator iter = facy.pages.begin(); iter != facy.pages.end(); ++iter) { data->walls.push_back(new wall_data(iter->first, mir_utf8decodeT(iter->second.c_str()), true)); } } HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(data)); ShowWindow(hDlg, SW_SHOW); return 0; }
int FillAvatarListFromDB(HWND list, MCONTACT hContact) { int max_pos = 0; BYTE blob[2048]; for (MEVENT hDbEvent = db_event_first(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = sizeof(blob); dbei.pBlob = blob; if (db_event_get(hDbEvent, &dbei) != 0) continue; if (dbei.eventType != EVENTTYPE_AVATAR_CHANGE) continue; // Get time TCHAR date[64]; TimeZone_ToStringT(dbei.timestamp, _T("d s"), date, _countof(date)); // Get file in disk TCHAR path[MAX_PATH]; ptrT tszStoredPath(mir_utf8decodeT((char*)dbei.pBlob)); PathToAbsoluteT(tszStoredPath, path); // Add to list ListEntry *le = new ListEntry(); le->hDbEvent = hDbEvent; le->filename = mir_tstrdup(path); max_pos = SendMessage(list,LB_ADDSTRING, 0, (LPARAM)date); SendMessage(list, LB_SETITEMDATA, max_pos, (LPARAM)le); } SendMessage(list, LB_SETCURSEL, max_pos, 0); // Set to first item return 0; }
TCHAR* GetContactUID(MCONTACT hContact) { char *szProto = GetContactProto(hContact); char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if (INT_PTR(uid) == CALLSERVICE_NOTFOUND || uid == 0) return NULL; DBVARIANT vrUid; if (db_get_s(hContact, szProto, uid, &vrUid, 0)) return NULL; if (vrUid.type == DBVT_DWORD) { TCHAR tmp[100]; _itot(vrUid.dVal, tmp, 10); return mir_tstrdup(tmp); } if (vrUid.type == DBVT_ASCIIZ) { TCHAR *res = mir_a2t(vrUid.pszVal); mir_free(vrUid.pszVal); return res; } if (vrUid.type == DBVT_UTF8) { TCHAR *res = mir_utf8decodeT(vrUid.pszVal); mir_free(vrUid.pszVal); return res; } return NULL; }
INT_PTR CSametimeProto::onMenuCreateChat(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)wParam; debugLog(_T("CSametimeProto::onMenuCreateChat() hContact=[%x]"), hContact); mwAwareIdBlock id_block; mwIdBlock idb; if (my_login_info && GetAwareIdFromContact(hContact, &id_block)) { TCHAR title[512]; TCHAR* ts = mir_utf8decodeT(my_login_info->user_name); mir_sntprintf(title, SIZEOF(title), TranslateT("%s's conference"), ts); mir_free(ts); idb.user = id_block.user; idb.community = id_block.community; invite_queue.push(idb.user); if (!my_conference) { debugLog(_T("CSametimeProto::onMenuCreateChat() mwConference_open")); char* utfs; my_conference = mwConference_new(service_conference, utfs = mir_utf8encodeT(title)); mwConference_open(my_conference); mir_free(utfs); } else { debugLog(_T("CSametimeProto::onMenuCreateChat() ClearInviteQueue")); ClearInviteQueue(); } free(id_block.user); } return 0; }
/** * name: AddDummyItem * class: CPsTree * desc: insert an empty tree item group * param: pszGroup - utf8 encoded string of the item to add * return: index of the new item or -1 if failed to add **/ INT CPsTree::AddDummyItem(LPCSTR pszGroup) { if (mir_stricmp(pszGroup, TREE_ROOTITEM)) { CPsHdr psh; OPTIONSDIALOGPAGE odp; INT rc; psh._hContact = _pPs->hContact; psh._pszProto = _pPs->pszProto; psh._hImages = _hImages; psh._pPages = _pItems; psh._numPages = _numItems; ZeroMemory(&odp, sizeof(odp)); odp.cbSize = sizeof(odp); odp.hInstance = ghInst; odp.flags = ODPF_TCHAR; odp.ptszTitle = mir_utf8decodeT(pszGroup); rc = CallService(MS_USERINFO_ADDPAGE, (WPARAM)&psh, (LPARAM)&odp); mir_free(odp.ptszTitle); if (!rc) { _pItems = psh._pPages; _numItems = psh._numPages; return _numItems - 1; } } return -1; }
int CMraProto::SendMsg(MCONTACT hContact, int, const char *lpszMessage) { if (!m_bLoggedIn) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline."); return 0; } DWORD dwFlags = 0; CMStringW wszMessage(ptrW(mir_utf8decodeT(lpszMessage))); if (wszMessage.IsEmpty()) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"Cant allocate buffer for convert to unicode."); return 0; } CMStringA szEmail; if (!mraGetStringA(hContact, "e-mail", szEmail)) return 0; BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND); if (getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE) && (MraContactCapabilitiesGet(hContact) & FEATURE_FLAG_RTF_MESSAGE)) dwFlags |= MESSAGE_FLAG_RTF; int iRet = MraMessage(bSlowSend, hContact, ACKTYPE_MESSAGE, dwFlags, szEmail, wszMessage, NULL, 0); if (bSlowSend == FALSE) ProtoBroadcastAckAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)iRet, 0); return iRet; }
/** * name: ItemLabel * class: CPsTreeItem * desc: returns the label for a given item. The returned value must be freed after use! * param: pszName - uniquely identifiing string for a propertypage encoded with utf8 (e.g.: {group\item}) * return: Label in a newly allocated piece of memory **/ int CPsTreeItem::ItemLabel(const BYTE bReadDBValue) { DBVARIANT dbv; // clear existing if (_ptszLabel) mir_free(_ptszLabel); // try to get custom label from database if (!bReadDBValue || DB::Setting::GetTString(NULL, MODNAME, GlobalPropertyKey(SET_ITEM_LABEL), &dbv) || (_ptszLabel = dbv.ptszVal) == NULL) { // extract the name LPSTR pszName = mir_strrchr(_pszName, '\\'); if (pszName && pszName[1]) pszName++; else pszName = _pszName; LPTSTR ptszLabel = mir_utf8decodeT(pszName); if (ptszLabel) { _ptszLabel = mir_tstrdup(TranslateTS(ptszLabel)); mir_free(ptszLabel); } } // return nonezero if label is invalid return _ptszLabel == NULL; }
void FacebookProto::OpenUrl(std::string url) { std::string::size_type pos = url.find(FACEBOOK_SERVER_DOMAIN); bool isFacebookUrl = (pos != std::string::npos); bool isRelativeUrl = (url.substr(0, 4) != "http"); if (isFacebookUrl || isRelativeUrl) { // Make realtive url if (!isRelativeUrl) { url = url.substr(pos + strlen(FACEBOOK_SERVER_DOMAIN)); // Strip eventual port pos = url.find("/"); if (pos != std::string::npos && pos != 0) url = url.substr(pos); } // Make absolute url bool useHttps = getByte(FACEBOOK_KEY_FORCE_HTTPS, 1) > 0; url = (useHttps ? HTTP_PROTO_SECURE : HTTP_PROTO_REGULAR) + facy.get_server_type() + url; } ptrT data( mir_utf8decodeT(url.c_str())); // Check if there is user defined browser for opening links ptrT browser(getTStringA(FACEBOOK_KEY_OPEN_URL_BROWSER)); if (browser != NULL) // If so, use it to open this link ForkThread(&FacebookProto::OpenUrlThread, new open_url(browser, data)); else // Or use Miranda's service CallService(MS_UTILS_OPENURL, (WPARAM)OUF_TCHAR, (LPARAM)data); }
void CToxProto::LoadChatRoomList(void*) { uint32_t count = tox_count_chatlist(toxThread->Tox()); if (count == 0) { debugLogA(__FUNCTION__": your group chat list is empty"); return; } int32_t *groupChats = (int32_t*)mir_alloc(count * sizeof(int32_t)); tox_get_chatlist(toxThread->Tox(), groupChats, count); for (uint32_t i = 0; i < count; i++) { int32_t groupNumber = groupChats[i]; int type = tox_group_get_type(toxThread->Tox(), groupNumber); if (type == TOX_GROUPCHAT_TYPE_AV) { continue; } MCONTACT hContact = AddChatRoom(groupNumber); if (hContact) { uint8_t title[TOX_MAX_NAME_LENGTH] = { 0 }; tox_group_get_title(toxThread->Tox(), groupNumber, title, TOX_MAX_NAME_LENGTH); setWString(hContact, "Nick", ptrT(mir_utf8decodeT((char*)title))); } } mir_free(groupChats); }
void CDropbox::SendToContact(MCONTACT hContact, const char* data) { if (hContact == GetDefaultContact()) { char *message = mir_utf8encode(data); AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF, mir_strlen(message), (PBYTE)message); return; } const char *szProto = GetContactProto(hContact); if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) { ptrT tszChatRoom(db_get_tsa(hContact, szProto, "ChatRoomID")); GCDEST gcd = { szProto, tszChatRoom, GC_EVENT_SENDMESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.bIsMe = TRUE; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszText = mir_utf8decodeT(data); gce.time = time(NULL); CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce); mir_free((void*)gce.ptszText); return; } if (CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)data) != ACKRESULT_FAILED) { char *message = mir_utf8encode(data); AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, mir_strlen(message), (PBYTE)message); } }
void CSkypeProto::AddMessageToChat(const TCHAR *chat_id, const TCHAR *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading) { GCDEST gcd = { m_szModuleName, chat_id, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(GCEVENT), &gcd }; gce.bIsMe = IsMe(_T2A(from)); gce.ptszNick = from; gce.time = timestamp; gce.ptszUID = from; ptrA szHtml(RemoveHtml(content)); ptrT tszHtml(mir_utf8decodeT(szHtml)); if (!isAction) { gce.ptszText = tszHtml; gce.dwFlags = GCEF_ADDTOLOG; } else { gce.ptszText = &tszHtml[emoteOffset]; } if (isLoading) gce.dwFlags = GCEF_NOTNOTIFY; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); }
/** * name: AddDummyItem * class: CPsTree * desc: insert an empty tree item group * param: pszGroup - utf8 encoded string of the item to add * return: index of the new item or -1 if failed to add **/ int CPsTree::AddDummyItem(LPCSTR pszGroup) { if (mir_stricmp(pszGroup, TREE_ROOTITEM)) { CPsHdr psh; psh._hContact = _pPs->hContact; psh._pszProto = _pPs->pszProto; psh._hImages = _hImages; psh._pPages = _pItems; psh._numPages = _numItems; OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.hInstance = ghInst; odp.flags = ODPF_TCHAR; odp.ptszTitle = mir_utf8decodeT(pszGroup); INT_PTR rc = UserInfo_AddPage((WPARAM)&psh, &odp); mir_free(odp.ptszTitle); if (!rc) { _pItems = psh._pPages; _numItems = psh._numPages; return _numItems - 1; } } return -1; }
void __cdecl SessionAdmin(struct mwSession* session, const char* text) { CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); proto->debugLog(_T("SessionAdmin()")); TCHAR* tt = mir_utf8decodeT(text); MessageBox(0, tt, TranslateT("Sametime administrator message"), MB_OK); mir_free(tt); }
static int core_ReplaceVariables(lua_State *L) { char *what = (char*)luaL_checkstring(L, 1); ptrT value(mir_utf8decodeT(what)); lua_pushstring(L, T2Utf(VARST(value))); return 1; }
static int core_Translate(lua_State *L) { char *what = (char*)luaL_checkstring(L, 1); ptrT value(mir_utf8decodeT(what)); lua_pushstring(L, T2Utf(TranslateW_LP(value, hLangpack))); return 1; }
void CDropbox::RequestAccountInfo() { MCONTACT hContact = CDropbox::GetDefaultContact(); ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); GetAccountInfoRequest request(token); NLHR_PTR response(request.Send(hNetlibConnection)); HandleHttpResponseError(response); JSONNode root = JSONNode::parse(response->pData); if (root.empty()) return; JSONNode referral_link = root.at("referral_link"); if (!referral_link.empty()) db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str()); JSONNode display_name = root.at("display_name"); if (!display_name.empty()) { ptrT display_name(mir_utf8decodeT(display_name.as_string().c_str())); TCHAR *sep = _tcsrchr(display_name, _T(' ')); if (sep) { db_set_ts(hContact, MODULE, "LastName", sep + 1); display_name[mir_tstrlen(display_name) - mir_tstrlen(sep)] = '\0'; db_set_ts(hContact, MODULE, "FirstName", display_name); } else { db_set_ts(hContact, MODULE, "FirstName", display_name); db_unset(hContact, MODULE, "LastName"); } } JSONNode country = root.at("country"); if (!country.empty()) { std::string isocode = country.as_string(); if (isocode.empty()) db_unset(hContact, MODULE, "Country"); else { char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0); db_set_s(hContact, MODULE, "Country", country); } } JSONNode quota_info = root.at("quota_info"); if (!quota_info.empty()) { db_set_dw(hContact, MODULE, "SharedQuota", quota_info.at("shared").as_int()); db_set_dw(hContact, MODULE, "NormalQuota", quota_info.at("normal").as_int()); db_set_dw(hContact, MODULE, "TotalQuota", quota_info.at("quota").as_int()); } }
static int lua_PlayFile(lua_State *L) { ptrT filePath(mir_utf8decodeT(luaL_checkstring(L, 1))); INT_PTR res = ::SkinPlaySoundFile(filePath); lua_pushboolean(L, res == 0); return 1; }
void MakeMenuItem(lua_State *L, CMenuItem &mi) { mi.hLangpack = hScriptsLangpack; lua_pushliteral(L, "Flags"); lua_gettable(L, -2); mi.flags = lua_tointeger(L, -1); lua_pop(L, 1); if (!(mi.flags & CMIF_TCHAR)) mi.flags |= CMIF_TCHAR; lua_pushliteral(L, "Uid"); lua_gettable(L, -2); const char* uuid = (char*)lua_tostring(L, -1); if (CLSIDFromString((LPCOLESTR)ptrT(mir_utf8decodeT(uuid)), (LPCLSID)&mi.uid) != NOERROR) UNSET_UID(mi); lua_pop(L, 1); lua_pushliteral(L, "Name"); lua_gettable(L, -2); mi.name.t = mir_utf8decodeT((char*)luaL_checkstring(L, -1)); lua_pop(L, 1); lua_pushliteral(L, "Position"); lua_gettable(L, -2); mi.position = lua_tointeger(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Icon"); lua_gettable(L, -2); mi.hIcolibItem = (HANDLE)lua_touserdata(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Service"); lua_gettable(L, -2); mi.pszService = (char*)lua_tostring(L, -1); lua_pop(L, 1); lua_pushliteral(L, "Parent"); lua_gettable(L, -2); mi.root = (HGENMENU)lua_touserdata(L, -1); lua_pop(L, 1); }