int DoExport(TCHAR *fileName) { FILE *fout = _tfopen(fileName, _T("wt")); if (!fout) { MessageBox(0, TranslateT("Could not open file to export birthdays"), TranslateT("Error"), MB_OK | MB_ICONERROR); return 1; } _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), TranslateT("Please do not edit this file by hand. Use the export function of WhenWasIt plugin.\n")); _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), TranslateT("Warning! Please do not mix Unicode and Ansi exported birthday files. You should use the same version (Ansi/Unicode) of WhenWasIt that was used to export the info.\n")); _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), TranslateT("This file was exported with a Unicode version of WhenWasIt. Please only use a Unicode version of the plugin to import the birthdays.\n")); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { int year, month, day; GetContactDOB(hContact, year, month, day); if (IsDOBValid(year, month, day)) { char *szProto = GetContactProto(hContact); TCHAR *szHandle = GetContactID(hContact, szProto); if ((szHandle) && (mir_strlen(szProto) > 0)) _ftprintf(fout, _T(BIRTHDAYS_EXPORT_FORMAT), szHandle, szProto, day, month, year); if (szHandle) free(szHandle); } } fclose(fout); return 0; }
TCHAR *GetContactID(MCONTACT hContact) { char protocol[256]; GetContactProtocol(hContact, protocol, sizeof(protocol)); return GetContactID(hContact, protocol); }
MCONTACT GetContactFromID(TCHAR *szID, char *szProto) { TCHAR *szHandle; TCHAR dispName[1024]; char cProtocol[256]; TCHAR *tmp; int found = 0; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); szHandle = GetContactID(hContact, cProtocol); tmp = pcli->pfnGetContactDisplayName(hContact, 0); _tcsncpy(dispName, tmp, _countof(dispName)); if ((szHandle) && ((mir_tstrcmpi(szHandle, szID) == 0) || (mir_tstrcmpi(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0))) found = 1; if (szHandle) { free(szHandle); } if (found) return hContact; } return NULL; }
static __forceinline char *GetContactIDX(const char*, MCONTACT hContact) { TCHAR *id = GetContactID(hContact); char* res = mir_t2a(id); mir_free(id); return res; }
MCONTACT GetContactFromID(TCHAR *szID, char *szProto) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *m_szProto = GetContactProto(hContact); TCHAR *szHandle = GetContactID(hContact, szProto); if (szHandle) { bool found = (!_tcsicmp(szHandle, szID) && !_stricmp(szProto, m_szProto)); free(szHandle); if (found) return hContact; } } return NULL; }
void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL patchVars) { DBVARIANT dbv; TCHAR szTemp[MAX_PATH]; szTemp[0] = 0; if ( !DBGetContactSettingTString( NULL, "SRFile", "RecvFilesDirAdv", &dbv)) { if ( lstrlen( dbv.ptszVal ) > 0 ) lstrcpyn( szTemp, dbv.ptszVal, SIZEOF( szTemp )); DBFreeVariant( &dbv ); } if ( !szTemp[0] ) #ifdef _UNICODE mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My Received Files")); #else mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), "My Received Files"); #endif if ( hContact ) { REPLACEVARSDATA dat = { 0 }; REPLACEVARSARRAY rvaVarsToReplace[4]; rvaVarsToReplace[0].lptzKey = _T("nick"); rvaVarsToReplace[0].lptzValue = mir_tstrdup((TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); rvaVarsToReplace[1].lptzKey = _T("userid"); rvaVarsToReplace[1].lptzValue = GetContactID(hContact); rvaVarsToReplace[2].lptzKey = _T("proto"); rvaVarsToReplace[2].lptzValue = mir_a2t((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact,0)); rvaVarsToReplace[3].lptzKey = NULL; rvaVarsToReplace[3].lptzValue = NULL; for (int i=0; i < (SIZEOF(rvaVarsToReplace)-1);i++) RemoveInvalidFilenameChars(rvaVarsToReplace[i].lptzValue); dat.cbSize = sizeof( dat ); dat.dwFlags = RVF_TCHAR; dat.variables = rvaVarsToReplace; dat.hContact = hContact; TCHAR* result = ( TCHAR* )CallService( MS_UTILS_REPLACEVARS, (WPARAM)szTemp, (LPARAM)&dat ); if ( result ) { _tcsncpy( szTemp, result, SIZEOF(szTemp)); mir_free( result ); for (int i=0; i < (SIZEOF(rvaVarsToReplace)-1);i++) mir_free(rvaVarsToReplace[i].lptzValue); } } if (patchVars) patchDir( szTemp, SIZEOF(szTemp)); RemoveInvalidPathChars(szTemp); lstrcpyn( szDir, szTemp, cchDir ); }
void MSNAccount::RemoveEntry (QObject *entryObj) { auto entry = qobject_cast<MSNBuddyEntry*> (entryObj); if (!entry) { qWarning () << Q_FUNC_INFO << "invalid entry" << entryObj; return; } const auto& id = ZheetUtil::ToStd (entry->GetContactID ()); const auto& pass = ZheetUtil::ToStd (entry->GetHumanReadableID ()); Conn_->delFromAddressBook (id, pass); }
void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOOL patchVars) { TCHAR tszTemp[MAX_PATH]; ptrT tszRecvPath(db_get_tsa(NULL, "SRFile", "RecvFilesDirAdv")); if (tszRecvPath) _tcsncpy_s(tszTemp, tszRecvPath, _TRUNCATE); else mir_sntprintf(tszTemp, _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files")); if (hContact) { hContact = db_mc_tryMeta(hContact); REPLACEVARSARRAY rvaVarsToReplace[4]; rvaVarsToReplace[0].key.t = _T("nick"); rvaVarsToReplace[0].value.t = mir_tstrdup((TCHAR *)pcli->pfnGetContactDisplayName(hContact, 0)); rvaVarsToReplace[1].key.t = _T("userid"); rvaVarsToReplace[1].value.t = GetContactID(hContact); rvaVarsToReplace[2].key.t = _T("proto"); rvaVarsToReplace[2].value.t = mir_a2t(GetContactProto(hContact)); rvaVarsToReplace[3].key.t = NULL; rvaVarsToReplace[3].value.t = NULL; for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) RemoveInvalidFilenameChars(rvaVarsToReplace[i].value.t); TCHAR *result = Utils_ReplaceVarsT(tszTemp, hContact, rvaVarsToReplace); if (result) { _tcsncpy(tszTemp, result, _countof(tszTemp)); mir_free(result); for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++) mir_free(rvaVarsToReplace[i].value.t); } } if (patchVars) patchDir(tszTemp, _countof(tszTemp)); RemoveInvalidPathChars(tszTemp); mir_tstrncpy(szDir, tszTemp, cchDir); }
MCONTACT GetContactFromID(TCHAR *szID, char *szProto) { TCHAR dispName[1024]; char cProtocol[256]; char *tmp; int found = 0; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { GetContactProto(hContact, cProtocol, sizeof(cProtocol)); TCHAR *szHandle = GetContactID(hContact, cProtocol); tmp = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0); STRNCPY(dispName, tmp, sizeof(dispName)); if ((szHandle) && ((_tcsicmp(szHandle, szID) == 0) || (_tcsicmp(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0))) found = 1; free(szHandle); if (found) return hContact; } return NULL; }
TCHAR* GetContactID(MCONTACT hContact) { return GetContactID(hContact, GetContactProto(hContact)); }
TCHAR *GetContactID(HANDLE hContact) { return GetContactID(hContact, GetContactProto(hContact)); }
static __forceinline TCHAR* GetContactIDX(const TCHAR*, MCONTACT hContact) { return GetContactID(hContact); }