static INT_PTR ReloadFont(WPARAM wParam, LPARAM lParam) { FontIDT fi = {0}; fi.cbSize = sizeof(fi); lstrcpyn(fi.group, TranslateT("Voice Calls"), MAX_REGS(fi.group)); font_max_height = 0; for (int i = 0; i < NUM_FONTS; i++) { if (fonts[i] != 0) DeleteObject(fonts[i]); lstrcpyn(fi.name, stateNames[i], MAX_REGS(fi.name)); LOGFONT log_font = {0}; font_colors[i] = CallService(MS_FONT_GETT, (WPARAM) &fi, (LPARAM) &log_font); fonts[i] = CreateFontIndirect(&log_font); font_max_height = max(font_max_height, log_font.lfHeight); } if (hwnd_frame != NULL) PostMessage(hwnd_frame, WMU_REFRESH, 0, 0); return 0; }
static void SetExtraIcons(HANDLE hContact) { if (hContact == NULL) return; char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (IsEmpty(proto)) return; for (unsigned int i = 0; i < MAX_REGS(infos); ++i) { Info &info = infos[i]; bool show = false; for (unsigned int j = 0; !show && j < MAX_REGS(info.db); j += 2) { if (info.db[j + 1] == NULL) break; DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(hContact, info.db[j] == NULL ? proto : info.db[j], info.db[j+1], &dbv)) { if (!IsEmpty(dbv.pszVal)) { info.SetIcon(hContact, &info, dbv.pszVal); show = true; } DBFreeVariant(&dbv); } } } }
void VoiceCall::AppendCallerID(HANDLE aHContact, const TCHAR *aName, const TCHAR *aNumber) { bool changed = false; if (aHContact != NULL) { hContact = aHContact; changed = true; } if (!IsEmpty(aName)) { lstrcpyn(name, aName, MAX_REGS(name)); changed = true; } if (!IsEmpty(aNumber)) { lstrcpyn(number, aNumber, MAX_REGS(number)); changed = true; } if (changed) CreateDisplayName(); }
TCHAR *GetProtoName(struct ClcContact *item) { PROTOACCOUNT *acc; #ifdef UNICODE char description[128]; #endif proto_name[0] = '\0'; if (item->hContact == NULL || item->proto == NULL) { lstrcpyn(proto_name, TranslateT("Unknown Protocol"), MAX_REGS(proto_name)); return proto_name; } acc = ProtoGetAccount(item->proto); if (acc == NULL) { #ifdef UNICODE CallProtoService(item->proto, PS_GETNAME, sizeof(description),(LPARAM) description); mir_sntprintf(proto_name, MAX_REGS(proto_name), L"%S", description); #else CallProtoService(item->proto, PS_GETNAME, sizeof(proto_name),(LPARAM) proto_name); #endif return proto_name; } lstrcpyn(proto_name, acc->tszAccountName, MAX_REGS(proto_name)); return proto_name; }
void loadCustomDict() { TCHAR filename[1024]; mir_sntprintf(filename, MAX_REGS(filename), _T("%s\\%s.cdic"), userPath, language); FILE *file = _tfopen(filename, _T("rb")); if (file != NULL) { char tmp[1024]; char c; int pos = 0; while((c = fgetc(file)) != EOF) { if (c == '\n' || c == '\r' || pos >= MAX_REGS(tmp) - 1) { if (pos > 0) { tmp[pos] = '\0'; hunspell->add(tmp); } pos = 0; } else { tmp[pos] = c; pos ++; } } fclose(file); } }
COLORREF mir_color_get(TCHAR *group, TCHAR *name) { ColourIDT cid = {0}; cid.cbSize = sizeof(cid); lstrcpyn(cid.group, group, MAX_REGS(cid.group)); lstrcpyn(cid.name, name, MAX_REGS(cid.name)); return (COLORREF) CallService(MS_COLOUR_GETT, (WPARAM) &cid, 0); }
static int ModulesLoaded(WPARAM wParam, LPARAM lParam) { mir_sntprintf(basedir, MAX_REGS(basedir), _T("%s\\Avatars History"), profilePath); hFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("Avatar History"), PROFILE_PATHT _T("\\") CURRENT_PROFILET _T("\\Avatars History")); InitPopups(); if (ServiceExists(MS_MC_GETPROTOCOLNAME)) metacontacts_proto = (char *) CallService(MS_MC_GETPROTOCOLNAME, 0, 0); // updater plugin support if(ServiceExists(MS_UPDATE_REGISTER)) { Update upd = {0}; char szCurrentVersion[30]; upd.cbSize = sizeof(upd); upd.szComponentName = pluginInfo.shortName; upd.szUpdateURL = UPDATER_AUTOREGISTER; upd.szBetaVersionURL = "http://code.google.com/p/pescuma/downloads/list?q=label:Plugin-AVH"; upd.szBetaChangelogURL = "http://code.google.com/p/pescuma/source/list"; #ifdef _WIN64 upd.pbBetaVersionPrefix = (BYTE *) "Avatar History (x64) "; upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/avatarhistW.%VERSION%-x64.zip"; #elif _UNICODE upd.pbBetaVersionPrefix = (BYTE *) "Avatar History (Unicode) "; upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/avatarhistW.%VERSION%.zip"; #else upd.pbBetaVersionPrefix = (BYTE *) "Avatar History (ANSI) "; upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/avatarhist.%VERSION%.zip"; #endif upd.cpbBetaVersionPrefix = (int) strlen((char *)upd.pbBetaVersionPrefix); upd.pbVersion = (BYTE *)CreateVersionStringPluginEx(&pluginInfo, szCurrentVersion); upd.cpbVersion = (int) strlen((char *)upd.pbVersion); CallService(MS_UPDATE_REGISTER, 0, (LPARAM)&upd); } if (DBGetContactSettingByte(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) { char *templates[] = { "Avatar change\nchanged his/her avatar", "Avatar removal\nremoved his/her avatar" }; HICON hIcon = createDefaultOverlayedIcon(FALSE); HistoryEvents_RegisterWithTemplates(MODULE_NAME, "avatarchange", "Avatar change", EVENTTYPE_AVATAR_CHANGE, hIcon, HISTORYEVENTS_FORMAT_CHAR | HISTORYEVENTS_FORMAT_WCHAR | HISTORYEVENTS_FORMAT_RICH_TEXT, HISTORYEVENTS_FLAG_SHOW_IM_SRMM | HISTORYEVENTS_FLAG_EXPECT_CONTACT_NAME_BEFORE, GetHistoryEventText, templates, MAX_REGS(templates)); DestroyIcon(hIcon); } hHooks[2] = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged); return 0; }
void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_path, TCHAR *source) { // Load the language files and create an array with then TCHAR file[1024]; mir_sntprintf(file, MAX_REGS(file), _T("%s\\*.dic"), path); BOOL found = FALSE; WIN32_FIND_DATA ffd = {0}; HANDLE hFFD = FindFirstFile(file, &ffd); if (hFFD != INVALID_HANDLE_VALUE) { do { mir_sntprintf(file, MAX_REGS(file), _T("%s\\%s"), path, ffd.cFileName); // Check .dic DWORD attrib = GetFileAttributes(file); if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY)) continue; // See if .aff exists too lstrcpy(&file[lstrlen(file) - 4], _T(".aff")); attrib = GetFileAttributes(file); if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY)) continue; ffd.cFileName[lstrlen(ffd.cFileName)-4] = _T('\0'); TCHAR *lang = ffd.cFileName; // Replace - for _ int i; for(i = 0; i < lstrlen(lang); i++) if (lang[i] == _T('-')) lang[i] = _T('_'); // Check if dict is new BOOL exists = FALSE; for(i = 0; i < dicts.getCount() && !exists; i++) if (lstrcmp(dicts[i]->language, lang) == 0) exists = TRUE; if (!exists) { found = TRUE; file[lstrlen(file) - 4] = _T('\0'); dicts.insert(new HunspellDictionary(lang, file, user_path, source)); } } while(FindNextFile(hFFD, &ffd)); FindClose(hFFD); } }
HFONT mir_font_get(TCHAR *group, TCHAR *name, COLORREF *color) { LOGFONT lf = {0}; FontIDT font = {0}; font.cbSize = sizeof(font); lstrcpyn(font.group, group, MAX_REGS(font.group)); lstrcpyn(font.name, name, MAX_REGS(font.name)); COLORREF tmp = (COLORREF) CallService(MS_FONT_GETT, (WPARAM) &font, (LPARAM) &lf); if (color != NULL) *color = tmp; return CreateFontIndirect(&lf); }
// To get the names of the languages BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { TCHAR *stopped = NULL; USHORT langID = (USHORT) _tcstol(lpLocaleString, &stopped, 16); TCHAR ini[32]; TCHAR end[32]; GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, MAX_REGS(ini)); GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO3166CTRYNAME, end, MAX_REGS(end)); TCHAR name[64]; mir_sntprintf(name, MAX_REGS(name), _T("%s_%s"), ini, end); for(int i = 0; i < tmp_dicts->getCount(); i++) { Dictionary *dict = (*tmp_dicts)[i]; if (lstrcmpi(dict->language, name) == 0) { #define LOCALE_SLOCALIZEDLANGUAGENAME 0x0000006f #define LOCALE_SNATIVEDISPLAYNAME 0x00000073 GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, MAX_REGS(dict->english_name)); GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLANGUAGE, dict->localized_name, MAX_REGS(dict->localized_name)); if (dict->localized_name[0] == 0) GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLOCALIZEDLANGUAGENAME, dict->localized_name, MAX_REGS(dict->localized_name)); if (dict->localized_name[0] == 0) GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, MAX_REGS(dict->localized_name)); if (dict->localized_name[0] == 0 && dict->english_name[0] != 0) { TCHAR country[1024]; GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, MAX_REGS(country)); TCHAR name[1024]; if (country[0] != 0) mir_sntprintf(name, MAX_REGS(name), _T("%s (%s)"), dict->english_name, country); else lstrcpyn(name, dict->english_name, MAX_REGS(name)); lstrcpyn(dict->localized_name, TranslateTS(name), MAX_REGS(dict->localized_name)); } if (dict->localized_name[0] != 0) { mir_sntprintf(dict->full_name, MAX_REGS(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language); } break; } } return TRUE; }
static int SettingChanged(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE) wParam; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*) lParam; if (hContact == NULL) return 0; char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (IsEmpty(proto)) return 0; bool isProto = (strcmp(cws->szModule, proto) == 0); if (isProto && strcmp(cws->szSetting, "ApparentMode") == 0) { SetVisibility(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.wVal, TRUE); return 0; } if (strcmp(cws->szSetting, "Gender") == 0 && (isProto || strcmp(cws->szModule, "UserInfo") == 0)) { SetGender(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.bVal, TRUE); return 0; } for (unsigned int i = 0; i < MAX_REGS(infos); ++i) { Info &info = infos[i]; for (unsigned int j = 0; j < MAX_REGS(info.db); j += 2) { if (info.db[j + 1] == NULL) break; if (info.db[j] == NULL && !isProto) continue; if (info.db[j] != NULL && strcmp(cws->szModule, info.db[j])) continue; if (strcmp(cws->szSetting, info.db[j + 1])) continue; bool show = (cws->value.type != DBVT_DELETED && !IsEmpty(cws->value.pszVal)); info.SetIcon(hContact, &info, show ? cws->value.pszVal : NULL); break; } } return 0; }
static int PreShutdown(WPARAM wParam, LPARAM lParam) { int i; for (i = 0; i < MAX_REGS(hHooks); i++) UnhookEvent(hHooks[i]); for (i = 0; i < MAX_REGS(hServices); i++) DestroyServiceFunction(hServices[i]); WindowList_Broadcast(hAvatarWindowsList,WM_CLOSE,0,0); return 0; }
void GetDictsInfo(LIST<Dictionary> &dicts) { tmp_dicts = &dicts; EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED); // Try to get name from DB for(int i = 0; i < dicts.getCount(); i++) { Dictionary *dict = dicts[i]; if (dict->full_name[0] == _T('\0')) { DBVARIANT dbv; #ifdef UNICODE char lang[128]; WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), NULL, NULL); if (!DBGetContactSettingTString(NULL, MODULE_NAME, lang, &dbv)) #else if (!DBGetContactSettingTString(NULL, MODULE_NAME, dict->language, &dbv)) #endif { lstrcpyn(dict->localized_name, dbv.ptszVal, MAX_REGS(dict->localized_name)); DBFreeVariant(&dbv); } if (dict->localized_name[0] == _T('\0')) { for(size_t j = 0; j < MAX_REGS(aditionalLanguages); j+=2) { if (lstrcmp(aditionalLanguages[j], dict->language) == 0) { lstrcpyn(dict->localized_name, aditionalLanguages[j+1], MAX_REGS(dict->localized_name)); break; } } } if (dict->localized_name[0] != _T('\0')) { mir_sntprintf(dict->full_name, MAX_REGS(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language); } else { lstrcpyn(dict->full_name, dict->language, MAX_REGS(dict->full_name)); } } } }
void GetTemplate(Buffer<TCHAR> *buffer, SPEAK_TYPE *type, int templ) { DBVARIANT dbv; char setting[128]; mir_snprintf(setting, MAX_REGS(setting), "%s_%d_" TEMPLATE_TEXT, type->name, templ); if (!DBGetContactSettingTString(NULL, type->module == NULL ? MODULE_NAME : type->module, setting, &dbv)) { buffer->append(dbv.ptszVal); DBFreeVariant(&dbv); } else { // Get default const char *tmp = type->templates[templ]; tmp = strchr(tmp, '\n'); if (tmp == NULL) return; tmp++; const char *end = strchr(tmp, '\n'); size_t len = (end == NULL ? strlen(tmp) : end - tmp); #ifdef UNICODE MultiByteToWideChar(CP_ACP, 0, tmp, len, buffer->appender(len), len); #else buffer->append(tmp, len); #endif } }
HFONT EmoticonsSelectionLayout::GetFont(HDC hdc) { HFONT hFont; if (ssd->hwndTarget != NULL) { CHARFORMAT2 cf; ZeroMemory(&cf, sizeof(cf)); cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_ITALIC | CFM_CHARSET | CFM_FACE | CFM_WEIGHT | CFM_SIZE; SendMessage(ssd->hwndTarget, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf); LOGFONT lf = {0}; lf.lfHeight = -MulDiv(cf.yHeight / 20, GetDeviceCaps(hdc, LOGPIXELSY), 72); lf.lfWeight = cf.wWeight; lf.lfItalic = (cf.dwEffects & CFE_ITALIC) == CFE_ITALIC; lf.lfCharSet = cf.bCharSet; lf.lfPitchAndFamily = cf.bPitchAndFamily; lstrcpyn(lf.lfFaceName, cf.szFaceName, MAX_REGS(lf.lfFaceName)); hFont = CreateFontIndirect(&lf); } else { hFont = (HFONT) SendMessage(hwnd, WM_GETFONT, 0, 0); } return hFont; }
// Return a list of auto suggestions to a word virtual Suggestions autoSuggest(const TCHAR * word) { Suggestions ret = {0}; load(); if (loaded != LANGUAGE_LOADED) return ret; char hunspell_word[1024]; toHunspell(hunspell_word, word, MAX_REGS(hunspell_word)); char ** words; int count = hunspell->suggest_auto(&words, hunspell_word); if (count <= 0) return ret; // Oki, lets make our array ret.count = count; ret.words = (TCHAR **) malloc(ret.count * sizeof(TCHAR *)); for (int i = 0; i < count; i++) { ret.words[i] = fromHunspell(words[i]); free(words[i]); } free(words); return ret; }
// Return a list of suggestions to a word virtual Suggestions suggest(const TCHAR * word) { Suggestions ret = {0}; load(); if (loaded != LANGUAGE_LOADED) return ret; char hunspell_word[1024]; toHunspell(hunspell_word, word, MAX_REGS(hunspell_word)); char ** words = NULL; ret.count = hunspell->suggest(&words, hunspell_word); if (ret.count > 0) { // Oki, lets make our array ret.words = (TCHAR **) malloc(ret.count * sizeof(TCHAR *)); for (unsigned i = 0; i < ret.count; i++) { ret.words[i] = fromHunspell(words[i]); free(words[i]); } } if (words != NULL) free(words); return ret; }
ExtraIconGroup::ExtraIconGroup(const char *name) : ExtraIcon(name), setValidExtraIcon(false), insideApply(false) { char setting[512]; mir_snprintf(setting, MAX_REGS(setting), "%s/%s", MODULE_NAME, name); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (WPARAM) setting); }
void Notify(HANDLE hContact, TCHAR *text) { if (text != NULL && text[0] == _T('\0')) text = NULL; if (!opts.track_changes && text != NULL) return; if (!opts.track_removes && text == NULL) return; // Replace template with nick TCHAR templ[1024]; lstrcpyn(templ, text == NULL ? opts.template_removed : opts.template_changed, MAX_REGS(templ)); ReplaceChars(templ); TCHAR log[1024]; mir_sntprintf(log, sizeof(log), templ, text == NULL ? TranslateT("<no nickname>") : text); if (opts.history_enable) HistoryLog(hContact, log); if (opts.popup_enable) ShowPopup(hContact, NULL, log); }
void FreeTypes() { // Destroy services int i; for(i = 0; i < MAX_REGS(hServices); ++i) DestroyServiceFunction(hServices[i]); // Free internal structs for(i = 0; i < types.getCount(); i++) { SPEAK_TYPE *type = types[i]; mir_free((void *) type->module); mir_free((void *) type->name); mir_free((void *) type->icon); if (type->numTemplates > 0) { for(int i = 0; i < type->numTemplates; i++) mir_free((void *) type->templates[i]); mir_free(type->templates); } mir_free(type); } types.destroy(); }
static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) { Info *info = (Info *) param; if (info == NULL) return 0; HANDLE hContact = (HANDLE) wParam; if (hContact == NULL) return 0; char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (IsEmpty(proto)) return 0; bool found = false; for (unsigned int j = 0; !found && j < MAX_REGS(info->db); j += 2) { if (info->db[j + 1] == NULL) break; DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(hContact, info->db[j] == NULL ? proto : info->db[j], info->db[j+1], &dbv)) { if (!IsEmpty(dbv.ptszVal)) { info->OnClick(info, dbv.ptszVal); found = true; } DBFreeVariant(&dbv); } } return 0; }
static void DBExtraIconsInit() { hExtraChat = ExtraIcon_Register("chat_activity", "Chat activity", "ChatActivity"); hExtraVisibility = ExtraIcon_Register("visibility", "Visibility", "AlwaysVis"); hExtraGender = ExtraIcon_Register("gender", "Gender", "gender_male"); for (unsigned int i = 0; i < MAX_REGS(infos); ++i) { Info &info = infos[i]; if (info.OnClick) info.hExtraIcon = ExtraIcon_Register(info.name, info.desc, info.icon, DefaultOnClick, (LPARAM) &info); else info.hExtraIcon = ExtraIcon_Register(info.name, info.desc, info.icon); } HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { SetExtraIcons(hContact); SetVisibility(hContact, -1, FALSE); SetGender(hContact, -1, FALSE); hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); } hHooks.push_back(HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged)); }
void appendToCustomDict(const TCHAR *word) { CreatePath(userPath); TCHAR filename[1024]; mir_sntprintf(filename, MAX_REGS(filename), _T("%s\\%s.cdic"), userPath, language); FILE *file = _tfopen(filename, _T("ab")); if (file != NULL) { char tmp[1024]; toHunspell(tmp, word, MAX_REGS(tmp)); fprintf(file, "%s\n", tmp); fclose(file); } }
static BOOL CALLBACK TestDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); TCHAR text[1024]; mir_sntprintf(text, MAX_REGS(text), TranslateT("UDP: %s : %d\nTCP: %s : %d\nTLS: %s : %d"), cli->udp_host, cli->udp_port, cli->tcp_host, cli->tcp_port, cli->tls_host, cli->tls_port); SendDlgItemMessage(hwndDlg, IDC_DATA, WM_SETTEXT, 0, (LPARAM) text); SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM) _T("UDP")); SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM) _T("TCP")); SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM) _T("TLS")); SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_SETCURSEL, 0, 0); return TRUE; } case WM_COMMAND: { switch(wParam) { case IDC_CALL: { TCHAR host[512]; GetDlgItemText(hwndDlg, IDC_HOST, host, MAX_REGS(host)); int port = GetDlgItemInt(hwndDlg, IDC_PORT, NULL, TRUE); int protocol = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_GETCURSEL, 0, 0) + 1; int callId = cli->Call(cli, host, port, protocol); if (callId < 0) MessageBox(NULL, _T("Error making call"), _T("SIP_CLI"), MB_OK | MB_ICONERROR); break; } } break; } } return FALSE; }
CallingMethod(VoiceProvider *provider, HANDLE hContact, const TCHAR *number = NULL) : provider(provider), hContact(hContact) { if (number == NULL) this->number[0] = 0; else lstrcpyn(this->number, number, MAX_REGS(this->number)); }
static void LoadGroups(vector<ExtraIconGroup *> &groups) { unsigned int count = DBGetContactSettingWord(NULL, MODULE_NAME "Groups", "Count", 0); for (unsigned int i = 0; i < count; ++i) { char setting[512]; mir_snprintf(setting, MAX_REGS(setting), "%d_count", i); unsigned int items = DBGetContactSettingWord(NULL, MODULE_NAME "Groups", setting, 0); if (items < 1) continue; mir_snprintf(setting, MAX_REGS(setting), "__group_%d", i); ExtraIconGroup *group = new ExtraIconGroup(setting); for (unsigned int j = 0; j < items; ++j) { mir_snprintf(setting, MAX_REGS(setting), "%d_%d", i, j); DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(NULL, MODULE_NAME "Groups", setting, &dbv)) { if (!IsEmpty(dbv.pszVal)) { BaseExtraIcon *extra = GetExtraIconByName(dbv.pszVal); if (extra != NULL) { group->items.push_back(extra); if (extra->getSlot() >= 0) group->setSlot(extra->getSlot()); } } DBFreeVariant(&dbv); } } if (group->items.size() < 2) { delete group; continue; } groups.push_back(group); } }
void SkinnedDialog::trace(TCHAR *msg, ...) { if (traceCallback == NULL) return; TCHAR buff[1024]; memset(buff, 0, sizeof(buff)); va_list args; va_start(args, msg); _vsntprintf(buff, MAX_REGS(buff) - 1, msg, args); buff[MAX_REGS(buff) - 1] = 0; va_end(args); traceCallback(traceCallbackParam, buff); }
static INT_PTR ReloadColor(WPARAM wParam, LPARAM lParam) { ColourIDT ci = {0}; ci.cbSize = sizeof(ci); lstrcpyn(ci.group, TranslateT("Voice Calls"), MAX_REGS(ci.group)); lstrcpyn(ci.name, TranslateT("Background"), MAX_REGS(ci.name)); bkg_color = CallService(MS_COLOUR_GETT, (WPARAM) &ci, 0); if (bk_brush != NULL) DeleteObject(bk_brush); bk_brush = CreateSolidBrush(bkg_color); if (hwnd_frame != NULL) InvalidateRect(hwnd_frame, NULL, TRUE); return 0; }
void AutoReplaceMap::loadAutoReplaceMap() { FILE *file = _tfopen(filename, _T("rb")); if (file == NULL) return; char tmp[1024]; char c; int pos = 0; while((c = fgetc(file)) != EOF) { if (c == '\n' || c == '\r' || pos >= MAX_REGS(tmp) - 1) { if (pos > 0) { tmp[pos] = '\0'; // Get from BOOL useVars; char *p; if ((p = strstr(tmp, "->")) != NULL) { *p = '\0'; p += 2; useVars = FALSE; } else if ((p = strstr(tmp, "-V>")) != NULL) { *p = '\0'; p += 3; useVars = TRUE; } if (p != NULL) { Utf8ToTchar find(tmp); Utf8ToTchar replace(p); lstrtrim(find); lstrtrim(replace); if (find[0] != 0 && replace[0] != 0) replacements[find.get()] = AutoReplacement(replace, useVars); } } pos = 0; } else { tmp[pos] = c; pos ++; } } fclose(file); }
void VoiceCall::Notify(bool history, bool popup, bool sound, bool clist) { if (history) { TCHAR *variables[] = { _T("number"), displayName }; HistoryEvents_AddToHistoryVars(hContact, EVENTTYPE_VOICE_CALL, state, variables, MAX_REGS(variables), DBEF_READ | (incoming ? 0 : DBEF_SENT)); } if (popup) { TCHAR text[512]; mir_sntprintf(text, MAX_REGS(text), TranslateTS(stateTexts[state]), displayName); ShowPopup(NULL, TranslateTS(popupTitles[state]), text); } if (sound) SkinPlaySound(sounds[state].name); if (clist && state == VOICE_STATE_RINGING) { HICON hIcon = IcoLib_LoadIcon(stateIcons[VOICE_STATE_RINGING]); CLISTEVENT ce = {0}; ce.cbSize = sizeof(ce); ce.hContact = hContact; ce.hIcon = hIcon; ce.hDbEvent = (HANDLE) this; ce.pszService = MS_VOICESERVICE_CLIST_DBLCLK; ce.lParam = (LPARAM) this; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) &ce); IcoLib_ReleaseIcon(hIcon); clistBlinking = true; } if (hwnd_frame != NULL) PostMessage(hwnd_frame, WMU_REFRESH, 0, 0); }