示例#1
0
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;
}
示例#2
0
/*	WriteSetting
*	this method writes a setting to the settings file (strings(const char))
*/
void IOSettings::WriteSetting(const char* Setting, const char* SettCont)
{
	BString tmp;
	tmp.SetTo(SettCont);

	WriteSetting(Setting, tmp);
}
示例#3
0
//------------------------------------------------------------------------
//! Removes the current configuration
//------------------------------------------------------------------------
void CViewConfigSectionProfiles::RemoveCurrentConfig()
{
	if (GetSectionName() == m_ViewName)
	{
		// Backup strProfile-settings and reset the other settings
		const CString& strProfiles = ReadSetting(m_ViewName, _T("CurrentProfiles"), _T(""));
		const CString& activeProfile = ReadSetting(m_ViewName, _T("ActiveProfile"), _T(""));
		CViewConfigSectionDefault::RemoveCurrentConfig();
		WriteSetting(m_ViewName, _T("CurrentProfiles"), strProfiles);
		WriteSetting(m_ViewName, _T("ActiveProfile"), activeProfile);
	}
	else
	{
		CViewConfigSectionDefault::RemoveCurrentConfig();
	}
}
示例#4
0
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", "");
}
示例#5
0
//------------------------------------------------------------------------
//! Switches to a new active configuration profile
//!
//! @param strProfile Name of the new profile
//------------------------------------------------------------------------
void CViewConfigSectionProfiles::SetActiveProfile(const CString& strProfile)
{
	// Make the new strProfile the active ones
	WriteSetting(m_ViewName, _T("ActiveProfile"), strProfile);
	m_CurrentSection = JoinSectionName(m_ViewName, strProfile);
	if (strProfile.IsEmpty())
		return;

	AddProfile(strProfile);
}
示例#6
0
/*
 *    Main... 
 *
 */
int main(int argc, char **argv) {
const char *me = (const char *)basename(argv[0]);
bool SwitchesAllowed = true;
bool WriteMode = false;
int ReturnCode = 0;
const char *preloadfile = DEFAULT_PRELOAD;

   PrintName = true;

   if (argc < 2) {
       return Usage(me);
   } /* endif */

   argv++;

   for (; argv && *argv && **argv; argv++) {
      if (SwitchesAllowed && **argv == '-') {        /* we have a switch */
         switch((*argv)[1]) {
         case 'n':
              PrintName = false;
           break;
         case 'w':
              SwitchesAllowed = false;
              WriteMode = true;
           break;
         case 'p':
              argv++;
              if (argv && *argv && **argv) {
                 preloadfile = *argv;
              } /* endif */

              Preload(preloadfile);
              return(0);
           break;
         case 'a':
         case 'A':
              SwitchesAllowed = false;
              return DisplayAll(PROC_PATH, ((*argv)[1] == 'a') ? false : true);
         case 'h':
         case '?':
              return Usage(me);
         default:
              fprintf(stderr, ERR_UNKNOWN_PARAMETER, *argv);
              return Usage(me);
         } /* end switch */
      } else {
         SwitchesAllowed = false;
         if (WriteMode)
            ReturnCode = WriteSetting(*argv);
         else ReadSetting(*argv);
      } /* end if */
   } /* end for */      

return ReturnCode;
} /* end main */
示例#7
0
//------------------------------------------------------------------------
//! Adds a profile to the official list of column configuration profiles
//!
//! @param strProfile Name of the profile
//------------------------------------------------------------------------
void CViewConfigSectionProfiles::AddProfile(const CString& strProfile)
{
	// Add the strProfile to the list if not already there
	CSimpleArray<CString> profiles;
	GetProfiles(profiles);
	for (int i = 0; i < profiles.GetSize(); ++i)
		if (profiles[i] == strProfile)
			return;

	CString noconst(strProfile);
	profiles.Add(noconst);

	WriteSetting(m_ViewName, _T("CurrentProfiles"), ConvertArraySetting(profiles, _T(", ")));
}
示例#8
0
//------------------------------------------------------------------------
//! Removes a profile from the official list of column configuration profiles
//!
//! @param strProfile Name of the profile
//------------------------------------------------------------------------
void CViewConfigSectionProfiles::DeleteProfile(const CString& strProfile)
{
	if (strProfile.IsEmpty())
		return;

	// Remove any settings
	RemoveSection(JoinSectionName(m_ViewName, strProfile));

	// Remove the strProfile from the list
	CSimpleArray<CString> profiles;
	GetProfiles(profiles);
	for (int i = 0; i < profiles.GetSize(); ++i)
		if (profiles[i] == strProfile)
			profiles.RemoveAt(i);
	WriteSetting(m_ViewName, _T("CurrentProfiles"), ConvertArraySetting(profiles, _T(", ")));
}
TDBTSettingHandle CSettings::WriteSetting(TDBTSetting & Setting)
{
	CBlockManager * file = &m_BlockManagerPri;
	if (Setting.Descriptor->Entity == 0)
		file = &m_BlockManagerSet;
	
	CBlockManager::WriteTransaction trans(*file);

	TDBTSettingHandle hset = FindSetting(*Setting.Descriptor);
	if (hset == DBT_INVALIDPARAM)
		return hset;

	hset = WriteSetting(Setting, hset);

	return hset;
}
示例#10
0
/*
 *     Preload the sysctl's from the conf file
 *           - we parse the file and then reform it (strip out whitespace)
 *
 */
void Preload(const char *filename) {
FILE *fp;
char oneline[257];
char buffer[257];
char *t;
int n = 0;
char *name, *value;

   if (!filename || ((fp = fopen(filename, "r")) == NULL)) {
      fprintf(stderr, ERR_PRELOAD_FILE, filename);
      return;
   } /* endif */

   while (fgets(oneline, 256, fp)) {
      oneline[256] = 0;
      n++;
      t = StripLeadingAndTrailingSpaces(oneline);

      if (strlen(t) < 2)
         continue;

      if (*t == '#' || *t == ';')
         continue;

      name = strtok(t, "=");
      if (!name || !*name) {
         fprintf(stderr, WARN_BAD_LINE, filename, n);
         continue;
      } /* endif */

      StripLeadingAndTrailingSpaces(name);

      value = strtok(NULL, "\n\r");
      if (!value || !*value) {
         fprintf(stderr, WARN_BAD_LINE, filename, n);
         continue;
      } /* endif */

      while ((*value == ' ' || *value == '\t') && *value != 0)
         value++;

      sprintf(buffer, "%s=%s", name, value);
      WriteSetting(buffer);
   } /* endwhile */

   fclose(fp);
} /* end Preload() */
示例#11
0
void CSettings::_EnsureModuleExists(char * Module)
{
	if ((Module == NULL) || (*Module == 0))
		return;

	char * e = strchr(Module, '/');
	if (e)
		*e = 0;

	TModulesMap::iterator i = m_Modules.find(*((uint16_t*)Module));
	while ((i != m_Modules.end()) && (i->first == *((uint16_t*)Module)) && (strcmp(i->second, Module) != 0))
	{
		++i;
	}

	if ((i == m_Modules.end()) || (i->first != *reinterpret_cast<uint16_t*>(Module)))
	{
		size_t l = strlen(Module);
		char * tmp = new char [l + 1];
		memcpy(tmp, Module, l + 1);
		m_Modules.insert(std::make_pair(*reinterpret_cast<uint16_t*>(tmp), tmp));

		char namebuf[512];
		strcpy_s(namebuf, "$Modules/");
		strcat_s(namebuf, Module);

		TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
		desc.cbSize = sizeof(desc);
		desc.pszSettingName = namebuf;

		TDBTSetting set = {0,0,0,0};
		set.cbSize = sizeof(set);
		set.Descriptor = &desc;
		set.Type = DBT_ST_DWORD;

		WriteSetting(set, cSettingsFileFlag);
	}

	if (e)
		*e = '/';
}
void PathManager::SetDecPackPath(QString &path)
{
	DECPACKPATH = path;
	WriteSetting();
}
示例#13
0
//------------------------------------------------------------------------
//! Updates a setting value for the view
//!
//! @param strName Name of setting
//! @param strValue New setting value
//------------------------------------------------------------------------
void CViewConfigSection::SetSetting(const CString& strName, const CString& strValue)
{
	WriteSetting(GetSectionName(), strName, strValue);
}
void PathManager::SetKeyPath(QString &path)
{
	KEYPATH = path;
	WriteSetting();
}
void PathManager::SetSrcPath(QString &path)
{
	SRCPATH = path;
	WriteSetting();
}
void PathManager::SetKeyAliases(QString &aliases)
{
	KEYALIASES = aliases;
	WriteSetting();
}
void PathManager::SetDigestalg(QString &dig)
{
	DIGESTALG = dig;
	WriteSetting();
}
void PathManager::SetSigalg(QString &sig)
{
	SIGALG = sig;
	WriteSetting();
}
示例#19
0
INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwnd);
		{
			MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam;
			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact);
			if (!hContact)
				break;

			/* link*/
			DBVARIANT dbv;
			if (!db_get_ts(hContact, MODNAME, "ProgramString", &dbv)) {
				SetDlgItemText(hwnd, IDC_LINK, dbv.ptszVal);
				db_free(&dbv);
			}

			if (!db_get_ts(hContact, MODNAME, "ProgramParamsString", &dbv)) {
				SetDlgItemText(hwnd, IDC_PARAMS, dbv.ptszVal);
				db_free(&dbv);
			}

			/* group*/
			TCHAR *szGroup;
			for (int i = 1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
				SendDlgItemMessage(hwnd, IDC_GROUP, CB_INSERTSTRING, 0, LPARAM(szGroup));

			if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
				SetDlgItemText(hwnd, IDC_GROUP, dbv.ptszVal);
				db_free(&dbv);
			}

			/* icons */
			CheckRadioButton(hwnd, 40072, 40080, db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE));
			SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_USERDATA, (LONG_PTR)Skin_LoadProtoIcon(MODNAME, ID_STATUS_ONLINE));
			g_PrevBtnWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_WNDPROC, (LONG_PTR)ButtWndProc);
			for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
				SetWindowLongPtr(GetDlgItem(hwnd, i), GWLP_USERDATA, (LONG_PTR)Skin_LoadProtoIcon(MODNAME, i));
				SetWindowLongPtr(GetDlgItem(hwnd, i), GWLP_WNDPROC, (LONG_PTR)ButtWndProc);
			}
			db_free(&dbv);
			/* timer */
			CheckDlgButton(hwnd, CHK_USE_TIMER, db_get_b(hContact, MODNAME, "UseTimer", 0) ? BST_CHECKED : BST_UNCHECKED);
			if (db_get_w(hContact, MODNAME, "Timer", 15)) {
				CheckDlgButton(hwnd, CHK_USE_TIMER, BST_CHECKED);
				EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1);
				TCHAR string[512];
				SetDlgItemText(hwnd, IDC_TIMER, _itot(db_get_w(hContact, MODNAME, "Timer", 15), string, 10));
				if (!db_get_w(NULL, MODNAME, "Timer", 1))
					SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, TranslateT("Non-IM Contact protocol timer is Disabled"));
				else {
					mir_sntprintf(string, TranslateT("Timer intervals... Non-IM Contact Protocol timer is %d seconds"), db_get_w(NULL, MODNAME, "Timer", 1));
					SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, string);
				}
			}
			/* always visible */
			if (db_get_b(hContact, MODNAME, "AlwaysVisible", 0)) {
				CheckDlgButton(hwnd, IDC_ALWAYS_VISIBLE, BST_CHECKED);
				EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1);
				CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED);
			}
		}
		return TRUE;

	case WM_COMMAND:
		SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
		switch (LOWORD(wParam)) {
		case IDC_ALWAYS_VISIBLE:
			if (IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)) {
				MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
				EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1);
				CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED);
			}
			else EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 0);
			break;

		case CHK_USE_TIMER:
			if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) {
				MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
				char string[4];
				EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1);
				SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME, "Timer", 15), string, 10));
			}
			else EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 0);
			break;

		case IDC_OPEN_FILE:
			char szFileName[512];
			if (Openfile(szFileName, 1))
				SetDlgItemTextA(hwnd, IDC_LINK, szFileName);
			break;

		case IDC_OPEN_FOLDER:
			if (BrowseForFolder(hwnd, szFileName)) {
				mir_snprintf(szFileName, "%s ,/e", szFileName);
				SetDlgItemTextA(hwnd, IDC_LINK, "explorer.exe");
				SetDlgItemTextA(hwnd, IDC_PARAMS, szFileName);
			}
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_APPLY:
				int status = GetLCStatus(0, 0);
				MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);

				if (GetWindowTextLength(GetDlgItem(hwnd, IDC_LINK))) {
					char text[512];
					GetDlgItemTextA(hwnd, IDC_LINK, text, _countof(text));
					db_set_s(hContact, MODNAME, "ProgramString", text);
					WriteSetting(hContact, MODNAME, "ProgramString", MODNAME, "Program");
				}
				else db_unset(hContact, MODNAME, "ProgramString");

				if (GetWindowTextLength(GetDlgItem(hwnd, IDC_PARAMS))) {
					char text[512];
					GetDlgItemTextA(hwnd, IDC_PARAMS, text, _countof(text));
					db_set_s(hContact, MODNAME, "ProgramParamsString", text);
					WriteSetting(hContact, MODNAME, "ProgramParamsString", MODNAME, "ProgramParams");
				}
				else db_unset(hContact, MODNAME, "ProgramParamsString");

				if (GetWindowTextLength(GetDlgItem(hwnd, IDC_GROUP))) {
					TCHAR text[512];
					GetDlgItemText(hwnd, IDC_GROUP, text, _countof(text));
					Clist_CreateGroup(NULL, text);
					db_set_ts(hContact, "CList", "Group", text);
				}
				else db_unset(hContact, "CList", "Group");

				for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
					if (IsDlgButtonChecked(hwnd, i))
						db_set_w(hContact, MODNAME, "Icon", (WORD)i);

				/* set correct status */
				if (status == ID_STATUS_ONLINE || status == ID_STATUS_AWAY || (status == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)))
					db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE));
				else
					db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE);

				if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) {
					if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER))) {
						TCHAR text[512];
						GetDlgItemText(hwnd, IDC_TIMER, text, _countof(text));
						db_set_w(hContact, MODNAME, "Timer", (WORD)_ttoi(text));
					}
					else db_set_w(hContact, MODNAME, "Timer", 15);
				}
				else db_set_w(hContact, MODNAME, "Timer", 0);

				// always visible
				db_set_b(hContact, MODNAME, "AlwaysVisible", (BYTE)IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE));
				db_set_b(hContact, MODNAME, "VisibleUnlessOffline", (BYTE)IsDlgButtonChecked(hwnd, IDC_VISIBLE_UNLESS_OFFLINE));
			}
			return TRUE;
		}
		break;
	}
	return FALSE;
}
void PathManager::SetSdkPath(QString &path)
{
	SDKPATH = path;
	WriteSetting();
}
void PathManager::SetThreadNum(int num)
{
	THREADNUM = num;
	WriteSetting();
}
void PathManager::SetAliasesPasswd(QString &password)
{
	ALIASESPASSWD = password;
	WriteSetting();
}
void PathManager::SetOutPath(QString &path)
{
	OUTPATH = path;
	WriteSetting();
}
void PathManager::SetVersion(QString &ver)
{
	VERSION = ver;
	WriteSetting();
}
void PathManager::SetPasswd(QString &password)
{
	PASSWD = password;
	WriteSetting();
}
示例#26
0
void WriteDefaultSettings(SettingsStruct **head)
{
	WriteSetting(head, "Benchmark_Prefix", "X");
	WriteSetting(head, "CITO_Event_Prefix", "C");
	WriteSetting(head, "Earthcache_Prefix", "G");
	WriteSetting(head, "Event_Prefix", "E");
	WriteSetting(head, "Letterbox_Hybrid_Prefix", "B");
	WriteSetting(head, "Locationless_Prefix", "L");
	WriteSetting(head, "Mega_Prefix", "E");
	WriteSetting(head, "Multi_Prefix", "M");
	WriteSetting(head, "No_Type_Prefix", "W");
	WriteSetting(head, "Project_APE_Prefix", "A");
	WriteSetting(head, "Traditional_Prefix", "T");
	WriteSetting(head, "Unknown_Prefix", "U");
	WriteSetting(head, "Virtual_Prefix", "V");
	WriteSetting(head, "Webcam_Prefix", "W");

	WriteSetting(head, "Active_Yes", "Y");
	WriteSetting(head, "Active_No", "N");
	WriteSetting(head, "Bug_Yes", "Y");
	WriteSetting(head, "Bug_No", "N");
	WriteSetting(head, "Found_Yes", "Y");
	WriteSetting(head, "Found_No", "N");
}
void PathManager::SetPackWay(int way)
{
	PACKWAY = way;
	WriteSetting();
}