void readSettings() { settings.showErrors = GetRCBoolDef("LSActiveDesktopShowErrors", TRUE) != FALSE; char line[MAX_LINE_LENGTH + 1]; const char *tokenStart = line; char token[MAX_LINE_LENGTH + 1]; GetRCLine("LSActiveDesktopWebWindows", line, MAX_LINE_LENGTH + 1, NULL); while (GetToken(tokenStart, token, &tokenStart, false)) { std::string name(token); std::transform(name.begin(), name.end(), name.begin(), tolower); LSADWebWndProp props; props.x = GetRCCoordinate((name + "X").c_str(), 0, GetSystemMetrics(SM_CXVIRTUALSCREEN)); props.y = GetRCCoordinate((name + "Y").c_str(), 0, GetSystemMetrics(SM_CYVIRTUALSCREEN)); props.width = GetRCInt((name + "Width").c_str(), 100); props.height = GetRCInt((name + "Height").c_str(), 100); props.showScrollbars = !(GetRCBool((name + "HideScrollbars").c_str(), TRUE) != FALSE); char url[MAX_LINE_LENGTH + 1]; GetRCString((name + "URL").c_str(), url, "http://tlundberg.com", MAX_LINE_LENGTH + 1); props.url = url; settings.windowProperties.insert(make_pair(name, props)); } }
int LSUtils::PrefixedGetRCInt(LPCTSTR prefix, LPCTSTR setting, int nDefault) { LPTSTR szTemp; AppendSetting(prefix, setting, szTemp); int retValue = GetRCInt(szTemp, nDefault); #ifdef _DEBUG _LSLogPrintf(LOG_DEBUG, szLogName, "looking for setting: %s, got %d", szTemp, retValue); #endif delete [] szTemp; return retValue; }
void Label::ReadConfig() { // Background and Borders TCHAR backgroundImageFile[MAX_PATH]; mBackgroundColor = GetRCColor(mName, "BackgroundColor", RGB(255, 255, 255)); GetRCString(mName, "BackgroundImage", backgroundImageFile, NULL, MAX_PATH); mBackgroundImage = LoadLSImage(backgroundImageFile, NULL); mBackgroundImageBorderTop = GetRCInt(mName, "BackgroundImageBorderTop", 0); mBackgroundImageBorderRight = GetRCInt(mName, "BackgroundImageBorderRight", 0); mBackgroundImageBorderBottom = GetRCInt(mName, "BackgroundImageBorderBottom", 0); mBackgroundImageBorderLeft = GetRCInt(mName, "BackgroundImageBorderLeft", 0); mBackgroundImageTile = GetRCEnum(mName, "BackgroundImageTile", gBackgroundImageTileEnum); mBorderColorTop = GetRCColor(mName, "BorderColorTop", RGB(0, 0, 0)); mBorderColorRight = GetRCColor(mName, "BorderColorRight", RGB(0, 0, 0)); mBorderColorBottom = GetRCColor(mName, "BorderColorBottom", RGB(0, 0, 0)); mBorderColorLeft = GetRCColor(mName, "BorderColorLeft", RGB(0, 0, 0)); mBorderTop = GetRCInt(mName, "BorderTop", 0); mBorderRight = GetRCInt(mName, "BorderRight", 0); mBorderBottom = GetRCInt(mName, "BorderBottom", 0); mBorderLeft = GetRCInt(mName, "BorderLeft", 0); // Font TCHAR fontName[LF_FACESIZE]; int fontHeight; bool fontBold; bool fontItalic; bool fontUnderline; GetRCString(mName, "Font", fontName, "Arial", LF_FACESIZE); fontHeight = GetRCInt(mName, "FontHeight", 15); fontBold = GetRCBoolDef(mName, "FontBold", FALSE); fontItalic = GetRCBoolDef(mName, "FontItalic", FALSE); fontUnderline = GetRCBoolDef(mName, "FontUnderline", FALSE); mFont = CreateSimpleFont(fontName, fontHeight, fontBold, fontItalic, fontUnderline); mFontColor = GetRCColor(mName, "FontColor", RGB(0, 0, 0)); mFontShadow = GetRCBoolDef(mName, "FontShadow", FALSE); mFontShadowColor = GetRCColor(mName, "FontShadowColor", RGB(128, 128, 128)); mFontShadowOffsetX = GetRCInt(mName, "FontShadowOffsetX", 1); mFontShadowOffsetY = GetRCInt(mName, "FontShadowOffsetY", 1); // Layout mAlign = GetRCEnum(mName, "Align", gAlignEnum); mImagePosition = GetRCEnum(mName, "ImagePosition", gImagePositionEnum); mImageTextGap = GetRCInt(mName, "ImageTextGap", 4); mPaddingLeft = GetRCInt(mName, "PaddingLeft", 0); mPaddingTop = GetRCInt(mName, "PaddingTop", 0); mPaddingRight = GetRCInt(mName, "PaddingRight", 0); mPaddingBottom = GetRCInt(mName, "PaddingBottom", 0); mVerticalAlign = GetRCEnum(mName, "VerticalAlign", gVerticalAlignEnum); // Content TCHAR imageFile[MAX_PATH]; GetRCString(mName, "Image", imageFile, NULL, MAX_PATH); mImage = LoadLSImage(imageFile, NULL); GetRCString(mName, "Text", mText, NULL, MAX_TEXT); // Position and Size mAlwaysOnTop = GetRCBoolDef(mName, "AlwaysOnTop", FALSE); mVisible = !GetRCBoolDef(mName, "StartHidden", FALSE); mX = GetRCInt(mName, "X", 0); mY = GetRCInt(mName, "Y", 0); mWidth = GetRCInt(mName, "Width", 64); mHeight = GetRCInt(mName, "Height", 64); }
BOOL WINAPI LSLog(int nLevel, LPCSTR pszModule, LPCSTR pszMessage) { #if defined(LS_COMPAT_LOGGING) char szLogFile[MAX_PATH] = { 0 }; int nLogLevel = GetRCInt("LSLogLevel", 2); // Should this message be logged? if (!pszModule || !pszMessage || (nLevel > nLogLevel) || (nLevel < 1) || (nLevel > 4)) { return FALSE; } // Has a log file been assigned? if (!GetRCString("LSLogFile", szLogFile, NULL, MAX_PATH)) { return FALSE; } // If so, open it HANDLE hLogFile = CreateFile(szLogFile, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); // Did open succeed? if (hLogFile == INVALID_HANDLE_VALUE) { return FALSE; } // Move to the end of the file SetFilePointer(hLogFile, 0, NULL, FILE_END); // Get timestamp SYSTEMTIME st = { 0 }; GetLocalTime(&st); // Add timestamp and module name to message LPCSTR rszLevel[4] = { "Error", "Warning", "Notice", "Debug" }; TCHAR szLine[MAX_LINE_LENGTH] = { 0 }; size_t cbLine = sizeof(szLine); size_t cbRemaining = 0; if (SUCCEEDED(StringCbPrintfEx(szLine, cbLine, NULL, &cbRemaining, STRSAFE_IGNORE_NULLS, "%02d-%02d-%04d %02d:%02d:%02d - %s - %s: %s\r\n", st.wMonth, st.wDay, st.wYear, st.wHour, st.wMinute, st.wSecond, rszLevel[nLevel-1], pszModule, pszMessage))) { size_t cbToWrite = cbLine - cbRemaining; ASSERT(cbToWrite <= MAXDWORD); // Write it to the log file DWORD dwCount = 0; WriteFile(hLogFile, szLine, (DWORD)cbToWrite, &dwCount, NULL); } // Close the log CloseHandle(hLogFile); #endif // LS_COMPAT_LOGGING return TRUE; }