/** * update all or only the given status message information from the database * * @param szKey: char* database key name or 0 to reload all messages */ void CContactCache::updateStatusMsg(const char *szKey) { if (!m_Valid) return; MCONTACT hContact = getActiveContact(); if (szKey == 0 || (szKey && !mir_strcmp("StatusMsg", szKey))) { if (m_szStatusMsg) mir_free(m_szStatusMsg); m_szStatusMsg = 0; ptrT szStatus(db_get_tsa(hContact, "CList", "StatusMsg")); if (szStatus != 0) m_szStatusMsg = (mir_tstrlen(szStatus) > 0 ? getNormalizedStatusMsg(szStatus) : 0); } if (szKey == 0 || (szKey && !mir_strcmp("ListeningTo", szKey))) { if (m_ListeningInfo) mir_free(m_ListeningInfo); m_ListeningInfo = 0; ptrT szListeningTo(db_get_tsa(hContact, cc->szProto, "ListeningTo")); if (szListeningTo != 0 && *szListeningTo) m_ListeningInfo = szListeningTo.detach(); } if (szKey == 0 || (szKey && !mir_strcmp("XStatusMsg", szKey))) { if (m_xStatusMsg) mir_free(m_xStatusMsg); m_xStatusMsg = 0; ptrT szXStatusMsg(db_get_tsa(hContact, cc->szProto, "XStatusMsg")); if (szXStatusMsg != 0 && *szXStatusMsg) m_xStatusMsg = szXStatusMsg.detach(); } m_xStatus = db_get_b(hContact, cc->szProto, "XStatusId", 0); }
void UpdateList(HWND hwndList) { LVITEM lvI = { 0 }; // Some code to create the list-view control. // Initialize LVITEM members that are common to all // items. int i = 0; for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { UpdateListFlag = TRUE; lvI.mask = LVIF_TEXT; lvI.iSubItem = 0; TCHAR *ptszNick = db_get_tsa(hContact, MODULE, "Nick"); if (ptszNick) { lvI.pszText = ptszNick; lvI.iItem = i; ListView_InsertItem(hwndList, &lvI); lvI.iSubItem = 1; TCHAR *ptszURL = db_get_tsa(hContact, MODULE, "URL"); if (ptszURL) { lvI.pszText = ptszURL; ListView_SetItem(hwndList, &lvI); i++; ListView_SetCheckState(hwndList, lvI.iItem, db_get_b(hContact, MODULE, "CheckState", 1)); mir_free(ptszURL); } mir_free(ptszNick); } } UpdateListFlag = FALSE; }
void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, HANDLE hContact) { if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) return; ptrT jid(getTStringA(hContact, "jid")); if (jid == NULL) return; debugLogA("Add %S permanently to list", jid); ptrT nick(db_get_tsa(hContact, "CList", "MyHandle")); if (nick == NULL) nick = getTStringA(hContact, "Nick"); if (nick == NULL) nick = JabberNickFromJID(jid); if (nick == NULL) return; AddContactToRoster(jid, nick, ptrT(db_get_tsa(hContact, "CList", "Group"))); XmlNode xPresence(_T("presence")); xPresence << XATTR(_T("to"), LPCTSTR(jid)) << XATTR(_T("type"), _T("subscribe")); ptrT myNick(getTStringA(NULL, "Nick")); if (myNick != NULL) xPresence << XCHILD(_T("nick"), LPCTSTR(myNick)) << XATTR(_T("xmlns"), JABBER_FEAT_NICK); m_ThreadInfo->send(xPresence); SendGetVcard(jid); db_unset(hContact, "CList", "Hidden"); }
int SiteDeleted(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; if (mir_strcmp(GetContactProto(hContact), MODULENAME)) return 0; ptrT contactName( db_get_tsa(hContact, MODULENAME, PRESERVE_NAME_KEY)); // TEST GET NAME FOR CACHE TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50]; GetModuleFileName(hInst, cachepath, _countof(cachepath)); TCHAR *cacheend = _tcsrchr(cachepath, '\\'); cacheend++; *cacheend = '\0'; mir_sntprintf(cachedirectorypath, _T("%s")_T(MODULENAME)_T("cache\\"), cachepath); CreateDirectory(cachedirectorypath, NULL); mir_sntprintf(newcachepath, _T("%s")_T(MODULENAME)_T("cache\\%s.txt"), cachepath, contactName); // file exists? if ( _taccess(newcachepath, 0) != -1) { FILE *pcachefile = _tfopen(newcachepath, _T("r")); if (pcachefile != NULL) { fclose(pcachefile); DeleteFile(newcachepath); db_set_s(hContact, MODULENAME, CACHE_FILE_KEY, ""); } } return 0; }
INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM) { if (!hContact) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrT roomID(getTStringA(hContact, "ChatRoomID")); if (roomID == NULL) return 0; if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) { ptrT group(db_get_tsa(hContact, "CList", "Group")); ptrT nick(getTStringA(hContact, "Nick")); AddContactToRoster(roomID, nick, group); if (m_options.AddRoster2Bookmarks == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID); if (item == NULL) { item = new JABBER_LIST_ITEM(); item->jid = mir_tstrdup(roomID); item->name = mir_tstrdup(nick); item->nick = getTStringA(hContact, "MyNick"); AddEditBookmark(item); delete item; } } } return 0; }
int DeleteAutoSession(int ses_count) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { RemoveSessionMark(hContact, 0, ses_count); SetInSessionOrder(hContact, 0, ses_count, 0); } char szSessionName[256]; mir_snprintf(szSessionName, "%s_%u", "SessionDate", ses_count); db_unset(NULL, MODNAME, szSessionName); for (int i = ses_count + 1;; i++) { mir_snprintf(szSessionName, "%s_%u", "SessionDate", i); ptrT szSessionNameBuf(db_get_tsa(NULL, MODNAME, szSessionName)); mir_snprintf(szSessionName, "%s_%u", "SessionDate", i - 1); if (szSessionNameBuf) db_set_ts(NULL, MODNAME, szSessionName, szSessionNameBuf); else { db_unset(NULL, MODNAME, szSessionName); break; } } return 0; }
int DelUserDefSession(int ses_count) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { RemoveSessionMark(hContact, 1, ses_count); SetInSessionOrder(hContact, 1, ses_count, 0); } char szSessionName[256]; mir_snprintf(szSessionName, "%s_%u", "UserSessionDsc", ses_count); db_unset(NULL, MODNAME, szSessionName); mir_snprintf(szSessionName, "%s_%u", "FavUserSession", ses_count); db_unset(NULL, MODNAME, szSessionName); for (int i = ses_count + 1;; i++) { mir_snprintf(szSessionName, "%s_%u", "UserSessionDsc", i); ptrT szSessionNameBuf(db_get_tsa(NULL, MODNAME, szSessionName)); mir_snprintf(szSessionName, "%s_%u", "UserSessionDsc", i - 1); if (szSessionNameBuf) { MarkUserDefSession(i - 1, IsMarkedUserDefSession(i)); db_set_ts(NULL, MODNAME, szSessionName, szSessionNameBuf); } else { db_unset(NULL, MODNAME, szSessionName); mir_snprintf(szSessionName, "%s_%u", "FavUserSession", i - 1); db_unset(NULL, MODNAME, szSessionName); break; } } g_ses_count--; db_set_b(0, MODNAME, "UserSessionsCount", (BYTE)g_ses_count); return 0; }
int SaveSessionDate() { if (session_list[0] != 0) { int TimeSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, NULL, 0); TCHAR *szTimeBuf = (TCHAR*)mir_alloc((TimeSize + 1)*sizeof(TCHAR)); GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, szTimeBuf, TimeSize); int DateSize = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, NULL, 0); TCHAR *szDateBuf = (TCHAR*)mir_alloc((DateSize + 1)*sizeof(TCHAR)); GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szDateBuf, DateSize); int lenn = (DateSize + TimeSize + 5); TCHAR *szSessionTime = (TCHAR*)mir_alloc(lenn*sizeof(TCHAR)); mir_sntprintf(szSessionTime, lenn, _T("%s - %s"), szTimeBuf, szDateBuf); char szSetting[256]; mir_snprintf(szSetting, "%s_%d", "SessionDate", 0); TCHAR *ptszSaveSessionDate = db_get_tsa(NULL, MODNAME, szSetting); db_set_ts(NULL, MODNAME, szSetting, szSessionTime); mir_free(szSessionTime); if (ptszSaveSessionDate) ResaveSettings("SessionDate", 1, g_ses_limit, ptszSaveSessionDate); if (szTimeBuf) mir_free(szTimeBuf); if (szDateBuf) mir_free(szDateBuf); } if (g_bCrashRecovery) db_set_b(NULL, MODNAME, "lastSaveCompleted", 1); return 0; }
static int AwayMsgHook(WPARAM wParam, LPARAM lParam, LPARAM pObj) { PLUGINDATA *pdp = (PLUGINDATA*)pObj; if (pdp == NULL) return 0; ACKDATA *ack = (ACKDATA *)lParam; if (ack->type != ACKTYPE_AWAYMSG || ack->hProcess != pdp->hAwayMsgProcess) return 0; //The first thing we go is removing the hook from the chain to avoid useless calls. UnhookEvent(pdp->hAwayMsgHook); pdp->hAwayMsgHook = NULL; if (ack->result != ACKRESULT_SUCCESS) return 0; MCONTACT hContact = PUGetContact(pdp->hWnd); ptrT pstzLast( db_get_tsa(hContact, MODULE, "LastPopupText")); TCHAR *tszStatus = (TCHAR*)ack->lParam; if (tszStatus == NULL || *tszStatus == 0) return 0; TCHAR stzText[1024]; if (pstzLast) mir_sntprintf(stzText, SIZEOF(stzText), _T("%s\n%s"), pstzLast, tszStatus); else _tcsncpy(stzText, tszStatus, SIZEOF(stzText)); SendMessage(pdp->hWnd, WM_SETREDRAW, FALSE, 0); PUChangeTextT(pdp->hWnd, stzText); SendMessage(pdp->hWnd, WM_SETREDRAW, TRUE, 0); return 0; }
static int ProcessChatEvent(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; if (gce == NULL || gce->pDest == NULL) return 0; GCDEST *gcd = (GCDEST*)gce->pDest; if (gcd->iType != GC_EVENT_MESSAGE) return 0; MCONTACT hContact = pci->FindRoom(gcd->pszModule, gcd->ptszID); if (hContact != 0) { ptrT nick(db_get_tsa(hContact, gcd->pszModule, "MyNick")); if (nick == NULL || gce->ptszText == NULL) return 0; if (_tcsstr(gce->ptszText, nick)) { isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0); DBVARIANT dbv; if (!isIgnoreSound && !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) { TCHAR PlaySoundPath[MAX_PATH] = { 0 }; PathToAbsoluteT(dbv.ptszVal, PlaySoundPath); isOwnSound = 0; SkinPlaySoundFile(PlaySoundPath); db_free(&dbv); isOwnSound = 1; } } } return 0; }
BOOL ResaveSettings(char *szName, int iFirst, int iLimit, TCHAR *szBuffer) { for (int i = iFirst; i < iLimit; i++) { if (szBuffer == NULL) break; char szNameBuf[256]; mir_snprintf(szNameBuf, "%s_%u", szName, i); TCHAR *ptszTemp = db_get_tsa(NULL, MODNAME, szNameBuf); db_set_ts(NULL, MODNAME, szNameBuf, szBuffer); mir_free(szBuffer); BYTE marked = IsMarkedUserDefSession(i); MarkUserDefSession(i, (BYTE)((i == iFirst) ? IsMarkedUserDefSession(iFirst - 1) : marked)); if (ptszTemp == NULL) // read failed return 0; szBuffer = ptszTemp; } mir_free(szBuffer); return 1; }
INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM) { FILE *pfile = fopen("psite.bat", "r"); if (pfile == NULL) { WErrorPopup((UINT_PTR)"ERROR", TranslateT("Missing \"psite.bat\" file.")); return 0; } ptrT url( db_get_tsa(wParam, MODULENAME, "URL")); if (url == NULL) return 0; TCHAR Cnick[200], *Oldnick; _tcsncpy(Cnick, url, _countof(Cnick)); if ((Oldnick = _tcsstr(Cnick, _T("://"))) != 0) Oldnick += 3; else Oldnick = Cnick; TCHAR *Nend = _tcschr(Oldnick, '/'); if (Nend) *Nend = '\0'; ShellExecute(NULL, _T("open"), _T("psite.bat"), Oldnick, NULL, SW_HIDE); return 0; }
int LoadSessionToCombobox(HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum) { int ses_count = iFirstNum, index; char szBuffer[256]={0}; if (session_list_recovered[0] && !iFirstNum && !mode) { index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)TranslateT("Session Before Last Crash")); SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, index, 256); } for(int i=0; i < iLimit; i++) { mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s_%u", pszSetting, i); TCHAR *pszBuffer = db_get_tsa(NULL, MODNAME, szBuffer); if (pszBuffer) { if (!IsMarkedUserDefSession(i+iFirstNum)||mode == 1) { index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)pszBuffer); SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, i+iFirstNum); } else { SendDlgItemMessage(hdlg, IDC_LIST, CB_INSERTSTRING, 0, (LPARAM)pszBuffer); SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, i+iFirstNum); } mir_free(pszBuffer); } else { if (i == 0) ses_count=iLimit-iFirstNum; break; } } return ses_count; }
void CreateAuthString(char *auth, MCONTACT hContact, HWND hwndDlg) { DBVARIANT dbv; char *user = NULL, *pass = NULL; TCHAR *tlogin = NULL, *tpass = NULL, buf[MAX_PATH] = {0}; if (hContact && db_get_b(hContact, MODULE, "UseAuth", 0)) { if (!db_get_ts(hContact, MODULE, "Login", &dbv)) { tlogin = mir_tstrdup(dbv.ptszVal); db_free(&dbv); } tpass = db_get_tsa(hContact, MODULE, "Password"); } else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) { GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf)); tlogin = mir_tstrdup(buf); GetDlgItemText(hwndDlg, IDC_PASSWORD, buf, SIZEOF(buf)); tpass = mir_tstrdup(buf); } user = mir_t2a(tlogin); pass = mir_t2a(tpass); char str[MAX_PATH]; int len = mir_snprintf(str, SIZEOF(str), "%s:%s", user, pass); mir_free(user); mir_free(pass); mir_free(tlogin); mir_free(tpass); mir_snprintf(auth, 250, "Basic %s", ptrA(mir_base64_encode((PBYTE)str, len))); }
MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags) { const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags); if (lstMsg == NULL) return -1; if (szModule == NULL) szModule = "UserInfo"; int iSelection = 0; ptrT tszName(db_get_tsa(hContact, szModule, "TzName")); if (tszName != NULL) { unsigned hash = mir_hashstrT(tszName); for (int i = 0; i < g_timezonesBias.getCount(); i++) { if (hash == g_timezonesBias[i]->hash) { iSelection = i + 1; break; } } } else { signed char cBias = db_get_b(hContact, szModule, "Timezone", -100); if (cBias != -100) { int iBias = cBias * 30; for (int i = 0; i < g_timezonesBias.getCount(); i++) { if (iBias == g_timezonesBias[i]->tzi.Bias) { iSelection = i + 1; break; } } } } SendMessage(hWnd, lstMsg->setSel, iSelection, 0); return iSelection; }
void CDropbox::SendToContact(MCONTACT hContact, const TCHAR *data) { if (hContact == GetDefaultContact()) { char *message = mir_utf8encodeT(data); AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF, (DWORD)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_tstrdup(data); gce.time = time(NULL); CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce); mir_free((void*)gce.ptszText); return; } char *message = mir_utf8encodeT(data); if (CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)message) != ACKRESULT_FAILED) AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, (DWORD)mir_strlen(message), (PBYTE)message); }
void CVkProto::OnReceiveStatusMsg(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveStatusMsg %d", reply->resultCode); if (reply->resultCode != 200) return; OnReceiveStatus(reply, pReq); ptrT ptszOldStatusMsg(db_get_tsa(NULL, m_szModuleName, "OldStatusMsg")); CMString tszOldStatusMsg(ptszOldStatusMsg); ENTER_STRING pForm = { sizeof(pForm) }; pForm.type = ESF_MULTILINE; pForm.caption = TranslateT("Enter new status message"); pForm.ptszInitVal = ptszOldStatusMsg; pForm.szModuleName = m_szModuleName; pForm.szDataPrefix = "statusmsgform_"; if (!EnterString(&pForm)) return; CMString tszNewStatusMsg(ptrT(pForm.ptszResult)); if (tszOldStatusMsg == tszNewStatusMsg) return; RetrieveStatusMsg(tszNewStatusMsg); setTString("OldStatusMsg", ptszOldStatusMsg); }
int DeleteAutoSession(int ses_count) { int i=0; HANDLE hContact; char szSessionName[256]={0}; TCHAR *szSessionNameBuf=NULL; for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { RemoveSessionMark(hContact,0,ses_count); SetInSessionOrder(hContact,0,ses_count,0); } mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", ses_count); db_unset(NULL, MODNAME, szSessionName); for (i=(ses_count+1);;i++) { mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i); if (szSessionNameBuf = db_get_tsa(NULL, MODNAME, szSessionName)) { mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i-1); db_set_ts(NULL, MODNAME, szSessionName, szSessionNameBuf); mir_free(szSessionNameBuf); } else { mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i-1); db_unset(NULL, MODNAME, szSessionName); break; } } return 0; }
int CreateGroup(const TCHAR *group, MCONTACT hContact) { if (group == NULL) return 0; size_t cbName = mir_tstrlen(group); TCHAR *tszGrpName = (TCHAR*)_alloca((cbName + 2)*sizeof(TCHAR)); tszGrpName[0] = 1 | GROUPF_EXPANDED; mir_tstrcpy(tszGrpName + 1, group); // Check for duplicate & find unused id char groupIdStr[11]; for (int groupId = 0;; groupId++) { itoa(groupId, groupIdStr, 10); ptrT tszDbGroup(db_get_tsa(NULL, "CListGroups", groupIdStr)); if (tszDbGroup == NULL) break; if (!mir_tstrcmp((TCHAR*)tszDbGroup+1, tszGrpName+1)) { if (hContact) db_set_ts(hContact, "CList", "Group", tszGrpName + 1); else AddMessage(LPGENT("Skipping duplicate group %s."), tszGrpName + 1); return 0; } } db_set_ts(NULL, "CListGroups", groupIdStr, tszGrpName); if (hContact) db_set_ts(hContact, "CList", "Group", tszGrpName + 1); return 1; }
void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, HANDLE hContact) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrT(getTStringA(hContact, "jid"))); if (item == NULL) return; ptrT tszNick(db_get_tsa(hContact, "CList", "MyHandle")); if (tszNick == NULL) tszNick = getTStringA(hContact, "Nick"); if (tszNick == NULL) tszNick = JabberNickFromJID(item->jid); if (tszNick == NULL) return; if (cws->value.type == DBVT_DELETED) { if (item->group != NULL) { debugLogA("Group set to nothing"); AddContactToRoster(item->jid, tszNick, NULL); } } else { TCHAR *p = sttSettingToTchar(cws); if (cws->value.pszVal != NULL && lstrcmp(p, item->group)) { debugLogA("Group set to %S", p); if (p) AddContactToRoster(item->jid, tszNick, p); } mir_free(p); } }
static void OpenURLThread(void *arg) { TOpenUrlInfo *hUrlInfo = (TOpenUrlInfo*)arg; // wack a protocol on it CMString tszUrl; if ((isalpha(hUrlInfo->szUrl[0]) && hUrlInfo->szUrl[1] == ':') || hUrlInfo->szUrl[0] == '\\') tszUrl.Format(_T("file:///%s"), hUrlInfo->szUrl); else { int i; for (i = 0; _istalpha(hUrlInfo->szUrl[i]); i++); if (hUrlInfo->szUrl[i] == ':') tszUrl = hUrlInfo->szUrl; else if (!_tcsnicmp(hUrlInfo->szUrl, _T("ftp."), 4)) tszUrl.Format(_T("ftp://%s"), hUrlInfo->szUrl); else tszUrl.Format(_T("http://%s"), hUrlInfo->szUrl); } // check user defined browser for opening urls ptrT tszBrowser(db_get_tsa(NULL, "Miranda", "OpenUrlBrowser")); if (tszBrowser) ShellExecute(NULL, _T("open"), tszBrowser, tszUrl, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT); else ShellExecute(NULL, _T("open"), tszUrl, NULL, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT); delete hUrlInfo; }
void ProtocolArray::GetDefaultAvatar() { ptrT tszFile(db_get_tsa(0, "ContactPhoto", "File")); if (tszFile) mir_tstrncpy(default_avatar_file, tszFile, _countof(default_avatar_file)); else default_avatar_file[0] = '\0'; }
void ProtocolArray::GetDefaultNick() { ptrT tszNick(db_get_tsa(0, MODULE_NAME, SETTING_DEFAULT_NICK)); if (tszNick) _tcsncpy_s(default_nick, SIZEOF(default_nick), tszNick, _TRUNCATE); else default_nick[0] = '\0'; }
void ProtocolArray::GetDefaultAvatar() { ptrT tszFile(db_get_tsa(0, "ContactPhoto", "File")); if (tszFile) _tcsncpy_s(default_avatar_file, SIZEOF(default_avatar_file), tszFile, _TRUNCATE); else default_avatar_file[0] = '\0'; }
void ProtocolArray::GetDefaultNick() { ptrT tszNick(db_get_tsa(0, MODULE_NAME, SETTING_DEFAULT_NICK)); if (tszNick) mir_tstrncpy(default_nick, tszNick, _countof(default_nick)); else default_nick[0] = '\0'; }
INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM) { debugLogA("CVkProto::SvcBanUser"); LONG userID = getDword(hContact, "ID", -1); if (!IsOnline() || userID == -1 || userID == VK_FEED_USER) return 1; CMStringA code(FORMAT, "var userID=\"%d\";API.account.banUser({\"user_id\":userID});", userID); CMString tszVarWarning; if (m_bReportAbuse) { debugLogA("CVkProto::SvcBanUser m_bReportAbuse = true"); code += "API.users.report({\"user_id\":userID,type:\"spam\"});"; tszVarWarning = TranslateT(" report abuse on him/her"); } if (m_bClearServerHistory) { debugLogA("CVkProto::SvcBanUser m_bClearServerHistory = true"); code += "API.messages.deleteDialog({\"user_id\":userID,count:10000});"; if (!tszVarWarning.IsEmpty()) tszVarWarning.AppendChar(L','); tszVarWarning += TranslateT(" clear server history with him/her"); } if (m_bRemoveFromFrendlist) { debugLogA("CVkProto::SvcBanUser m_bRemoveFromFrendlist = true"); code += "API.friends.delete({\"user_id\":userID});"; if (!tszVarWarning.IsEmpty()) tszVarWarning.AppendChar(L','); tszVarWarning += TranslateT(" remove him/her from your friend list"); } if (m_bRemoveFromClist) { debugLogA("CVkProto::SvcBanUser m_bRemoveFromClist = true"); if (!tszVarWarning.IsEmpty()) tszVarWarning.AppendChar(L','); tszVarWarning += TranslateT(" remove him/her from your contact list"); } if (!tszVarWarning.IsEmpty()) tszVarWarning += ".\n"; code += "return 1;"; ptrT ptszNick(db_get_tsa(hContact, m_szModuleName, "Nick")); CMString ptszMsg(FORMAT, TranslateT("Are you sure to ban %s? %s%sContinue?"), IsEmpty(ptszNick) ? TranslateT("(Unknown contact)") : ptszNick, tszVarWarning.IsEmpty() ? _T(" ") : TranslateT("\nIt will also"), tszVarWarning.IsEmpty() ? _T("\n") : tszVarWarning); if (IDNO == MessageBox(NULL, ptszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO)) return 1; Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth) << CHAR_PARAM("code", code) << VER_API); if (m_bRemoveFromClist) CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact); return 0; }
INT CheckDefaults(WPARAM, LPARAM) { interval = db_get_w(NULL, protocolname, KEY_REPEATINTERVAL, 300); TCHAR *ptszVal = db_get_tsa(NULL, protocolname, KEY_HEADING); if (ptszVal == 0) // Heading not set db_set_ts(NULL, protocolname, KEY_HEADING, TranslateT("Dear %user%, the owner left the following message:")); else mir_free(ptszVal); for (int c = ID_STATUS_ONLINE; c < ID_STATUS_IDLE; c++) { if (c == ID_STATUS_ONLINE || c == ID_STATUS_FREECHAT || c == ID_STATUS_INVISIBLE) continue; else { char szStatus[6] = { 0 }; mir_snprintf(szStatus, "%d", c); ptszVal = db_get_tsa(NULL, protocolname, szStatus); if (ptszVal == 0) { TCHAR *ptszDefault; if (c < ID_STATUS_FREECHAT) // This mode does not have a preset message ptszDefault = ptszDefaultMsg[c - ID_STATUS_ONLINE - 1]; else if (c > ID_STATUS_INVISIBLE) ptszDefault = ptszDefaultMsg[c - ID_STATUS_ONLINE - 3]; else ptszDefault = 0; if (ptszDefault) db_set_ts(NULL, protocolname, szStatus, TranslateTS(ptszDefault)); } else mir_free(ptszVal); } } HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); if (ServiceExists(MS_VARS_FORMATSTRING)) gbVarsServiceExist = TRUE; BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1); if (fEnabled) Menu_ModifyItem(hEnableMenu, LPGENT("Disable Auto&reply"), iconList[0].hIcolib); else Menu_ModifyItem(hEnableMenu, LPGENT("Enable Auto&reply"), iconList[1].hIcolib); return 0; }
extern "C" MIR_CORE_DLL(void) db_setCurrent(MIDatabase *_db) { currDb = _db; // try to get the langpack's name from a profile ptrT langpack(db_get_tsa(NULL, "Langpack", "Current")); if (langpack && langpack[0] != '\0') LoadLangPack(langpack); }
void SetLabelProp(int index, LPSTR setting) { sprintf(setting, LABEL_SETTING_PROP, index); //!!!!!!!!!!!!!! ptrT tszProp( db_get_tsa(0, TIPPER_ITEMS_MOD_NAME, setting)); if (tszProp == NULL) return; ptrT tszLastWritten( db_get_tsa(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING)); if (tszLastWritten == NULL) return; if ( !lstrcmp(tszProp, tszLastWritten)) { LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL); db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label); db_set_ts(0, TIPPER_ITEMS_MOD_NAME, setting, label); } }
INT_PTR OpenSessionsManagerWindow(WPARAM wparam,LPARAM lparam) { if (g_hDlg) { ShowWindow(g_hDlg,SW_SHOW); return 0; } ptrT tszSession(db_get_tsa(NULL, MODNAME, "SessionDate_0")), tszUserSession(db_get_tsa(NULL, MODNAME, "UserSessionDsc_0")); if (g_bIncompletedSave || tszSession || tszUserSession) { g_hDlg = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc); return 0; } if (g_bOtherWarnings) MessageBox(NULL, TranslateT("No sessions to open"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING); return 1; }