MCONTACT CIrcProto::CList_AddContact(CONTACT *user, bool InList, bool SetOnline) { if (user->name == NULL) return 0; MCONTACT hContact = CList_FindContact(user); if (hContact) { if (InList) db_unset(hContact, "CList", "NotOnList"); setTString(hContact, "Nick", user->name); db_unset(hContact, "CList", "Hidden"); if (SetOnline && getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) setWord(hContact, "Status", ID_STATUS_ONLINE); return hContact; } // here we create a new one since no one is to be found hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); if (hContact) { CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName); if (InList) db_unset(hContact, "CList", "NotOnList"); else db_set_b(hContact, "CList", "NotOnList", 1); db_unset(hContact, "CList", "Hidden"); setTString(hContact, "Nick", user->name); setTString(hContact, "Default", user->name); setWord(hContact, "Status", SetOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE); if (!InList && getByte("MirVerAutoRequestTemp", 0)) PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), user->name); return hContact; } return false; }
void write_ping_address(PINGADDRESS &i) { char buff[16]; mir_snprintf(buff, "PING_DEST_%d", i.index); if (i.item_id == 0) { i.item_id = NextID++; db_set_dw(0, PLUG, "NextID", NextID); } db_set_dw(0, buff, "Id", i.item_id); db_set_ts(0, buff, "Address", i.pszName); db_set_ts(0, buff, "Label", i.pszLabel); db_set_w(0, buff, "Status", i.status); db_set_dw(0, buff, "Port", i.port); db_set_s(0, buff, "Proto", i.pszProto); if (mir_tstrlen(i.pszCommand)) db_set_ts(0, buff, "Command", i.pszCommand); else db_unset(0, buff, "Command"); if (mir_tstrlen(i.pszParams)) db_set_ts(0, buff, "CommandParams", i.pszParams); else db_unset(0, buff, "CommandParams"); db_set_w(0, buff, "SetStatus", i.set_status); db_set_w(0, buff, "GetStatus", i.get_status); db_set_w(0, buff, "Index", i.index); }
// MsnAddToList - adds contact to the server list MCONTACT CMsnProto::AddToListByEmail(const char *email, const char *nick, DWORD flags) { MCONTACT hContact = MSN_HContactFromEmail(email, nick, true, flags & PALF_TEMPORARY); if (flags & PALF_TEMPORARY) { if (db_get_b(hContact, "CList", "NotOnList", 0) == 1) db_set_b(hContact, "CList", "Hidden", 1); } else { db_unset(hContact, "CList", "Hidden"); if (msnLoggedIn) { int netId = strncmp(email, "tel:", 4) ? NETID_MSN : NETID_MOB; if (MSN_AddUser(hContact, email, netId, LIST_FL)) { MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE); MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE); MSN_AddUser(hContact, email, netId, LIST_AL); db_unset(hContact, "CList", "Hidden"); } MSN_SetContactDb(hContact, email); if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact); } else hContact = NULL; } return hContact; }
void TwitterProto::resetOAuthKeys() { db_unset(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK); db_unset(0,m_szModuleName,TWITTER_KEY_OAUTH_ACCESS_TOK_SECRET); db_unset(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK); db_unset(0,m_szModuleName,TWITTER_KEY_OAUTH_TOK_SECRET); db_unset(0,m_szModuleName,TWITTER_KEY_OAUTH_PIN); }
int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) { char *szSetting; ptrA myreplace; int count = 0; DBVARIANT dbv2; if (!dbv->type) return 0; if (mode & RW_FULL) szSetting = (char*)replace; else { myreplace = multiReplace(setting, find, replace, mode & RW_CASE); szSetting = myreplace; } if (szSetting[0] == 0) { ItemFound(hwnd, hContact, module, setting, NULL, FW_SETTINGNAME | FW_DELETED); db_unset(hContact, module, setting); return 1; } // check & write if (GetSetting(hContact, module, myreplace, &dbv2)) { if (!db_set(hContact, module, szSetting, &dbv2)) { count++; db_unset(hContact, module, setting); ItemFound(hwnd, hContact, module, szSetting, NULL, FW_SETTINGNAME | FW_REPLACED); } } else db_free(&dbv2); return count; }
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 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 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; }
/** * This method writes the combobox's item as the contact's timezone. * * @param hContact - HANDLE of the contact whose timezone to select * @param pszProto - the contact's protocol (not used by new core tz interface) * * @return nothing **/ void CTzCombo::OnApply(MCONTACT hContact, LPCSTR pszProto) { if (_Flags.B.hasChanged) { const char* pszModule = hContact ? USERINFO : pszProto; if (_Flags.B.hasCustom || !hContact) { //use new core tz interface TimeZone_StoreListResult(hContact, NULL, _hwnd, TZF_PLF_CB); if (!hContact) { _Flags.B.hasCustom = false; _Flags.B.hasProto = true; } _Flags.B.hasChanged = false; } if (_Flags.B.hasChanged) { db_unset(hContact, USERINFO, SET_CONTACT_TIMEZONENAME); db_unset(hContact, USERINFO, SET_CONTACT_TIMEZONEINDEX); db_unset(hContact, pszModule, SET_CONTACT_TIMEZONE); _Flags.B.hasChanged = false; OnInfoChanged(hContact, pszProto); } InvalidateRect(_hwnd, NULL, TRUE); } }
void logoff_contacts(BOOL bCleanup) { MCONTACT hContact; char *szProto; DBVARIANT dbv = { 0 }; LOG(("logoff_contacts: Logging off contacts.")); for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); if (szProto != NULL && !strcmp(szProto, SKYPE_PROTONAME)) { if (db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) db_set_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE); db_unset(hContact, SKYPE_PROTONAME, "CallId"); if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 1) { if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) continue; RemChat(dbv.ptszVal); db_free(&dbv); } if (db_get_s(hContact, SKYPE_PROTONAME, "Typing_Stream", &dbv) == 0) { if (bCleanup) SkypeSend("ALTER APPLICATION libpurple_typing DISCONNECT %s", dbv.pszVal); db_free(&dbv); db_unset(hContact, SKYPE_PROTONAME, "Typing_Stream"); } } } if (bCleanup && (protocol >= 5 || bIsImoproxy)) SkypeSend("DELETE APPLICATION libpurple_typing"); }
MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr) { ptrA id(mir_t2a_cp(psr->id.t, CP_UTF8)); ptrA name(mir_t2a_cp(psr->firstName.t, CP_UTF8)); ptrA surname(mir_t2a_cp(psr->lastName.t, CP_UTF8)); if (id == NULL) return NULL; facebook_user fbu; fbu.user_id = id; if (name != NULL) fbu.real_name = name; if (surname != NULL) { fbu.real_name += " "; fbu.real_name += surname; } if (fbu.user_id.find_first_not_of("0123456789") != std::string::npos) { MessageBox(0, TranslateT("Facebook ID must be numeric value."), m_tszUserName, MB_ICONERROR | MB_OK); return NULL; } bool add_temporarily = (flags & PALF_TEMPORARY); MCONTACT hContact = AddToContactList(&fbu, CONTACT_NONE, false, add_temporarily); // Reset NotOnList flag if present and we're adding this contact not temporarily if (hContact && !add_temporarily && db_get_b(hContact, "CList", "NotOnList", 0)) { db_unset(hContact, "CList", "Hidden"); db_unset(hContact, "CList", "NotOnList"); } return hContact; }
MCONTACT CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, bool make_permanent, bool make_visible, u_int status) { for (MCONTACT res = db_find_first(PROTONAME); res; res = db_find_next(res, PROTONAME)) { u_long caddr = db_get_dw(res, PROTONAME, "ipaddr", -1); if (caddr==addr.S_un.S_addr) { if (make_permanent) db_unset(res,"CList","NotOnList"); if (make_visible) db_unset(res,"CList","Hidden"); return res; } } if (add_to_list) { MCONTACT res=(MCONTACT)CallService(MS_DB_CONTACT_ADD,0,0); CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)res,(LPARAM)PROTONAME); db_set_dw(res,PROTONAME, "ipaddr", addr.S_un.S_addr); db_set_s(res,PROTONAME, "Nick", nick); if (!make_permanent) db_set_b(res,"CList","NotOnList",1); if (!make_visible) db_set_b(res,"CList","Hidden",1); db_set_w(res,PROTONAME, "Status", status); return res; } return NULL; }
void DeleteSettingEx(const char *szModule, const char *szSetting) { size_t lenModule; if (szModule == NULL) return; lenModule = mir_strlen(szModule); if (szModule[0] == '*' || szModule[lenModule-1] == '*') { DeleteModuleStruct dms; memset(&dms, 0, sizeof(dms)); dms.filter = szModule; dms.lenFilterMinusOne = lenModule-1; CallService(MS_DB_MODULES_ENUM, (WPARAM) &dms, (LPARAM) &ModuleEnumProc); // Delete then szModule = dms.buffer; while(szModule[0] != '\0') { DeleteSettingEx(szModule, szSetting); // Get next one szModule += mir_strlen(szModule) + 1; } } else { size_t lenSetting = szSetting == NULL ? 0 : mir_strlen(szSetting); if (szSetting == NULL || szSetting[0] == '*' || szSetting[lenSetting-1] == '*') { DeleteModuleStruct dms; DBCONTACTENUMSETTINGS dbces; memset(&dms, 0, sizeof(dms)); dms.filter = szSetting; dms.lenFilterMinusOne = lenSetting-1; dbces.pfnEnumProc = EnumProc; dbces.lParam = (LPARAM) &dms; dbces.szModule = szModule; dbces.ofsSettings = 0; CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM) &dbces); // Delete then szSetting = dms.buffer; while(szSetting[0] != '\0') { db_unset(NULL, szModule, szSetting); // Get next one szSetting += mir_strlen(szSetting) + 1; } } else { db_unset(NULL, szModule, szSetting); } } }
HANDLE AddToListByName(const CString& sName, WPARAM flags, LPCTSTR about, bool bInteractive, bool bGroup) { ip addr = INADDR_NONE; CString sShortName( sName ); if ( ! bGroup ) { // Попытка получить IP из имени if ( addr == INADDR_NONE ) addr = ResolveToIP( sShortName ); // Поиск NetBIOS-имени if ( addr == INADDR_NONE ) addr = pluginNetBIOS.FindNameIP( sName ); // Неизвестный контакт if ( addr == INADDR_NONE && bInteractive ) { if ( MessageBox( NULL, TranslateT("Cannot resolve contacts IP-address. Add it anyway?"), modname_t, MB_YESNO | MB_ICONQUESTION ) != IDYES ) { return NULL; } } } // Поиск существующего контакта HANDLE hContact = GetContact( sShortName ); if ( ! hContact ) { // Добавление контакта hContact = (HANDLE)CallService( MS_DB_CONTACT_ADD, 0, 0 ); if ( hContact ) { CallService( MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)modname ); SetNick( hContact, sShortName ); SetGroup( hContact, bGroup ); db_set_ts( hContact, "CList", "MyHandle", sShortName ); db_set_b( hContact, "CList", "NotOnList", 1 ); db_set_b( hContact, "CList", "Hidden", 1 ); SetContactIP( hContact, addr ); SetElapsed( hContact, "IPTime" ); if ( about ) db_set_ts( hContact, modname, "About", about ); contact_scanner::ScanContact( hContact ); } } if ( hContact && ! ( flags & PALF_TEMPORARY ) && db_get_b( hContact, "CList", "NotOnList", 1 ) ) { // Оставляем контакт db_unset( hContact, "CList", "NotOnList" ); db_unset( hContact, "CList", "Hidden" ); } return hContact; }
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()); } }
INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); { MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam; char name[2048]; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact); if (db_get_static(hContact, MODNAME, "Name", name, _countof(name))) break; SetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, name); if (db_get_static(hContact, MODNAME, "ToolTip", name, _countof(name))) break; SetDlgItemTextA(hwnd, IDC_TOOLTIP, name); } return TRUE; case WM_COMMAND: SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); return TRUE; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (GetWindowTextLength(GetDlgItem(hwnd, IDC_DISPLAY_NAME))) { char text[512]; GetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, text, _countof(text)); db_set_s(hContact, MODNAME, "Name", text); WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick"); } else { db_unset(hContact, MODNAME, "Name"); db_unset(hContact, MODNAME, "Nick"); } if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TOOLTIP))) { char text[2048]; GetDlgItemTextA(hwnd, IDC_TOOLTIP, text, _countof(text)); db_set_s(hContact, MODNAME, "ToolTip", text); WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes"); } else { db_unset(hContact, MODNAME, "ToolTip"); db_unset(hContact, "UserInfo", "MyNotes"); } } return TRUE; } break; } return FALSE; }
int LoadSkinHotkeys(void) { WNDCLASSEX wcl = { 0 }; bModuleInitialized = TRUE; wcl.cbSize = sizeof(wcl); wcl.lpfnWndProc = sttHotkeyHostWndProc; wcl.style = 0; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hInstance = g_hInst; wcl.hIcon = NULL; wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); wcl.lpszMenuName = NULL; wcl.lpszClassName = _T("MirandaHotkeyHostWnd"); wcl.hIconSm = NULL; RegisterClassEx(&wcl); g_pid = GetCurrentProcessId(); g_hwndHotkeyHost = CreateWindow(_T("MirandaHotkeyHostWnd"), NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL); SetWindowPos(g_hwndHotkeyHost, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW); hhkKeyboard = SetWindowsHookEx(WH_KEYBOARD, sttKeyboardProc, NULL, hMainThreadId); hEvChanged = CreateHookableEvent(ME_HOTKEYS_CHANGED); CreateServiceFunction("CoreHotkeys/Register", svcHotkeyRegister); CreateServiceFunction(MS_HOTKEY_UNREGISTER, svcHotkeyUnregister); CreateServiceFunction(MS_HOTKEY_SUBCLASS, svcHotkeySubclass); CreateServiceFunction(MS_HOTKEY_UNSUBCLASS, svcHotkeyUnsubclass); CreateServiceFunction(MS_HOTKEY_CHECK, svcHotkeyCheck); HookEvent(ME_SYSTEM_MODULESLOADED, sttModulesLoaded); for (int i = 0; i < _countof(oldSettings); i++) { char szSetting[100]; mir_snprintf(szSetting, "HK%s", oldSettings[i]); WORD key; if ((key = db_get_w(NULL, "Clist", szSetting, 0))) { db_unset(NULL, "Clist", szSetting); db_set_w(NULL, DBMODULENAME, newSettings[i], key); } mir_snprintf(szSetting, "HKEn%s", oldSettings[i]); if ((key = db_get_b(NULL, "Clist", szSetting, 0))) { db_unset(NULL, "Clist", szSetting); db_set_b(NULL, DBMODULENAME "Off", newSettings[i], (BYTE)(key == 0)); } } return 0; }
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()) { CMString tszDisplayName(display_name.as_mstring()); int pos = tszDisplayName.ReverseFind(' '); if (pos != -1) { db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos+1)); db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos)); } else { db_set_ts(hContact, MODULE, "FirstName", tszDisplayName); 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 *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0); db_set_s(hContact, MODULE, "Country", szCountry); } } 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()); } }
void CVkProto::OnLoggedIn() { debugLogA("CVkProto::OnLoggedIn"); m_bOnline = true; SetServerStatus(m_iDesiredStatus); // initialize online timer CallFunctionAsync(VKSetTimer, this); db_unset(NULL, m_szModuleName, "LastNewsReqTime"); db_unset(NULL, m_szModuleName, "LastNotificationsReqTime"); }
static void RemoveAvatar(TlenProtocol *proto, HANDLE hContact) { TCHAR tFileName[ MAX_PATH ]; if (hContact == NULL) { proto->threadData->avatarHash[0] = '\0'; } TlenGetAvatarFileName( proto, NULL, tFileName, sizeof tFileName ); DeleteFile(tFileName); db_unset(hContact, "ContactPhoto", "File"); db_unset(hContact, proto->m_szModuleName, "AvatarHash"); db_unset(hContact, proto->m_szModuleName, "AvatarFormat"); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); }
void DeleteAvatar(HANDLE hContact) { if (hContact && db_get_b(hContact, "ContactPhoto", "IsZodiac", FALSE)) { db_unset(hContact, "ContactPhoto", "File"); db_unset(hContact, "ContactPhoto", "RFile"); db_unset(hContact, "ContactPhoto", "Backup"); db_unset(hContact, "ContactPhoto", "ImageHash"); db_set_b(hContact, "ContactPhoto", "IsZodiac", 0); } }
INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM) { if (bPGPloaded) { db_unset(wParam, MODULENAME, "pgp"); db_unset(wParam, MODULENAME, "pgp_mode"); db_unset(wParam, MODULENAME, "pgp_abbr"); } { pUinKey ptr = getUinKey(wParam); cpp_delete_context(ptr->cntx); ptr->cntx = 0; } ShowStatusIconNotify(wParam); return 1; }
void CleanSettings(int buttonnum,int from) { char szMEntry[256]={'\0'}; DBVARIANT dbv = {0}; if(from==-1){ mir_snprintf(szMEntry,SIZEOF(szMEntry),"ButtonName_%u",buttonnum); db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"ButtonValue_%u",buttonnum); db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"RCEntryIsServiceName_%u",buttonnum); db_unset(NULL, PLGNAME,szMEntry); } mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryName_%u_%u",buttonnum,from); while(!db_get_ts(NULL, PLGNAME,szMEntry,&dbv)) { db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryValue_%u_%u",buttonnum,from); db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryRel_%u_%u",buttonnum,from); db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryToQMenu_%u_%u",buttonnum,from); db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryIsServiceName_%u_%u",buttonnum,from); db_unset(NULL, PLGNAME,szMEntry); mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryName_%u_%u",buttonnum,++from); } db_free(&dbv); }
MIR_CORE_DLL(void) TimeZone_StoreByContact(MCONTACT hContact, LPCSTR szModule, HANDLE hTZ) { if (szModule == NULL) szModule = "UserInfo"; MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ; if (tz) { db_set_ts(hContact, szModule, "TzName", tz->tszName); db_set_b(hContact, szModule, "Timezone", (char)((tz->tzi.Bias + tz->tzi.StandardBias) / 30)); } else { db_unset(hContact, szModule, "TzName"); db_unset(hContact, szModule, "Timezone"); } }
INT_PTR Meta_Delete(WPARAM wParam,LPARAM lParam) { DWORD metaID; // The wParam is a metacontact if ((metaID = db_get_dw((HANDLE)wParam, META_PROTO, META_ID, (DWORD)-1)) != (DWORD)-1) { if ( !lParam) { // check from recursion - see second half of this function if ( MessageBox((HWND)CallService(MS_CLUI_GETHWND,0,0), TranslateT("This will remove the MetaContact permanently.\n\nProceed Anyway?"), TranslateT("Are you sure?"),MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) != IDYES) return 0; } for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { // This contact is assigned to the MetaContact that will be deleted, clear the "MetaContacts" information if ( db_get_dw(hContact, META_PROTO, META_LINK,(DWORD)-1) == metaID) { db_unset(hContact, META_PROTO, "IsSubcontact"); db_unset(hContact, META_PROTO, META_LINK); db_unset(hContact, META_PROTO, "Handle"); db_unset(hContact, META_PROTO, "ContactNumber"); // unhide - must be done after removing link (see meta_services.c:Meta_ChangeStatus) Meta_RestoreGroup(hContact); db_unset(hContact, META_PROTO, "OldCListGroup"); // stop ignoring, if we were if (options.suppress_status) CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE); } } NotifyEventHooks(hSubcontactsChanged, (WPARAM)wParam, 0); CallService(MS_DB_CONTACT_DELETE,wParam,0); } else { HANDLE hMeta = (HANDLE)db_get_dw((HANDLE)wParam, META_PROTO, "Handle", 0); DWORD num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", -1); if (num_contacts == 1) { if (IDYES == MessageBox(0, TranslateT(szDelMsg), TranslateT("Delete MetaContact?"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1)) Meta_Delete((WPARAM)hMeta,(LPARAM)1); return 0; } Meta_RemoveContactNumber(hMeta, db_get_dw((HANDLE)wParam, META_PROTO, "ContactNumber", -1)); } return 0; }
static BOOL Convert(MCONTACT hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string { int Result = 1; char temp[64]; switch (toType) { case 0: if (value > 0xFF) Result = 0; else db_set_b(hContact, module, setting, (BYTE)value); break; case 1: if (value > 0xFFFF) Result = 0; else db_set_w(hContact, module, setting, (WORD)value); break; case 2: db_set_dw(hContact, module, setting, (DWORD)value); break; case 3: db_unset(hContact, module, setting); db_set_s(hContact, module, setting, itoa(value, temp, 10)); break; } return Result; }
static int Toolbar_ModulesLoaded(WPARAM, LPARAM) { CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("Toolbar background")"/ToolBar"), 0); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ehhToolBarSettingsChanged); TopToolbar_SetCustomProc(CustomizeButton, 0); BYTE bOldSetting = 0; if (!db_get_b(NULL, "Compatibility", "TTB_Upgrade", 0)) { if (bOldSetting = db_get_b(NULL, "CLUI", "ShowButtonBar", 1)) { CopySettings("BUTTWIDTH", "option_Bar0_BtnWidth", 20); CopySettings("BUTTHEIGHT", "option_Bar0_BtnHeight", 20); CopySettings("BUTTGAP", "option_Bar0_BtnSpace", 1); CopySettings("BUTTAUTOSIZE", "option_Bar0_Autosize", 1); CopySettings("BUTTMULTI", "option_Bar0_Multiline", 1); db_unset(NULL, "CLUI", "ShowButtonBar"); CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)"ModernToolBar"); } db_set_b(NULL, "Compatibility", "TTB_Upgrade", 1); } if (!ServiceExists(MS_TTB_REMOVEBUTTON) && bOldSetting == 1) if (IDYES == MessageBox(NULL, TranslateTS(szWarning), TranslateT("Toolbar upgrade"), MB_ICONQUESTION | MB_YESNO)) CallService(MS_UTILS_OPENURL, 0, (LPARAM)szUrl); return 0; }
/** * name: DBResetState * class: CPsTree * desc: delete all treesettings from database * param: pszGroup - name of the parent item of the current subtree * hRootItem - the root of the current subtree * iItem - index of the current item for position saving * return: 0 on success or 1 otherwise **/ void CPsTree::DBResetState() { DB::CEnumList Settings; if (!Settings.EnumSettings(NULL, MODNAME)) { int i; LPSTR s; LPCSTR p; INT_PTR c; p = (_pPs->pszProto[0]) ? _pPs->pszProto : "Owner"; c = mir_strlen(p); for (i = 0; i < Settings.getCount(); i++) { s = Settings[i]; if (s && *s == '{' && !mir_strnicmp(s + 1, p, c)) { db_unset(NULL, MODNAME, s); } } // keep only these flags _dwFlags &= PSTVF_SORTTREE|PSTVF_GROUPS; } }
void MarkUnread(MCONTACT hContact) { // We're not actually marking anything. We just pushing saved events to the database from a temporary location DBVARIANT _dbv = {0}; PBYTE pos; if (hContact == NULL) return; if (db_get(hContact, PLUGIN_NAME, "LastMsgEvents", &_dbv) == 0) { pos = _dbv.pbVal; while (pos - _dbv.pbVal < _dbv.cpbVal) { DBEVENTINFO _dbei; ZeroMemory(&_dbei, sizeof(_dbei)); _dbei.cbSize = sizeof(_dbei); memcpy(&_dbei.eventType, pos, sizeof(WORD)); pos += sizeof(WORD); memcpy(&_dbei.flags, pos, sizeof(DWORD)); pos += sizeof(DWORD); memcpy(&_dbei.timestamp, pos, sizeof(DWORD)); pos += sizeof(DWORD); _dbei.szModule = (char*)malloc(strlen((const char*)pos)+1); strcpy(_dbei.szModule, (const char*)pos); pos += strlen((const char*)pos)+1; memcpy(&_dbei.cbBlob, pos, sizeof(DWORD)); pos += sizeof(DWORD); _dbei.pBlob = (PBYTE)malloc(_dbei.cbBlob); memcpy(_dbei.pBlob, pos, _dbei.cbBlob); pos += _dbei.cbBlob; db_event_add(hContact,&_dbei); } db_free(&_dbv); db_unset(hContact, PLUGIN_NAME, "LastMsgEvents"); } }
int deleteModule(char* module, MCONTACT hContact, int fromMenu) { char msg[1024]; ModuleSettingLL settinglist; ModSetLinkLinkItem *setting; if (!module) return 0; if (!fromMenu) { mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete module \"%s\"?"), module); if (db_get_b(NULL,modname, "WarnOnDelete",1)) if (MessageBox(0,msg, Translate("Confirm Module Deletion"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) return 0; } if (!EnumSettings(hContact,module,&settinglist)) return 0; setting = settinglist.first; while (setting) { db_unset(hContact, module, setting->name); setting = setting->next; } FreeModuleSettingLL(&settinglist); return 1; }