void SetInSessionOrder(MCONTACT hContact,int mode,int count,unsigned int ordernum) { int iOrder=0; char szTemp[3]={'\0'}; if (ordernum < 10) mir_snprintf(szTemp, SIZEOF(szTemp), "%u%u", 0, ordernum); else mir_snprintf(szTemp, SIZEOF(szTemp), "%u", ordernum); if (mode == 0) { DBVARIANT dbv; if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal) { dbv.pszVal[count*2]=szTemp[0]; dbv.pszVal[count*2+1]=szTemp[1]; db_set_s(hContact, MODNAME, "LastSessionsOrder", dbv.pszVal); db_free(&dbv); } } else if (mode == 1) { DBVARIANT dbv; if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) { dbv.pszVal[count*2]=szTemp[0]; dbv.pszVal[count*2+1]=szTemp[1]; db_set_s(hContact, MODNAME, "UserSessionsOrder", dbv.pszVal); db_free(&dbv); } } }
void RemoveSessionMark(MCONTACT hContact,int mode,int marknum) { unsigned int i=1; char temp_1[1]={'\0'},temp_2[1]={'\0'}; char szDst[256]={'\0'}; DBVARIANT dbv; if (mode == 0) { if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) { for (i=marknum;i<ses_limit;i++) dbv.pszVal[i] = dbv.pszVal[i+1]; for (i=ses_limit;i<10;i++) dbv.pszVal[i] = '0'; db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal); db_free(&dbv); } } else if (mode == 1) { if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) { for (i=marknum;i < ses_limit; i++) dbv.pszVal[i] = dbv.pszVal[i+1]; db_set_s(hContact, MODNAME, "UserSessionsMarks", dbv.pszVal); db_free(&dbv); } } }
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; }
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 AddInSessionOrder(MCONTACT hContact, int mode, int ordernum, int writemode) { char szFormNumBuf[100]; mir_snprintf(szFormNumBuf, "%02u", ordernum); if (mode == 0) { ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks")); if (szValue) { int len = (int)mir_strlen(szValue); if (!len) len = 20; char *temp2 = (char*)_alloca(len - 1); strncpy(temp2, szValue, len - 2); temp2[len - 2] = '\0'; char *temp = (char*)_alloca(len + 1); mir_snprintf(temp, len + 1, "%02u%s", ordernum, temp2); for (int i = (g_ses_limit * 2); i < 20; i++) temp[i] = '0'; db_set_s(hContact, MODNAME, "LastSessionsOrder", temp); } else if (writemode == 1) { mir_snprintf(szFormNumBuf, "%02u%s", ordernum, "000000000000000000"); db_set_s(hContact, MODNAME, "LastSessionsOrder", szFormNumBuf); } } else if (mode == 1) { ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder")); if (szValue) { char *pszBuffer; if (mir_strlen(szValue) < (g_ses_count * 2)) { pszBuffer = (char*)mir_alloc((g_ses_count * 2) + 1); memset(pszBuffer, 0, ((g_ses_count * 2) + 1)); mir_strcpy(pszBuffer, szValue); } else pszBuffer = mir_strdup(szValue); int len = (int)mir_strlen(pszBuffer); len = (len == 0) ? 20 : len + 2; char *temp = (char*)_alloca(len + 1); mir_snprintf(temp, len + 1, "%02u%s", ordernum, szValue); db_set_s(hContact, MODNAME, "UserSessionsOrder", temp); mir_free(pszBuffer); } else if (writemode == 1) db_set_s(hContact, MODNAME, "UserSessionsOrder", szFormNumBuf); else db_set_s(hContact, MODNAME, "UserSessionsOrder", "00"); } }
void CDropbox::RequestAccountInfo(void *p) { CDropbox *self = (CDropbox*)p; MCONTACT hContact = self->GetDefaultContact(); ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); GetCurrentAccountRequest request(token); NLHR_PTR response(request.Send(self->hNetlibConnection)); HandleJsonResponseError(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 email = root.at("email"); if (!email.empty()) db_set_s(hContact, MODULE, "e-mail", email.as_string().c_str()); JSONNode name = root.at("name"); if (!name.empty()) { db_set_utf(hContact, MODULE, "FirstName", name.at("given_name").as_string().c_str()); db_set_utf(hContact, MODULE, "LastName", name.at("surname").as_string().c_str()); } 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()) { ULONG lTotalQuota = quota_info.at("quota").as_int(); ULONG lNormalQuota = quota_info.at("normal").as_int(); ULONG lSharedQuota = quota_info.at("shared").as_int(); db_set_dw(hContact, MODULE, "SharedQuota", lSharedQuota); db_set_dw(hContact, MODULE, "NormalQuota", lNormalQuota); db_set_dw(hContact, MODULE, "TotalQuota", lTotalQuota); db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota) / (1024 * 1024), lTotalQuota / (1024 * 1024))); }*/ }
/** * name: SaveInitialDir * desc: save the last vCard directory from database * pszInitialDir - buffer to store the initial dir to (size must be MAX_PATH) * return: nothing **/ static void SaveInitialDir(LPSTR pszInitialDir) { CHAR szRelative[MAX_PATH]; LPSTR p; if (p = mir_strrchr(pszInitialDir, '\\')) { *p = 0; if ( PathToRelative(pszInitialDir, szRelative)) db_set_s(0, MODNAME, "vCardPath", szRelative); else db_set_s(0, MODNAME, "vCardPath", pszInitialDir); *p = '\\'; } }
void AddSessionMark(MCONTACT hContact, int mode, char bit) { DBVARIANT dbv; unsigned int i; char temp_1[1]={'\0'},temp_2[1]={'\0'}; char szDst[256]={'\0'}; char* pszBuffer=NULL; if (mode == 0) { if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) { temp_1[0]=dbv.pszVal[0]; for (i=0; i < ses_limit; i++) { temp_2[0]=dbv.pszVal[i+1]; dbv.pszVal[i+1]=temp_1[0]; temp_1[0]=temp_2[0]; } for (i=ses_limit; i < 10; i++) dbv.pszVal[i]='0'; dbv.pszVal[0]=bit; db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal); db_free(&dbv); } else if (bit == '1') db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000"); } else if (mode == 1) { if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) { if (strlen(dbv.pszVal)<g_ses_count) { pszBuffer = (char*)mir_alloc(g_ses_count+1); ZeroMemory(pszBuffer,g_ses_count+1); strcpy(pszBuffer,dbv.pszVal); } else pszBuffer = mir_strdup(dbv.pszVal); db_free(&dbv); temp_1[0]=pszBuffer[0]; for (i=0;i<g_ses_count;i++) { temp_2[0]=pszBuffer[i+1]; pszBuffer[i+1]=temp_1[0]; temp_1[0]=temp_2[0]; } pszBuffer[0]=bit; db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer); mir_free(pszBuffer); } else if (bit == '1') db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000"); else db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000"); } }
void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) { char *type; // RECVED: authentication result // ACTION: if successfully logged in, continue by requesting roster list and set my initial status if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; if (!strcmp(type, "result")) { DBVARIANT dbv; if (db_get(NULL, proto->m_szModuleName, "Nick", &dbv)) db_set_s(NULL, proto->m_szModuleName, "Nick", proto->threadData->username); else db_free(&dbv); // iqId = TlenSerialNext(); // TlenIqAdd(iqId, IQ_PROC_NONE, TlenIqResultGetRoster); // TlenSend(info, "<iq type='get' id='"TLEN_IQID"%d'><query xmlns='jabber:iq:roster'/></iq>", iqId); TlenSend(proto, "<iq type='get' id='GetRoster'><query xmlns='jabber:iq:roster'/></iq>"); TlenSend(proto, "<iq to='tcfg' type='get' id='TcfgGetAfterLoggedIn'></iq>"); } // What to do if password error? etc... else if (!strcmp(type, "error")) { char text[128]; TlenSend(proto, "</s>"); mir_snprintf(text, sizeof(text), Translate("Authentication failed for %s@%s."), proto->threadData->username, proto->threadData->server); MessageBoxA(NULL, text, Translate("Tlen Authentication"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); proto->threadData = NULL; // To disallow auto reconnect } }
void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool force) { DBVARIANT dbv = {0}; if( !force && (!db_get_s(hContact,m_szModuleName,TWITTER_KEY_AV_URL,&dbv) && url == dbv.pszVal)) { debugLogA( _T("***** Avatar already up-to-date: %s"), url.c_str()); } else { // TODO: more defaults (configurable?) if(url == "http://static.twitter.com/images/default_profile_normal.png") { PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai),hContact}; db_set_s(hContact,m_szModuleName,TWITTER_KEY_AV_URL,url.c_str()); ProtoBroadcastAck(hContact,ACKTYPE_AVATAR,ACKRESULT_SUCCESS,&ai,0); } else { ForkThread(&TwitterProto::UpdateAvatarWorker, new update_avatar(hContact,url)); } } db_free(&dbv); }
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); }
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; }
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; }
ROWCELL *cppInitModernRow(ROWCELL ** tabAccess) { int fsize; int seq = 0; ROWCELL * RowRoot = NULL; FILE * hFile; int i=0; if (!db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT)) return NULL; tmplbuf = NULL; if ( db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT) == 1) tmplbuf = db_get_sa(NULL,"ModernData","RowTemplate"); if (tmplbuf) { rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess); mir_free(tmplbuf); return RowRoot; } if (hFile = fopen("template.txt", "rb")) { fsize = _filelength(_fileno(hFile)); tmplbuf = (char*)malloc(fsize+1); ZeroMemory(tmplbuf, fsize+1); for (i=0; i < fsize; i++) tmplbuf[i] = getc(hFile); tmplbuf[i] = 0; i=0; rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess); db_set_s(NULL,"ModernData","RowTemplate",tmplbuf); free(tmplbuf); fclose(hFile); return RowRoot; } return NULL; }
/** * name: CLineBuffer::DBWriteTokenFirst * desc: scans for the first <delim> in the _pVal member and writes all characters * that come before the first <delim> to database * param: hContact - handle to the contact to write the setting to * pszModule - destination module * pszSetting - destination setting for the value * delim - the deliminer which delimins the string * * return: 0 if successful, 1 otherwise **/ int CLineBuffer::DBWriteTokenFirst(MCONTACT hContact, const CHAR* pszModule, const CHAR* pszSetting, const CHAR delim) { PBYTE here; int iRet = 1; _pTok = _pVal; if (_pTok && *_pTok) { for (here = _pTok;; here++) { if (*here == 0 || *here == '\n' || *here == delim) { if (here - _pTok > 0) { CHAR c = *here; *here = 0; iRet = db_set_s(hContact, pszModule, pszSetting, (LPSTR)_pTok); *here = c; } _pTok = (*here == 0 || *here == '\n') ? NULL : ++here; break; } } } if (iRet) iRet = db_unset(hContact, pszModule, pszSetting); return iRet; }
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 AddSessionMark(MCONTACT hContact, int mode, char bit) { if (mode == 0) { ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks")); if (szValue) { char temp_1 = szValue[0]; for (int i = 0; i < g_ses_limit; i++) { char temp_2 = szValue[i + 1]; szValue[i + 1] = temp_1; temp_1 = temp_2; } for (int i = g_ses_limit; i < 10; i++) szValue[i] = '0'; szValue[0] = bit; db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue); } else if (bit == '1') db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000"); } else if (mode == 1) { ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks")); if (szValue) { char *pszBuffer; if (mir_strlen(szValue) < g_ses_count) { pszBuffer = (char*)mir_alloc(g_ses_count + 1); memset(pszBuffer, 0, (g_ses_count + 1)); mir_strcpy(pszBuffer, szValue); } else pszBuffer = szValue.detach(); char temp_1 = pszBuffer[0]; for (int i = 0; i < g_ses_count; i++) { char temp_2 = pszBuffer[i + 1]; pszBuffer[i + 1] = temp_1; temp_1 = temp_2; } pszBuffer[0] = bit; db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer); mir_free(pszBuffer); } else if (bit == '1') db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000"); else db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000"); } }
void SetSessionMark(MCONTACT hContact, int mode, char bit, unsigned int marknum) { if (mode == 0) { ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks")); if (szValue) { szValue[marknum] = bit; db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue); } } else if (mode == 1) { ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks")); if (szValue) { szValue[marknum] = bit; db_set_s(hContact, MODNAME, "UserSessionsMarks", szValue); } } }
int myDBWriteStringEncode(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val) { int len = (int)strlen(val) + 64; char *buf = (LPSTR)alloca(len); strncpy(buf, val, len); int ret = db_set_s(hContact, szModule, szSetting, buf); return ret; }
void SettingsMigrate(void) { BYTE TrayIcon = db_get_b(NULL, "CList", "TrayIcon", 0); BYTE AlwaysPrimary = db_get_b(NULL, "CList", "AlwaysPrimary", 0); BYTE AlwaysMulti = db_get_b(NULL, "CList", "AlwaysMulti", 0); ptrA PrimaryStatus(db_get_sa(NULL, "CList", "PrimaryStatus")); // these strings must always be set if (PrimaryStatus) { db_set_s(NULL, "CList", "tiAccS", PrimaryStatus); db_set_s(NULL, "CList", "tiAccV", PrimaryStatus); } else { db_set_s(NULL, "CList", "tiAccS", ""); db_set_s(NULL, "CList", "tiAccV", ""); } switch (TrayIcon) { case 0: // global or single acc if (AlwaysPrimary) { if (!PrimaryStatus) { // global always db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL); db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL); } else { // single acc always db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_ACC); db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ACC); } } else { db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL); db_set_b(NULL, "CList", "tiModeV", (PrimaryStatus) ? TRAY_ICON_MODE_ACC : TRAY_ICON_MODE_GLOBAL); } break; case 1: // cycle db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_CYCLE); db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_CYCLE); break; case 2: // multiple db_set_b(NULL, "CList", "tiModeS", (AlwaysMulti) ? TRAY_ICON_MODE_ALL : TRAY_ICON_MODE_GLOBAL); db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ALL); break; } }
MCONTACT CDropbox::GetDefaultContact() { if (!hDefaultContact) hDefaultContact = db_find_first(MODULE); if (!hDefaultContact) { hDefaultContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); if (!Proto_AddToContact(hDefaultContact, MODULE)) { db_set_s(NULL, MODULE, "Nick", MODULE); db_set_s(hDefaultContact, MODULE, "Nick", MODULE); db_set_ws(hDefaultContact, "CList", "MyHandle", L"Dropbox"); } db_set_w(hDefaultContact, MODULE, "Status", HasAccessToken() ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE); } return hDefaultContact; }
void replaceAllStrings(MCONTACT hContact) { char tmp1[256], tmp2[256], tmp3[256]; WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick"); WriteSetting(hContact, MODNAME, "ProgramString", MODNAME, "Program"); WriteSetting(hContact, MODNAME, "ProgramParamsString", MODNAME, "ProgramParams"); /* tooltips*/ WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes"); if (db_get_static(hContact, MODNAME, "Program", tmp1, _countof(tmp1)) && db_get_static(hContact, MODNAME, "ProgramParams", tmp2, _countof(tmp2))) { mir_snprintf(tmp3, _countof(tmp3), "%s %s", tmp1, tmp2); db_set_s(hContact, "UserInfo", "FirstName", tmp3); } else if (db_get_static(hContact, MODNAME, "Program", tmp1, _countof(tmp1))) { db_set_s(hContact, "UserInfo", "FirstName", tmp1); } else db_set_s(hContact, "UserInfo", "FirstName", ""); }
static INT_PTR CALLBACK icqOptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; char str[128]; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hWnd); SetDlgItemInt(hWnd, IDC_OPT_UIN, db_get_dw(NULL, protoName, "UIN", 0), FALSE); if (!db_get(NULL, protoName, "Password", &dbv)) { SetDlgItemText(hWnd, IDC_OPT_PASSWORD, dbv.pszVal); db_free(&dbv); } if(!db_get(NULL, protoName, "Server", &dbv)) { SetDlgItemText(hWnd, IDC_OPT_SERVER, dbv.pszVal); db_free(&dbv); } SetDlgItemInt(hWnd, IDC_OPT_PORT, db_get_w(NULL, protoName, "Port", 4000), FALSE); ShowWindow(GetDlgItem(hWnd, IDC_OPT_RECONNECT), SW_HIDE); return TRUE; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: db_set_dw(NULL, protoName, "UIN", (DWORD)GetDlgItemInt(hWnd, IDC_OPT_UIN, NULL, FALSE)); GetDlgItemText(hWnd, IDC_OPT_PASSWORD, str, sizeof(str)); db_set_s(NULL, protoName, "Password", str); GetDlgItemText(hWnd, IDC_OPT_SERVER, str, sizeof(str)); db_set_s(NULL, protoName, "Server", str); db_set_w(NULL, protoName, "Port", (WORD)GetDlgItemInt(hWnd, IDC_OPT_PORT, NULL, FALSE)); return TRUE; } break; case WM_COMMAND: if ((LOWORD(wParam) == IDC_OPT_UIN || LOWORD(wParam) == IDC_OPT_PASSWORD || LOWORD(wParam) == IDC_OPT_SERVER || LOWORD(wParam) == IDC_OPT_PORT) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); break; } return FALSE; }
void SaveNotificationSettings(POPUPTREEDATA *ptd, char* szModul) { if (ptd->typ == 1) { char setting[2 * MAXMODULELABELLENGTH]; mir_snprintf(setting, "{%s/%s}Timeout", ptd->notification.lpzGroup, ptd->notification.lpzName); db_set_w(NULL, szModul, setting, ptd->notification.iSeconds); mir_snprintf(setting, "{%s/%s}enabled", ptd->notification.lpzGroup, ptd->notification.lpzName); db_set_b(NULL, szModul, setting, ptd->enabled); mir_snprintf(setting, "{%s/%s}TimeoutVal", ptd->notification.lpzGroup, ptd->notification.lpzName); db_set_w(NULL, szModul, setting, ptd->timeoutValue); mir_snprintf(setting, "{%s/%s}disableWhen", ptd->notification.lpzGroup, ptd->notification.lpzName); db_set_b(NULL, szModul, setting, ptd->disableWhen); mir_snprintf(setting, "{%s/%s}leftAction", ptd->notification.lpzGroup, ptd->notification.lpzName); db_set_s(NULL, szModul, setting, ptd->leftAction); mir_snprintf(setting, "{%s/%s}rightAction", ptd->notification.lpzGroup, ptd->notification.lpzName); db_set_s(NULL, szModul, setting, ptd->rightAction); for (int i = 0; i < ptd->notification.actionCount; ++i) { POPUPNOTIFYACTION &p = ptd->notification.lpActions[i]; if (!mir_strcmp(ptd->leftAction, p.lpzTitle)) db_set(NULL, p.lpzLModule, p.lpzLSetting, &p.dbvLData); if (!mir_strcmp(ptd->rightAction, p.lpzTitle)) db_set(NULL, p.lpzRModule, p.lpzRSetting, &p.dbvRData); } } }
static INT_PTR Proto_AddToContact(WPARAM wParam, LPARAM lParam) { char *szProto = (char*)lParam; PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(szProto); if (pd == NULL) { PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa) { db_set_s(wParam, "Protocol", "p", szProto); return 0; } return 1; } if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL) db_set_s(wParam, "Protocol", "p", szProto); return 0; }
BOOL convertSetting(MCONTACT hContact, char* module, char* setting, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string, 4 = unicode { DBVARIANT dbv = { 0 }; BOOL Result = 0; if (!GetSetting(hContact, module, setting, &dbv)) { switch (dbv.type) { case DBVT_BYTE: Result = Convert(hContact, module, setting, dbv.bVal, toType); break; case DBVT_WORD: Result = Convert(hContact, module, setting, dbv.wVal, toType); break; case DBVT_DWORD: Result = Convert(hContact, module, setting, dbv.dVal, toType); break; case DBVT_ASCIIZ: if (toType == 4) // convert to UNICODE { int len = (int)strlen(dbv.pszVal) + 1; WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); Result = !db_set_ws(hContact, module, setting, wc); } else if (strlen(dbv.pszVal) < 11 && toType != 3) { int val = atoi(dbv.pszVal); if (val == 0 && dbv.pszVal[0] != '0') break; Result = Convert(hContact, module, setting, val, toType); } break; case DBVT_UTF8: if (toType == 3) { // convert to ANSI int len = (int)strlen(dbv.pszVal) + 1; char *sz = (char*)_alloca(len * 3); WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); Result = !db_set_s(hContact, module, setting, sz); } break; } if (!Result) msg(Translate("Cannot Convert!"), modFullname); db_free(&dbv); } return Result; }
int setTextValue(MCONTACT hContact, const char *module, const char *setting, TCHAR *value, int type) { #ifdef _UNICODE if (type == DBVT_UTF8 || type == DBVT_WCHAR) return !db_set_ws(hContact, module, setting, value); if (type == DBVT_ASCIIZ && IsRealUnicode(value)) return 0; #endif return !db_set_s(hContact, module, setting, _T2A(value)); }
void IcolibExtraIcon::storeIcon(MCONTACT hContact, void *icon) { if (hContact == NULL) return; const char *icolibName = (const char *)icon; if (IsEmpty(icolibName)) db_unset(hContact, MODULE_NAME, m_szName); else db_set_s(hContact, MODULE_NAME, m_szName, icolibName); }
INT_PTR ContactChangeGroup(WPARAM hContact, LPARAM lParam) { CallService(MS_CLUI_CONTACTDELETED, hContact, 0); if ((HANDLE)lParam == NULL) db_unset(hContact, "CList", "Group"); else db_set_s(hContact, "CList", "Group", (char*)CallService(MS_CLIST_GROUPGETNAME2, lParam, (LPARAM)(int*)NULL)); CallService(MS_CLUI_CONTACTADDED, hContact, ExtIconFromStatusMode(hContact, GetContactProto(hContact), GetContactStatus(hContact))); return 0; }