Back to index

indicator-appmenu  12.10.0
Functions
hud-dump-application.c File Reference
#include <glib.h>
#include "dump-app-info.h"

Go to the source code of this file.

Functions

int main (int argv, char *argc[])

Function Documentation

int main ( int  argv,
char *  argc[] 
)

Definition at line 26 of file hud-dump-application.c.

{
       if (argv != 2 && argv != 3) {
              g_printerr("Usage: %s <desktop file path> [gettext domain]\n", argc[0]);
              return 1;
       }

       const gchar * basecachedir = g_getenv("HUD_CACHE_DIR");
       if (basecachedir == NULL) {
              basecachedir = g_get_user_cache_dir();
       }

       gchar * cachedir = g_build_filename(basecachedir, "indicator-appmenu", NULL);
       if (!g_file_test(cachedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
              g_warning("Cache directory '%s' doesn't exist", cachedir);
              return 1;
       }
       g_free(cachedir);

       gchar * cachefile = g_build_filename(basecachedir, "indicator-appmenu", "hud-usage-log.sqlite", NULL);
       gboolean db_exists = g_file_test(cachefile, G_FILE_TEST_EXISTS);

       if (!db_exists) {
              g_warning("There is no HUD usage log: %s", cachefile);
              return 1;
       }

       sqlite3 * db;
       int open_status = sqlite3_open(cachefile, &db); 

       if (open_status != SQLITE_OK) {
              g_warning("Error opening usage DB: %s", cachefile);
              sqlite3_close(db);
              return 1;
       }

       gchar * domain = NULL;
       if (argv == 3) {
              domain = argc[2];
       }

       dump_app_info(argc[1], domain, db);

       sqlite3_close(db);
       g_free(cachefile);

       return 0;
}

Here is the call graph for this function: