coding standards question



Hello, all.

This is my first post to this list.  I'm Dave Loyall, from Omaha,
Nebraska, USA. :)

I intend to make a small modification to nm-applet and submit it
upstream.  A client of mine requires a new feature, which I can
implement.  I hope that others will be able to benefit from the change
as well.

The feature will allow administrators to set the default connection
scope for new connections to System.  Users with appropriate
permissions can already create System Connections, but this feature
will allow them to do with without having to click edit and check the
"available to all users" box.  (My client requires this, for purposes
of a smooth user experience on the systems he controls.)

So, I figure I can add key/value pair to the existing configuration
file.  I'll model my code after plugin_get_hostname(SCPluginKeyfile
*plugin) in network-manager-0.8/system-settings/plugins/keyfile/plugin.c.

...Which brings me to my question.  Why does plugin_get_hostname take
an SCPluginKeyfile as an argument?  'plugin' doesn't seem to be
touched inside this function.  Is it used in a way that I'm not
familiar with?

Does the function I'll make need to take SCPluginKeyfile *plugin as
well--I mean, is this required by some interface spec?

For bonus points: Is my strategy sound? :)

Cheers, and thanks,
--Dave

For your convenience:

//snip from network-manager-0.8/system-settings/plugins/keyfile/plugin.c
static char *
plugin_get_hostname (SCPluginKeyfile *plugin)
{
       GKeyFile *key_file;
       char *hostname = NULL;
       GError *error = NULL;

       key_file = g_key_file_new ();
       if (g_key_file_load_from_file (key_file, CONF_FILE,
G_KEY_FILE_NONE, &error))
               hostname = g_key_file_get_value (key_file, "keyfile",
"hostname", NULL);
       else {
               g_warning ("Error parsing file '%s': %s", CONF_FILE,
error->message);
               g_error_free (error);
       }

       g_key_file_free (key_file);

       return hostname;
}
//end snip

//more snip from the same
static void
sc_plugin_keyfile_init (SCPluginKeyfile *plugin)
{
       SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (plugin);

       priv->hostname = plugin_get_hostname (plugin);
}
//end snip


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]