Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Using private .ini-based settings

Development:

Do the following:

  1. Create an instance of SettingsiniFactory.
  2. Call ISettingsStoreFactory_Create(), which will return an ISettings implementation instance.
  3. Use this ISettings instance for all ISettings calls.

Run-time:

  1. An instance of iniStoreFactory is created.
  2. ISettingsStoreFactory_Create() internally creates a Settings Factory Store based on the parameters passed to ISettingsStoreFactory_Create() and returns an ISettings implementation.
  3. All ISettings calls operate on this ISettings implementation.

Follow these steps to add a private .ini file-based settings store to an application or component:

  1. Create an .ini file using a text editor and place it in the application or component directory in the EFS. The following .ini file example contains one section, with one setting:
    [section1]
    setting1=value1
  2. Add AEEPRIVID_PLFile to the privilege list of the Applet primitive in the application's CIF. This privilege is required to be able to write to or reset the .ini file. For example:
    Applet {
       appletid       =  AEECLSID_C_SETTINGS_APP,
       resbaseid      =  20, -- Applet base resource id
       applethostid   =  0,
       type           =  0,
       privs          = { AEEPRIVID_PLFile },
    }
  3. Add code to the application or component to access your settings.

    Note: Unlike public settings, access to a private store does not require the prefix "/myApp/myIniSettings".

    {
       // create an instance of the settings factory
       ISettingsStoreFactory *piSSF = NULL;
       if (SUCCESS == IEnv_CreateInstance(piEnv,
                   AEECLSID_SettingsIniFactory,
                   (void**) &piSSF)) {
    
         
          ISettings *piSettings = NULL;
          int result;
    
          // create an ISettings object for the specified store
          result = ISettingsStoreFactory_Create(piSSF,
                   "owner=0x12345678;path=mysettings.ini",
                   &piSettings);
    
          // get the value for section1/setting1
          if (SUCCESS == result) {
             char outbuf[32];
             result = ISettings_Get(piSettings, "section1/setting1",
                      outbuf, sizeof(outbuf), NULL);
    
            if (SUCCESS == result) {
               // outbuf will contain "value1"
            }
    
            ISettings_Release(piSettings);
            pSettings = NULL;
         }
    
         ISettingsStoreFactory_Release(piSSF);
         piSSF = NULL;
       }
    }