Esempio n. 1
0
bool ReadIniDouble(dictionary *dict, const char *section, double &value, string &err)
{
    string str;
    if (!ReadIniString(dict, section, str, err)) {
        return false;
    }

    value = atof(str.c_str());
    return true;
}
Esempio n. 2
0
bool ReadIniString(dictionary *dict, const string& section, string &value, string &err)
{
    return ReadIniString(dict, section.c_str(), value, err);
}
Esempio n. 3
0
void Window::GetWindowState(int aSaveFlags)
{
    if (Name==NULL) Name=strdup(Title);
    Flags|=aSaveFlags | W_SAVEPOS;

    WINDOWPLACEMENT wp;
    wp.length=sizeof(WINDOWPLACEMENT);
    if (hWnd) GetWindowPlacement(hWnd,&wp); // fill max position
    wp.flags=0;
    wp.showCmd=SW_SHOWNORMAL;

    String S;
    ReadIniString(Name,"State",S);
    if (!S.Empty())
    {
        if (S=="MinFromMax")
        {
            Style|=WS_MINIMIZE;
            wp.flags=WPF_RESTORETOMAXIMIZED;
            wp.showCmd=SW_SHOWMINIMIZED;
        }
        else if (S=="Maximized")
        {
            Style|=WS_MAXIMIZE;
            wp.showCmd=SW_SHOWMAXIMIZED;
        }
        else if (S=="Minimized")
        {
            Style|=WS_MINIMIZE;
            wp.showCmd=SW_SHOWMINIMIZED;
        }
        else if (S=="Hidden")
        {
            wp.showCmd=SW_HIDE;
        }
    }

    ReadIniString(Name,"Window",S="");
    if (!S.Empty())
    {
        int ww,hh;
        sscanf(S,"%d,%d,%d,%d",&x,&y,&ww,&hh);
        if (!(Flags & W_NOSIZE)) {
            w=ww-x;
            h=hh-y;
        }
        //	wp.ptMinPosition
        //	wp.ptMaxPosition.x=0;
        //	wp.ptMaxPosition.y=0;
        wp.rcNormalPosition.left=x;
        wp.rcNormalPosition.top=y;
        wp.rcNormalPosition.right=x+w;
        wp.rcNormalPosition.bottom=y+h;
    }
    if (this==App::MainWindow)
    {
        App::nCmdShow=wp.showCmd;
        // minimizing MDI frame now messes up
        if (wp.showCmd==SW_SHOWMINIMIZED)
        {
            wp.showCmd= (wp.flags==WPF_RESTORETOMAXIMIZED) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
        }
    }
    if (hWnd) SetWindowPlacement(hWnd,&wp);
}
Esempio n. 4
0
OP_STATUS EudoraImporter::Init()
{
	if (!m_eudora_ini)
		return OpStatus::ERR;

	GetModel()->DeleteAll();

	OpString account;

	RETURN_IF_ERROR(ReadIniString(DOMINANT_PERSONALITY, UNI_L("POPAccount"), account));

	if (account.IsEmpty())
		return OpStatus::ERR;

	//AutoReceiveAttachmentsDirectory might have been defined, which means that
	// if we are not importing in situ but a transported folder we have to guess at the
	// right path since the attachments folder is absolute
	OpString att_folder;
	ReadIniString(DOMINANT_PERSONALITY, UNI_L("AutoReceiveAttachmentsDirectory"), att_folder);

	if (att_folder.IsEmpty())
		m_attachments_folder_name.Set(UNI_L("attach"));
	else
	{
		// Find leaf folder name and use that as attachments folder name
		int pos = att_folder.FindLastOf('\\');	// find last path separator
		if (pos != KNotFound)
			m_attachments_folder_name.Set(att_folder.CStr() + pos + 1);	// strip path
	}

	OpString imported;
	OpStatus::Ignore(g_languageManager->GetString(Str::S_IMPORTED, imported));
	OpStatus::Ignore(imported.Insert(0, UNI_L(" (")));
	OpStatus::Ignore(imported.Append(UNI_L(")")));

	OpString m2FolderPath;
	m2FolderPath.Set(account);
	m2FolderPath.Append(imported);

	INT32 branch;

	ImporterModelItem* item = OP_NEW(ImporterModelItem, (OpTypedObject::IMPORT_ACCOUNT_TYPE, account, *m_file_list.Get(0), m2FolderPath, UNI_L("")));
	if (item)
	{
		branch = GetModel()->AddLast(item); // add the dominant account as first entry

		InsertMailBoxes(m_folder_path, m2FolderPath, branch);
	}

	for (int persona = 0; persona < MAX_PERSONA; persona++)
	{
		uni_char buf[5];
		OpString str;
		str.Set(UNI_L("Persona"));
		str.Append(uni_itoa(persona, buf, 10));

		OpString entry;
		ReadIniString(UNI_L("Personalities"), str, entry);
		if (entry.IsEmpty())
			break;

		ReadIniString(entry, UNI_L("POPAccount"), account);

		if (account.HasContent())
		{
			OpString imported;
			m2FolderPath.Set(account);
			OpStatus::Ignore(g_languageManager->GetString(Str::S_IMPORTED, imported));
			OpStatus::Ignore(imported.Insert(0, UNI_L(" (")));
			OpStatus::Ignore(imported.Append(UNI_L(")")));
			OpStatus::Ignore(m2FolderPath.Append(imported));

			item = OP_NEW(ImporterModelItem, (OpTypedObject::IMPORT_ACCOUNT_TYPE, account, *m_file_list.Get(0), m2FolderPath, UNI_L("")));
			if (item)
			{
				branch = GetModel()->AddLast(item);

				InsertMailBoxes(m_folder_path, m2FolderPath, branch);
			}
		}
	}
	return OpStatus::OK;
}
Esempio n. 5
0
static void DeserializeAdvancedSettings(const WCHAR *filepath, SettingInfo *info, size_t count, void *structBase)
{
    char *base = (char *)structBase;
    const WCHAR *section = NULL;
    INT intValue, intValueDef;
    ScopedMem<WCHAR> strValue;

    for (size_t i = 0; i < count; i++) {
        SettingInfo& meta = info[i];
        CrashIf(meta.type != SType_Section && !section);
        switch (meta.type) {
        case SType_Section:
            section = meta.name;
            break;
        case SType_Bool:
            intValueDef = *(bool *)(base + meta.offset) ? 1 : 0;
            intValue = GetPrivateProfileInt(section, meta.name, intValueDef, filepath);
            *(bool *)(base + meta.offset) = intValue != 0;
            break;
        case SType_Color:
            strValue.Set(ReadIniString(filepath, section, meta.name));
            if (str::Parse(strValue, L"#%6x", &intValue))
                *(COLORREF *)(base + meta.offset) = (COLORREF)intValue;
            break;
        case SType_Int:
            intValueDef = *(int *)(base + meta.offset);
            intValue = GetPrivateProfileInt(section, meta.name, intValueDef, filepath);
            *(int *)(base + meta.offset) = intValue;
            break;
        case SType_String:
            strValue.Set(ReadIniString(filepath, section, meta.name, L"\n"));
            if (!str::Eq(strValue, L"\n"))
                ((ScopedMem<WCHAR> *)(base + meta.offset))->Set(strValue.StealData());
            break;
        case SType_BoolVec:
        case SType_ColorVec:
        case SType_IntVec:
        case SType_StringVec:
            ScopedMem<WCHAR> sections(ReadIniString(filepath, section, NULL));
            for (const WCHAR *name = sections; *name; name += str::Len(name) + 1) {
                UINT idx;
                if (str::Eq(str::Parse(name, L"%u.", &idx), meta.name)) {
                    if (SType_BoolVec == meta.type) {
                        bool value = GetPrivateProfileInt(section, name, 0, filepath) != 0;
                        ((Vec<bool> *)(base + meta.offset))->InsertAt(idx, value);
                    }
                    else if (SType_ColorVec == meta.type) {
                        strValue.Set(ReadIniString(filepath, section, name));
                        if (str::Parse(strValue, L"#%6x", &intValue)) {
                            COLORREF value = (COLORREF)intValue;
                            ((Vec<COLORREF> *)(base + meta.offset))->InsertAt(idx, value);
                        }
                    }
                    else if (SType_IntVec == meta.type) {
                        intValue = GetPrivateProfileInt(section, name, 0, filepath);
                        ((Vec<int> *)(base + meta.offset))->InsertAt(idx, intValue);
                    }
                    else {
                        strValue.Set(ReadIniString(filepath, section, name));
                        WStrVec *strVec = (WStrVec *)(base + meta.offset);
                        // TODO: shouldn't InsertAt free the previous string?
                        if (idx < strVec->Count())
                            free(strVec->At(idx));
                        strVec->InsertAt(idx, strValue.StealData());
                    }
                }
            }
            break;
        }
    }
}