bool ConfigManager::Read(const wxString& name, wxColour* ret)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlElement *c = (TiXmlElement *) parentHandle.FirstChild(cbU2C(key)).FirstChild("colour").Element();

    if (c)
    {
        const char *isNull = c->Attribute("null");
        if (isNull && strcmp(isNull, "true") == 0)
        {
            *ret = wxNullColour;
            return true;
        }
        else
        {
            int r, g, b;
            if (c->QueryIntAttribute("r", &r) == TIXML_SUCCESS
                    && c->QueryIntAttribute("g", &g) == TIXML_SUCCESS
                    && c->QueryIntAttribute("b", &b) == TIXML_SUCCESS)
            {
                ret->Set(r, g, b);
                return true;
            }
        }
    }
    *ret = wxNullColour;
    return false;
}
wxString ConfigManager::ReadBinary(const wxString& name)
{
    wxString str;
    wxString key(name);
    TiXmlElement* e = AssertPath(key);
    unsigned int crc = 0;

    TiXmlHandle parentHandle(e);
    TiXmlElement* bin = parentHandle.FirstChild(cbU2C(key)).FirstChild("bin").Element();

    if (!bin)
        return wxEmptyString;

    if (bin->QueryIntAttribute("crc", (int*)&crc) != TIXML_SUCCESS)
        return wxEmptyString;

    if (const TiXmlText* t = bin->FirstChild()->ToText())
    {
        str.assign(cbC2U(t->Value()));
        str = wxBase64::Decode(str);
        if (crc ==  wxCrc32::FromString(str))
            return str;
    }
    return wxEmptyString;
}
bool ConfigManager::Read(const wxString& name, wxString* str)
{
    if (name.IsSameAs(CfgMgrConsts::app_path))
    {
        str->assign(app_path);
        return true;
    }
    else if (name.IsSameAs(CfgMgrConsts::data_path))
    {
        str->assign(data_path_global);
        return true;
    }

    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlText *t = (TiXmlText *) parentHandle.FirstChild(cbU2C(key)).FirstChild("str").FirstChild().Node();

    if (t)
    {
        str->assign(cbC2U(t->Value()));
        return true;
    }
    return false;
}
bool ConfigManager::Exists(const wxString& name)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlElement *leaf = parentHandle.FirstChild(cbU2C(key)).Element();

    return leaf;
}
bool ConfigManager::Read(const wxString& name,  int* value)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlElement *leaf = parentHandle.FirstChild(cbU2C(key)).Element();

    if (leaf)
        return leaf->QueryIntAttribute("int", value) == TIXML_SUCCESS;
    return false;
}
bool ConfigManager::Read(const wxString& name,  bool* value)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlElement *leaf = parentHandle.FirstChild(cbU2C(key)).Element();

    if (leaf && leaf->Attribute("bool"))
    {
        *value = leaf->Attribute("bool")[0] == '1';
        return true;
    }
    return false;
}
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::StringSet* set)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("sset").Node();

    TiXmlNode *curr = nullptr;
    if (mNode)
    {
        while ((curr = mNode->IterateChildren(curr)))
            set->insert(cbC2U(curr->FirstChild()->ToText()->Value()));
    }
}
void ConfigManager::Read(const wxString& name, wxArrayString *arrayString)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *asNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("astr").Node();

    TiXmlNode *curr = nullptr;
    if (asNode)
    {
        while ((curr = asNode->IterateChildren("s", curr)))
            arrayString->Add(cbC2U(curr->FirstChild()->ToText()->Value()));
    }
}
Example #9
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::StringToStringMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("ssmap").Node();

    TiXmlNode *curr = 0;
    if(mNode)
    {
        while((curr = mNode->IterateChildren(curr)))
            (*map)[cbC2U(curr->Value())] = cbC2U(curr->FirstChild()->ToText()->Value());
    }
}
Example #10
0
bool ConfigManager::Read(const wxString& name, ISerializable* object)
{
    wxString str;
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlText *t = (TiXmlText *) parentHandle.FirstChild(cbU2C(key)).FirstChild("obj").FirstChild().Node();

    if (t)
    {
        str.assign(cbC2U(t->Value()));
        object->SerializeIn(wxBase64::Decode(str));
    }
    return wxEmptyString;
}
Example #11
0
void ConfigManager::Read(const wxString& name, ConfigManagerContainer::IntToStringMap* map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlNode *mNode = parentHandle.FirstChild(cbU2C(key)).FirstChild("ismap").Node();

    TiXmlNode *curr = nullptr;
    long tmp;
    if (mNode)
    {
        while ((curr = mNode->IterateChildren(curr)))
        {
            cbC2U(curr->Value()).Mid(1).ToLong(&tmp);
            (*map)[tmp] = cbC2U(curr->FirstChild()->ToText()->Value());
        }
    }
}
bool ConfigManager::Read(const wxString& name, wxColour* ret)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlElement *c = (TiXmlElement *) parentHandle.FirstChild(cbU2C(key)).FirstChild("colour").Element();

    if (c)
    {
        int r, g, b;
        if (c->QueryIntAttribute("r", &r) == TIXML_SUCCESS
                && c->QueryIntAttribute("g", &g) == TIXML_SUCCESS
                && c->QueryIntAttribute("b", &b) == TIXML_SUCCESS)
            ret->Set(r, g, b);
        return true;
    }
    return false;
}
Example #13
0
void CMTPDeviceDataProvider::AddFolderRecursiveL( const TMTPNotificationParamsFolderChange& aFolder )
    {
    OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL_ENTRY );
    
    TPtrC folderRight( aFolder.iFolderChanged );
    OstTraceExt1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, 
            "Folder Addition - DriveAndFullPath:%S", folderRight);
    
    if ( !BaflUtils::FolderExists( Framework().Fs(), folderRight ))
    	{
        OstTrace0(TRACE_NORMAL, DUP1_CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, 
                "Folder not exist in file system");
    	User::Leave( KErrArgument );
    	}
    
    TUint32 parentHandle( KMTPHandleNoParent );
    TUint32 handle( KMTPHandleNoParent );
    TInt pos( KErrNotFound );
    TInt lengthOfRight( folderRight.Length());
    TFileName folderLeft;
    
    // get root path of storage
    TInt driveNumber;
    User::LeaveIfError(Framework().Fs().CharToDrive(folderRight[0], driveNumber));
    RBuf rootDirPath;
    rootDirPath.CreateL(KMaxFileName);
    rootDirPath.CleanupClosePushL();
    iDevDpSingletons.ConfigMgr().GetRootDirPathL(driveNumber, rootDirPath);
    rootDirPath.Insert(0, folderRight.Mid(0, 2));// get drive:
    
    /*
    Go through from beginning.
    when this while end, folderLeft keeps the top
    layer folder which has no handle
    */
    do 
        {
        pos = folderRight.Locate( KPathDelimiter );
        if ( KErrNotFound == pos )
            {
            break;
            }
        folderLeft.Append( folderRight.Left( pos + 1 ));
        lengthOfRight = folderRight.Length()-pos -1;
        folderRight.Set( folderRight.Right( lengthOfRight ));
        
        if ( rootDirPath.FindF(folderLeft) != KErrNotFound)
        	{
        	//first time, root folder
        	//continue
        	continue;
        	}
        parentHandle = handle;
        handle = Framework().ObjectMgr().HandleL( folderLeft );
        }
    while( KMTPHandleNone != handle );
    CleanupStack::PopAndDestroy(&rootDirPath);

    if ( KMTPHandleNone == handle )
        {
        OstTrace0(TRACE_NORMAL, DUP2_CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, 
                "need to add entry into mtp database");
        
        CMTPObjectMetaData* folderObject = CMTPObjectMetaData::NewL();
        TUint32 storageId = GetStorageIdL( folderLeft );
        
        while( 1 )
            {
            parentHandle = AddEntryL( folderLeft, parentHandle, storageId, *folderObject );
            OnDeviceFolderChangedL( EMTPEventCodeObjectAdded, *folderObject );

            pos = folderRight.Locate( KPathDelimiter );
            lengthOfRight = folderRight.Length()-pos -1;
            if ( KErrNotFound == pos )
            	{
            	break;
            	}
            folderLeft.Append( folderRight.Left( pos + 1  ));
            folderRight.Set( folderRight.Right( lengthOfRight ));
            }
            
        delete folderObject;
        }
    
    OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL_EXIT );
    }