PWumf new_wumf( DWORD dwID, LPTSTR szUser, LPTSTR szPath, LPTSTR szComp, LPTSTR szUNC, DWORD dwSess, DWORD dwPerm, DWORD dwAttr) { PWumf w = (PWumf)mir_calloc(sizeof(Wumf)); if (!w) return NULL; w->szUser = mir_tstrdup(szUser); w->szPath = mir_tstrdup(szPath); w->szComp = mir_tstrdup(szComp); w->szUNC = mir_tstrdup(szUNC); switch(dwPerm) { case PERM_FILE_READ: mir_tstrcpy(w->szPerm, _T("Read"));break; case PERM_FILE_WRITE: mir_tstrcpy(w->szPerm, _T("Write"));break; case PERM_FILE_CREATE: mir_tstrcpy(w->szPerm, _T("Create"));break; default: mir_tstrcpy(w->szPerm, _T("Execute")); } mir_sntprintf(w->szID, _countof(w->szID), _T("%i"), dwID); w->dwID = dwID; w->dwSess = dwSess; w->dwAttr = dwAttr; w->dwPerm = dwPerm; w->mark = FALSE; w->next = NULL; return w; }
static BOOL EnumProfilesForList(TCHAR *tszFullPath, TCHAR *profile, LPARAM lParam) { ProfileEnumData *ped = (ProfileEnumData*)lParam; CCtrlListView &list = ped->list; TCHAR sizeBuf[64]; bool bFileLocked = true; TCHAR *p = _tcsrchr(profile, '.'); mir_tstrcpy(sizeBuf, _T("0 KB")); if (p != NULL) *p = 0; LVITEM item = { 0 }; item.mask = LVIF_TEXT | LVIF_IMAGE; item.pszText = profile; item.iItem = 0; struct _stat statbuf; if (_tstat(tszFullPath, &statbuf) == 0) { if (statbuf.st_size > 1000000) { mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); mir_tstrcpy(sizeBuf + 5, _T(" MB")); } else { mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); mir_tstrcpy(sizeBuf + 5, _T(" KB")); } bFileLocked = !fileExist(tszFullPath); } DATABASELINK *dblink; switch (touchDatabase(tszFullPath, &dblink)) { case ERROR_SUCCESS: item.iImage = bFileLocked; break; case EGROKPRF_OBSOLETE: item.iImage = 2; break; default: item.iImage = 3; } int iItem = list.InsertItem(&item); if (mir_tstrcmpi(ped->szProfile, tszFullPath) == 0) list.SetItemState(iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); list.SetItemText(iItem, 2, sizeBuf); if (dblink != NULL) { if (bFileLocked) // file locked list.SetItemText(iItem, 1, TranslateT("<In use>")); else list.SetItemText(iItem, 1, TranslateTS(dblink->szFullName)); } else list.SetItemText(iItem, 1, TranslateT("<Unknown format>")); return TRUE; }
void CConfig::LoadFontSettings(int iFont) { if (iFont > FONT_SETTINGS - 1 || iFont < 0) return; char szSetting[128]; // Fixed Values m_logfont[iFont].lfOutPrecision = OUT_DEFAULT_PRECIS; m_logfont[iFont].lfClipPrecision = CLIP_DEFAULT_PRECIS; m_logfont[iFont].lfQuality = DEFAULT_QUALITY; m_logfont[iFont].lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; // Height mir_snprintf(szSetting, "Font%dHeight", iFont); m_logfont[iFont].lfHeight = (char)db_get_b(NULL, "MirandaG15", szSetting, -MulDiv(6, 96, 72)); // Style mir_snprintf(szSetting, "Font%dStyle", iFont); int style = db_get_b(NULL, "MirandaG15", szSetting, 0); m_logfont[iFont].lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL; m_logfont[iFont].lfItalic = style & FONTF_ITALIC ? 1 : 0; // Charset mir_snprintf(szSetting, "Font%dCharset", iFont); m_logfont[iFont].lfCharSet = db_get_b(NULL, "MirandaG15", szSetting, DEFAULT_CHARSET); // Name mir_snprintf(szSetting, "Font%dName", iFont); DBVARIANT dbv; if (db_get_ts(NULL, "MirandaG15", szSetting, &dbv)) mir_tstrcpy(m_logfont[iFont].lfFaceName, _T("Small Fonts")); else { mir_tstrcpy(m_logfont[iFont].lfFaceName, dbv.ptszVal); db_free(&dbv); } UpdateFontSettings(iFont); }
void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data) { TCHAR str[MAX_DATA_LEN]; // convert the unit if (mir_tstrcmp(Data, TranslateT("<Error>")) && mir_tstrcmp(Data, NODATA) && mir_tstrcmp(Data, TranslateTS(NODATA))) { // temperature if (!mir_tstrcmp(UpdateData->Name, _T("Temperature")) || !mir_tstrcmp(UpdateData->Name, _T("High")) || !mir_tstrcmp(UpdateData->Name, _T("Low")) || !mir_tstrcmp(UpdateData->Name, _T("Feel")) || !mir_tstrcmp(UpdateData->Name, _T("Dewpoint")) || !mir_tstrcmpi(UpdateData->Unit, _T("C")) || !mir_tstrcmpi(UpdateData->Unit, _T("F")) || !mir_tstrcmpi(UpdateData->Unit, _T("K"))) { GetTemp(Data, UpdateData->Unit, str); mir_tstrcpy(Data, str); } // pressure else if (!mir_tstrcmp(UpdateData->Name, _T("Pressure")) || !mir_tstrcmpi(UpdateData->Unit, _T("HPA")) || !mir_tstrcmpi(UpdateData->Unit, _T("KPA")) || !mir_tstrcmpi(UpdateData->Unit, _T("MB")) || !mir_tstrcmpi(UpdateData->Unit, _T("TORR")) || !mir_tstrcmpi(UpdateData->Unit, _T("IN")) || !mir_tstrcmpi(UpdateData->Unit, _T("MM"))) { GetPressure(Data, UpdateData->Unit, str); mir_tstrcpy(Data, str); } // speed else if (!mir_tstrcmp(UpdateData->Name, _T("Wind Speed")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM/H")) || !mir_tstrcmpi(UpdateData->Unit, _T("M/S")) || !mir_tstrcmpi(UpdateData->Unit, _T("MPH")) || !mir_tstrcmpi(UpdateData->Unit, _T("KNOTS"))) { GetSpeed(Data, UpdateData->Unit, str); mir_tstrcpy(Data, str); } // visibility else if (!mir_tstrcmp(UpdateData->Name, _T("Visibility")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM")) || !mir_tstrcmpi(UpdateData->Unit, _T("MILES"))) { GetDist(Data, UpdateData->Unit, str); mir_tstrcpy(Data, str); } // elevation else if (!mir_tstrcmp(UpdateData->Name, _T("Elevation")) || !mir_tstrcmpi(UpdateData->Unit, _T("FT")) || !mir_tstrcmpi(UpdateData->Unit, _T("M"))) { GetElev(Data, UpdateData->Unit, str); mir_tstrcpy(Data, str); } // converting case for condition to the upper+lower format else if (!mir_tstrcmpi(UpdateData->Unit, _T("COND"))) CaseConv(Data); // degree sign else if (!mir_tstrcmpi(UpdateData->Unit, _T("DEG"))) { if (!opt.DoNotAppendUnit) mir_tstrcat(Data, opt.DegreeSign); } // percent sign else if (!mir_tstrcmpi(UpdateData->Unit, _T("%"))) { if (!opt.DoNotAppendUnit) mir_tstrcat(Data, _T("%")); } // truncating strings for day/month to 2 or 3 characters else if (!mir_tstrcmpi(UpdateData->Unit, _T("DAY")) || !mir_tstrcmpi(UpdateData->Unit, _T("MONTH"))) if (opt.dUnit > 1 && mir_tstrlen(Data) > opt.dUnit) Data[opt.dUnit] = '\0'; } }
static INT_PTR CALLBACK DlgProcWaMpdOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); SetDlgItemInt(hwndDlg, IDC_PORT, db_get_w(NULL, szModuleName, "Port", 6600), FALSE); TCHAR *tmp = UniGetContactSettingUtf(NULL, szModuleName, "Server", _T("127.0.0.1")); SetDlgItemText(hwndDlg, IDC_SERVER, tmp); mir_free(tmp); tmp = UniGetContactSettingUtf(NULL, szModuleName, "Password", _T("")); SetDlgItemText(hwndDlg, IDC_PASSWORD, tmp); mir_free(tmp); return TRUE; } case WM_COMMAND: { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { TCHAR szText[256]; db_set_w(NULL, szModuleName, "Port", (WORD)GetDlgItemInt(hwndDlg, IDC_PORT, NULL, FALSE)); gbPort = (WORD)GetDlgItemInt(hwndDlg, IDC_PORT, NULL, FALSE); GetDlgItemText(hwndDlg, IDC_SERVER, szText, _countof(szText)); db_set_ts(NULL, szModuleName, "Server", szText); mir_tstrcpy(gbHost, szText); GetDlgItemText(hwndDlg, IDC_PASSWORD, szText, _countof(szText)); db_set_ts(NULL, szModuleName, "Password", szText); mir_tstrcpy(gbPassword, szText); return TRUE; } } } break; } return FALSE; }
void DeleteJob::run() { char szError[1024]; CURL *hCurl = curl_easy_init(); if (hCurl) { struct curl_slist *headerList = NULL; headerList = curl_slist_append(headerList, getDelFileString()); Utils::curlSetOpt(hCurl, this->ftp, getDelUrlString(), headerList, szError); int result = curl_easy_perform(hCurl); if (result == CURLE_OK) { if (manDlg != NULL && this->treeItem) this->treeItem->remove(); else DBEntry::remove(entry->fileID); } else if (manDlg != NULL && this->treeItem) { TCHAR *error = mir_a2t(szError); mir_tstrcpy(this->treeItem->stzToolTip, error); this->treeItem->setState(Manager::TreeItem::_ERROR()); FREE(error); } curl_slist_free_all(headerList); curl_easy_cleanup(hCurl); } }
int AddStatusMode(OPTTREE_OPTION *options, int pos, LPTSTR prefix, DWORD flag) { if (!flag) return pos; options[pos].dwFlag = flag; options[pos].groupId = OPTTREE_CHECK; options[pos].pszOptionName = (LPTSTR)mir_alloc(sizeof(TCHAR) * mir_tstrlen(prefix) + 32); options[pos].pszSettingName = mir_tstrdup(prefix); options[pos].iconIndex = 0; mir_tstrcpy(options[pos].pszOptionName, prefix); mir_tstrcat(options[pos].pszOptionName, _T("/")); switch (flag) { case PF2_IDLE: mir_tstrcat(options[pos].pszOptionName, LPGENT("Offline")); break; case PF2_ONLINE: mir_tstrcat(options[pos].pszOptionName, LPGENT("Online")); break; case PF2_INVISIBLE: mir_tstrcat(options[pos].pszOptionName, LPGENT("Invisible")); break; case PF2_SHORTAWAY: mir_tstrcat(options[pos].pszOptionName, LPGENT("Away")); break; case PF2_LONGAWAY: mir_tstrcat(options[pos].pszOptionName, LPGENT("NA")); break; case PF2_LIGHTDND: mir_tstrcat(options[pos].pszOptionName, LPGENT("Occupied")); break; case PF2_HEAVYDND: mir_tstrcat(options[pos].pszOptionName, LPGENT("DND")); break; case PF2_FREECHAT: mir_tstrcat(options[pos].pszOptionName, LPGENT("Free for chat")); break; case PF2_OUTTOLUNCH: mir_tstrcat(options[pos].pszOptionName, LPGENT("Out to lunch")); break; case PF2_ONTHEPHONE: mir_tstrcat(options[pos].pszOptionName, LPGENT("On the phone")); break; } return pos + 1; }
WORD MTime::DateFormatAlt(LPTSTR ptszTimeFormat, WORD cchTimeFormat) { if (!ptszTimeFormat || !cchTimeFormat) return 0; WORD wRes = DateFormat(ptszTimeFormat, cchTimeFormat); if (wRes != 0) return wRes; SYSTEMTIME AltSysTime = _SysTime; MTime mtNow; mtNow.GetLocalTime(); AltSysTime.wYear=mtNow.Year(); if ((cchTimeFormat = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &AltSysTime, NULL, ptszTimeFormat, cchTimeFormat)) == 0) { *ptszTimeFormat = 0; return 0; } TCHAR tszText[10]; _itot(mtNow.Year(), tszText, 10); TCHAR * tszYear = _tcsstr(ptszTimeFormat, tszText); if (tszYear && mir_tstrlen(tszYear) == 4) mir_tstrcpy(tszYear, _T("????")); else { *ptszTimeFormat = 0; return 0; } return cchTimeFormat; }
static BOOL IsValidRunCommand(const TCHAR *pszRunCmd) { TCHAR *buf,*pexe,*pargs; TCHAR szFullExe[MAX_PATH],*pszFilePart; buf=mir_tstrcpy((TCHAR*)_alloca((mir_tstrlen(pszRunCmd)+1)*sizeof(TCHAR)),pszRunCmd); /* split into executable path and arguments */ if (buf[0]==_T('\"')) { pargs=_tcschr(&buf[1],_T('\"')); if (pargs!=NULL) *(pargs++)=0; pexe=&buf[1]; if (*pargs==_T(' ')) ++pargs; } else { pargs=_tcschr(buf,_T(' ')); if (pargs!=NULL) *pargs=0; pexe=buf; } if (SearchPath(NULL,pexe,_T(".exe"),_countof(szFullExe),szFullExe,&pszFilePart)) { if (pszFilePart!=NULL) if (!mir_tstrcmpi(pszFilePart,_T("rundll32.exe")) || !mir_tstrcmpi(pszFilePart,_T("rundll.exe"))) { /* split into dll path and arguments */ if (pargs[0]==_T('\"')) { ++pargs; pexe=_tcschr(&pargs[1],_T('\"')); if (pexe!=NULL) *pexe=0; } else { pexe=_tcschr(pargs,_T(',')); if (pexe!=NULL) *pexe=0; } return SearchPath(NULL,pargs,_T(".dll"),0,NULL,NULL)!=0; } return TRUE; } return FALSE; }
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; }
// hKey must have been opened with KEY_SET_VALUE access right static void SetRegStrPrefixValue(HKEY hKey,const TCHAR *pszValPrefix,const TCHAR *pszVal) { size_t dwSize = (mir_tstrlen(pszVal)+mir_tstrlen(pszValPrefix)+1)*sizeof(TCHAR); TCHAR *pszStr = (TCHAR*)_alloca(dwSize); mir_tstrcat(mir_tstrcpy(pszStr, pszValPrefix), pszVal); /* buffer safe */ RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE*)pszStr, (int)dwSize); }
static BOOL Opera6_GetIniFilePath(TCHAR *szIniFile) { HKEY hExeKey; TCHAR szPath[MAX_PATH],*p; BOOL fSuccess=FALSE; DWORD len; /* Info: http://opera-info.de/forum/thread.php?threadid=2905 */ /* app path */ if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscape.exe",0,KEY_QUERY_VALUE,&hExeKey)) { /* exe name */ p=GetRegStrValue(hExeKey,NULL); if (p!=NULL && _tcsstr(p,_T("Opera.exe"))!=NULL) { /* path */ mir_free(p); p=GetRegStrValue(hExeKey,_T("Path")); len=mir_tstrlen(p); if (p[len-1]==_T('\\')) p[len-1]=0; fSuccess=(p!=NULL && ExpandEnvironmentStrings(p,szPath,MAX_PATH)); } mir_free(p); /* does NULL check */ RegCloseKey(hExeKey); } if (fSuccess) { TCHAR szFileBuf[MAX_PATH+34]; /* operadef6.ini */ mir_tstrcat(mir_tstrcpy(szFileBuf,szPath),_T("\\operadef6.ini")); /* buffer safe */ /* If enabled Opera will use Windows profiles to store individual user settings */ if (GetPrivateProfileInt(_T("System"),_T("Multi User"),0,szFileBuf)==1) { p=_tcsrchr(szPath,'\\'); mir_tstrcpy(szFileBuf,_T("%APPDATA%\\Opera")); /* buffer safe */ if (p!=NULL) mir_tstrcat(szFileBuf,p); /* buffer safe */ } else mir_tstrcpy(szFileBuf,szPath); /* opera6.ini */ mir_tstrcat(szFileBuf,_T("\\profile\\opera6.ini")); /* buffer safe */ fSuccess=ExpandEnvironmentStrings(szFileBuf,szIniFile,MAX_PATH)!=0; } /* check file existstance */ if (fSuccess) { HANDLE hFile; hFile=CreateFile(szIniFile,0,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); if (hFile==INVALID_HANDLE_VALUE) fSuccess=FALSE; else CloseHandle(hFile); } return fSuccess; }
static INT_PTR ShowGuideFile(WPARAM, LPARAM) { LPTSTR pszDirName = (LPTSTR)mir_alloc(250*sizeof(TCHAR)); LPTSTR pszFileName = (LPTSTR)mir_alloc(250*sizeof(TCHAR)); TCHAR *ptszHelpFile = db_get_tsa(NULL, "UserGuide", "PathToHelpFile"); if (ptszHelpFile==0) { mir_tstrcpy(pszDirName, _T("%miranda_path%\\Plugins")); mir_tstrcpy(pszFileName, _T("UserGuide.chm")); } else { if(!mir_tstrcmp(ptszHelpFile, _T(""))) { mir_tstrcpy(pszDirName, _T("%miranda_path%\\Plugins")); mir_tstrcpy(pszFileName, _T("UserGuide.chm")); } else { LPTSTR pszDivider = _tcsrchr(ptszHelpFile, '\\'); if (pszDivider == NULL) { mir_tstrcpy(pszDirName, _T("")); _tcsncpy(pszFileName, ptszHelpFile, mir_tstrlen(ptszHelpFile)); } else { _tcsncpy(pszFileName, pszDivider + 1, mir_tstrlen(ptszHelpFile) - mir_tstrlen(pszDivider) - 1); pszFileName[mir_tstrlen(ptszHelpFile) - mir_tstrlen(pszDivider) - 1] = 0; _tcsncpy(pszDirName, ptszHelpFile, pszDivider - ptszHelpFile); pszDirName[pszDivider - ptszHelpFile] = 0; } } mir_free(ptszHelpFile); } LPTSTR pszDirNameEx; pszDirNameEx = Utils_ReplaceVarsT(pszDirName); mir_free(pszDirName); ShellExecute(NULL, _T("open"), pszFileName, NULL, pszDirNameEx, SW_SHOW); mir_free(pszFileName); mir_free(pszDirNameEx); return 0; }
void WINAPI GetStatusFcn(HACCOUNT Which, TCHAR *Value) { if (Which == NULL) return; mir_cslock lck(csAccountStatusCS); mir_tstrcpy(Value, Which->Status); }
void WINAPI SetStatusFcn(HACCOUNT Which, TCHAR *Value) { if (Which != NULL) { mir_cslock lck(csAccountStatusCS); mir_tstrcpy(Which->Status, Value); } WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGESTATUS, (WPARAM)Which, 0); }
void InitTimeZones(void) { REG_TZI_FORMAT tzi; HKEY hKey; const TCHAR *tszKey = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"); /* * use GetDynamicTimeZoneInformation() on Vista+ - this will return a structure with * the registry key name, so finding our own time zone later will be MUCH easier for * localized systems or systems with a MUI pack installed */ if (IsWinVerVistaPlus()) pfnGetDynamicTimeZoneInformation = (pfnGetDynamicTimeZoneInformation_t)GetProcAddress(GetModuleHandle(_T("kernel32")), "GetDynamicTimeZoneInformation"); if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszKey, 0, KEY_ENUMERATE_SUB_KEYS, &hKey)) { DWORD dwIndex = 0; HKEY hSubKey; TCHAR tszName[MIM_TZ_NAMELEN]; DWORD dwSize = _countof(tszName); while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx(hKey, dwIndex++, tszName, &dwSize, NULL, NULL, 0, NULL)) { if (ERROR_SUCCESS == RegOpenKeyEx(hKey, tszName, 0, KEY_QUERY_VALUE, &hSubKey)) { dwSize = sizeof(tszName); DWORD dwLength = sizeof(tzi); if (ERROR_SUCCESS != RegQueryValueEx(hSubKey, _T("TZI"), NULL, NULL, (unsigned char *)&tzi, &dwLength)) continue; MIM_TIMEZONE *tz = new MIM_TIMEZONE; tz->tzi.Bias = tzi.Bias; tz->tzi.StandardDate = tzi.StandardDate; tz->tzi.StandardBias = tzi.StandardBias; tz->tzi.DaylightDate = tzi.DaylightDate; tz->tzi.DaylightBias = tzi.DaylightBias; mir_tstrcpy(tz->tszName, tszName); tz->hash = mir_hashstrT(tszName); tz->offset = INT_MIN; GetLocalizedString(hSubKey, _T("Display"), tz->szDisplay, _countof(tz->szDisplay)); GetLocalizedString(hSubKey, _T("Std"), tz->tzi.StandardName, _countof(tz->tzi.StandardName)); GetLocalizedString(hSubKey, _T("Dlt"), tz->tzi.DaylightName, _countof(tz->tzi.DaylightName)); g_timezones.insert(tz); g_timezonesBias.insert(tz); RegCloseKey(hSubKey); } dwSize = _countof(tszName); } RegCloseKey(hKey); } RecalculateTime(); }
int ReloadColors(WPARAM, LPARAM) { ColourIDT colourid = { 0 }; colourid.cbSize = sizeof(colourid); mir_tstrcpy(colourid.group, _T(ModuleName)); mir_tstrcpy(colourid.name, LPGENT("Frame background")); clBack = CallService(MS_COLOUR_GETT, (WPARAM)&colourid, 0); if (hBkgBrush) DeleteObject(hBkgBrush); hBkgBrush = CreateSolidBrush(clBack); HWND hwnd = GetFocus(); InvalidateRect(hwndSlider, NULL, TRUE); SetFocus(hwndSlider); RedrawWindow(hwnd_plugin, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE); SetFocus(hwnd); return 0; }
HTREEITEM OptTree_AddItem(HWND hwndTree, TCHAR *name, LPARAM lParam, int iconIndex) { TCHAR itemName[1024]; TCHAR* sectionName; int sectionLevel = 0; HTREEITEM hSection = NULL, result = NULL; mir_tstrcpy(itemName, name); sectionName = itemName; while (sectionName) { // allow multi-level tree TCHAR* pItemName = sectionName; HTREEITEM hItem; if (sectionName = _tcschr(sectionName, '/')) { // one level deeper *sectionName = 0; sectionName++; } hItem = OptTree_FindNamedTreeItemAt(hwndTree, hSection, pItemName); if (!sectionName || !hItem) { if (!hItem) { TVINSERTSTRUCT tvis = {0}; tvis.hParent = hSection; tvis.hInsertAfter = TVI_LAST;//TVI_SORT; tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE; tvis.item.pszText = pItemName; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; if (sectionName) { tvis.item.lParam = 0; tvis.item.iImage = tvis.item.iSelectedImage = -1; } else { tvis.item.lParam = lParam; tvis.item.iImage = tvis.item.iSelectedImage = iconIndex; tvis.item.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE; } hItem = TreeView_InsertItem(hwndTree, &tvis); if (!sectionName) result = hItem; } } sectionLevel++; hSection = hItem; } return result; }
void SetFilenames(const TCHAR *path) { if (!path || !path[0]) return; CreateDirectoryTreeT(path); mir_tstrcpy(g_private_key_filename, path); mir_tstrcat(g_private_key_filename, _T("\\")); mir_tstrcat(g_private_key_filename, _T(PRIVATE_KEY_FILENAME)); mir_tstrcpy(g_fingerprint_store_filename, path); mir_tstrcat(g_fingerprint_store_filename, _T("\\")); mir_tstrcat(g_fingerprint_store_filename, _T(FINGERPRINT_STORE_FILENAME)); mir_tstrcpy(g_instag_filename, path); mir_tstrcat(g_instag_filename, _T("\\")); mir_tstrcat(g_instag_filename, _T(INSTAG_FILENAME)); }
// hKey must have been opened with KEY_SET_VALUE access right static void SetRegStrPrefixValue(HKEY hKey,const TCHAR *pszValPrefix,const TCHAR *pszVal) { DWORD dwSize=(mir_tstrlen(pszVal)+mir_tstrlen(pszValPrefix)+1)*sizeof(TCHAR); TCHAR *pszStr=(TCHAR*)mir_alloc(dwSize); if (pszStr==NULL) return; mir_tstrcat(mir_tstrcpy(pszStr,pszValPrefix),pszVal); /* buffer safe */ RegSetValueEx(hKey,NULL,0,REG_SZ,(BYTE*)pszStr,dwSize); mir_free(pszStr); }
static void SortGroup(struct ClcData *dat, ClcGroup *group, int useInsertionSort) { int i, sortCount; for (i = group->cl.count - 1; i >= 0; i--) { if (group->cl.items[i]->type == CLCIT_DIVIDER) { mir_free(group->cl.items[i]); List_Remove((SortedList*)&group->cl, i); } } for (i=0; i < group->cl.count; i++) if (group->cl.items[i]->type != CLCIT_INFO) break; if (i > group->cl.count - 2) return; if (group->cl.items[i]->type == CLCIT_GROUP) { if (dat->exStyle & CLS_EX_SORTGROUPSALPHA) { for (sortCount = 0; i + sortCount < group->cl.count; sortCount++) if (group->cl.items[i + sortCount]->type != CLCIT_GROUP) break; qsort(group->cl.items + i, sortCount, sizeof(void*), GroupSortProc); i = i + sortCount; } for (; i < group->cl.count; i++) if (group->cl.items[i]->type == CLCIT_CONTACT) break; if (group->cl.count - i < 2) return; } for (sortCount = 0; i + sortCount < group->cl.count; sortCount++) if (group->cl.items[i + sortCount]->type != CLCIT_CONTACT) break; if (useInsertionSort) InsertionSort(group->cl.items + i, sortCount, ContactSortProc); else qsort(group->cl.items + i, sortCount, sizeof(void*), ContactSortProc); if (dat->exStyle & CLS_EX_DIVIDERONOFF) { int prevContactOnline = 0; for (i=0; i < group->cl.count; i++) { if (group->cl.items[i]->type != CLCIT_CONTACT) continue; if (group->cl.items[i]->flags & CONTACTF_ONLINE) prevContactOnline = 1; else { if (prevContactOnline) { i = cli.pfnAddItemToGroup(group, i); group->cl.items[i]->type = CLCIT_DIVIDER; mir_tstrcpy(group->cl.items[i]->szText, TranslateT("Offline")); } break; } } } }
void CreateFrame() { if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) return; WNDCLASS wndclass = { 0 }; wndclass.style = 0; wndclass.lpfnWndProc = FrameWindowProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInst; wndclass.hIcon = NULL; wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = 0; wndclass.lpszMenuName = NULL; wndclass.lpszClassName = _T("BassInterfaceFrame"); RegisterClass(&wndclass); hwnd_plugin = CreateWindow(_T("BassInterfaceFrame"), TranslateT("Bass Interface"), WS_CHILD | WS_CLIPCHILDREN, 0, 0, 10, 10, pcli->hwndContactList, NULL, hInst, NULL); CLISTFrame Frame = { sizeof(CLISTFrame) }; Frame.tname = TranslateT("Bass Interface"); Frame.hWnd = hwnd_plugin; Frame.align = alBottom; Frame.Flags = F_TCHAR | F_VISIBLE | F_SHOWTB | F_SHOWTBTIP; Frame.height = 22; Frame.hIcon = Skin_LoadIcon(SKINICON_OTHER_FRAME); frame_id = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); ColourIDT colourid = { 0 }; colourid.cbSize = sizeof(ColourIDT); mir_strcpy(colourid.dbSettingsGroup, ModuleName); mir_strcpy(colourid.setting, "ColorFrame"); mir_tstrcpy(colourid.name, LPGENT("Frame background")); mir_tstrcpy(colourid.group, _T(ModuleName)); colourid.defcolour = GetSysColor(COLOR_3DFACE); ColourRegisterT(&colourid); HookEvent(ME_COLOUR_RELOAD, ReloadColors); ReloadColors(0, 0); }
TCHAR* Utils::getTextFragment(TCHAR *stzText, size_t length, TCHAR *buff) { if (mir_tstrlen(stzText) > length) { mir_tstrcpy(buff, stzText); buff[length - 1] = 0; mir_tstrcat(buff, _T("...")); return buff; } return stzText; }
static void patchDir(TCHAR *str, size_t strSize) { TCHAR *result = Utils_ReplaceVarsT(str, 0, sttVarsToReplace); if (result) { _tcsncpy(str, result, strSize); mir_free(result); } size_t len = mir_tstrlen(str); if (len + 1 < strSize && str[len - 1] != '\\') mir_tstrcpy(str + len, _T("\\")); }
static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll) { OPENFILENAME ofn = {0}; TCHAR filter[512], *pfilter, file[MAX_PATH*2]; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hParent; mir_tstrcpy(filter, TranslateT("Icon sets")); if (bAll) mir_tstrcat(filter, _T(" (*.dll;*.icl;*.exe;*.ico)")); else mir_tstrcat(filter, _T(" (*.dll)")); pfilter = filter+mir_tstrlen(filter)+1; if (bAll) mir_tstrcpy(pfilter, _T("*.DLL;*.ICL;*.EXE;*.ICO")); else mir_tstrcpy(pfilter, _T("*.DLL")); pfilter += mir_tstrlen(pfilter) + 1; mir_tstrcpy(pfilter, TranslateT("All files")); mir_tstrcat(pfilter, _T(" (*)")); pfilter += mir_tstrlen(pfilter) + 1; mir_tstrcpy(pfilter, _T("*")); pfilter += mir_tstrlen(pfilter) + 1; *pfilter = '\0'; ofn.lpstrFilter = filter; ofn.lpstrDefExt = _T("dll"); mir_tstrncpy(file, szFile, SIZEOF(file)); ofn.lpstrFile = file; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; ofn.nMaxFile = MAX_PATH*2; if (!GetOpenFileName(&ofn)) return NULL; return mir_tstrdup(file); }
static void SetFileListAndSizeControls(HWND hwndDlg, FileDlgData *dat) { int fileCount = 0, dirCount = 0, i; __int64 totalSize = 0; struct _stati64 statbuf; TCHAR str[64]; for (i = 0; dat->files[i]; i++) { if (_tstati64(dat->files[i], &statbuf) == 0) { if (statbuf.st_mode & _S_IFDIR) dirCount++; else fileCount++; totalSize += statbuf.st_size; } } GetSensiblyFormattedSize(totalSize, str, _countof(str), 0, 1, NULL); SetDlgItemText(hwndDlg, IDC_TOTALSIZE, str); if (i > 1) { TCHAR szFormat[32]; if (fileCount && dirCount) { mir_sntprintf(szFormat, _T("%s, %s"), TranslateTS(fileCount == 1 ? _T("%d file") : _T("%d files")), TranslateTS(dirCount == 1 ? _T("%d directory") : _T("%d directories"))); mir_sntprintf(str, szFormat, fileCount, dirCount); } else if (fileCount) { mir_tstrcpy(szFormat, TranslateT("%d files")); mir_sntprintf(str, szFormat, fileCount); } else { mir_tstrcpy(szFormat, TranslateT("%d directories")); mir_sntprintf(str, szFormat, dirCount); } SetDlgItemText(hwndDlg, IDC_FILE, str); } else SetDlgItemText(hwndDlg, IDC_FILE, dat->files[0]); EnableWindow(GetDlgItem(hwndDlg, IDOK), fileCount || dirCount); }
CMLuaScript::CMLuaScript(lua_State *L, const TCHAR* path) : L(L), unloadRef(0) { mir_tstrcpy(filePath, path); fileName = _tcsrchr(filePath, '\\') + 1; size_t length = mir_tstrlen(fileName) - 3; ptrT name((TCHAR*)mir_calloc(sizeof(TCHAR) * length)); mir_tstrncpy(name, fileName, mir_tstrlen(fileName) - 3); moduleName = mir_utf8encodeT(name); }
int AlarmWinModulesLoaded(WPARAM, LPARAM) { title_font_id.cbSize = sizeof(FontIDT); mir_tstrcpy(title_font_id.group, LPGENT("Alarms")); mir_tstrcpy(title_font_id.name, LPGENT("Title")); mir_strcpy(title_font_id.dbSettingsGroup, MODULE); mir_strcpy(title_font_id.prefix, "FontTitle"); mir_tstrcpy(title_font_id.backgroundGroup,LPGENT("Alarms")); mir_tstrcpy(title_font_id.backgroundName,LPGENT("Background")); title_font_id.flags = 0; title_font_id.order = 0; FontRegisterT(&title_font_id); window_font_id.cbSize = sizeof(FontIDT); mir_tstrcpy(window_font_id.group, LPGENT("Alarms")); mir_tstrcpy(window_font_id.name, LPGENT("Window")); mir_strcpy(window_font_id.dbSettingsGroup, MODULE); mir_strcpy(window_font_id.prefix, "FontWindow"); mir_tstrcpy(window_font_id.backgroundGroup,LPGENT("Alarms")); mir_tstrcpy(window_font_id.backgroundName,LPGENT("Background")); window_font_id.flags = 0; window_font_id.order = 1; FontRegisterT(&window_font_id); bk_colour_id.cbSize = sizeof(ColourIDT); mir_strcpy(bk_colour_id.dbSettingsGroup, MODULE); mir_tstrcpy(bk_colour_id.group, LPGENT("Alarms")); mir_tstrcpy(bk_colour_id.name, LPGENT("Background")); mir_strcpy(bk_colour_id.setting, "BkColour"); bk_colour_id.defcolour = GetSysColor(COLOR_3DFACE); bk_colour_id.flags = 0; bk_colour_id.order = 0; ColourRegisterT(&bk_colour_id); ReloadFonts(0, 0); HookEvent(ME_FONT_RELOAD, ReloadFonts); return 0; }
void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, size_t cbLen) { TCHAR szPath[MAX_PATH * 2]; mir_sntprintf(szPath, _T("%s\\%S\\"), VARST(_T("%miranda_avatarcache%")), m_szModuleName); FOLDERSGETDATA fgd = { sizeof(fgd) }; fgd.nMaxPathSize = _countof(szPath); fgd.szPathT = szPath; fgd.flags = FF_TCHAR; // fill the destination mir_tstrncpy(pszDest, szPath, cbLen - 1); size_t tPathLen = mir_tstrlen(pszDest); // make sure the avatar cache directory exists CreateDirectoryTreeT(szPath); if (dwUin != 0) _ltot(dwUin, pszDest + tPathLen, 10); else if (szUid) { TCHAR* p = mir_a2t(szUid); mir_tstrcpy(pszDest + tPathLen, p); mir_free(p); } else { TCHAR szBuf[MAX_PATH]; if (CallService(MS_DB_GETPROFILENAMET, MAX_PATH, (LPARAM)szBuf)) mir_tstrcpy(pszDest + tPathLen, _T("avatar")); else { TCHAR *szLastDot = _tcsrchr(szBuf, '.'); if (szLastDot) szLastDot[0] = '\0'; mir_tstrcpy(pszDest + tPathLen, szBuf); mir_tstrcat(pszDest + tPathLen, _T("_avt")); } } }
void __cdecl ChooseFilesThread(void* param) { HWND hwndDlg = (HWND)param; FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); TCHAR *buf = (TCHAR*)mir_alloc(sizeof(TCHAR) * 32767); if (buf == NULL) { PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, NULL); return; } TCHAR filter[128]; mir_tstrcpy(filter, TranslateT("All files")); mir_tstrcat(filter, _T(" (*)")); TCHAR *pfilter = filter + mir_tstrlen(filter) + 1; mir_tstrcpy(pfilter, _T("*")); pfilter = filter + mir_tstrlen(filter) + 1; pfilter[0] = '\0'; OPENFILENAME ofn = { 0 }; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = filter; ofn.lpstrFile = buf; *buf = 0; ofn.nMaxFile = 32767; ofn.Flags = OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; char *szProto = GetContactProto(dat->hContact); if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_SINGLEFILEONLY)) ofn.Flags |= OFN_ALLOWMULTISELECT; if (GetOpenFileName(&ofn)) PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, (LPARAM)buf); else { mir_free(buf); PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, NULL); } }