PXML support for file associations, and spitting out extra .desktop files for them...
[pandora-libraries.git] / apps / pndnotifyd.c
index fd1c1a1..c488257 100644 (file)
@@ -73,6 +73,7 @@ unsigned char g_info_p = 0; // spit out info .desktops
 
 // constants
 #define PNDNOTIFYD_LOGLEVEL "pndnotifyd.loglevel"
+#define PNDLOCKNAME "pndnotifyd-disco.lock"
 
 // decl's
 void consume_configuration ( void );
@@ -315,6 +316,13 @@ int main ( int argc, char *argv[] ) {
       /* run the discovery
        */
 
+      // do some 'locking'
+      pnd_log ( pndn_rem, "creating lockfile %s", PNDLOCKNAME );
+      if ( ! pnd_lock ( PNDLOCKNAME ) ) {
+       // problem .. well, too bad, we need to do this .. proceed!
+      }
+
+      // scan..
       pnd_log ( pndn_rem, "  Scanning desktop paths----------------------------\n" );
       if ( ! perform_discoveries ( desktop_appspath, overridespath, desktop_dotdesktoppath, desktop_iconpath ) ) {
        pnd_log ( pndn_rem, "    No applications found in desktop search path\n" );
@@ -327,6 +335,10 @@ int main ( int argc, char *argv[] ) {
        }
       }
 
+      // unlock
+      pnd_log ( pndn_rem, "clearing lockfile %s", PNDLOCKNAME );
+      pnd_unlock ( PNDLOCKNAME );
+
       // if we've got a hup script located, lets invoke it
       if ( pndhup ) {
        pnd_log ( pndn_rem, "Invoking hup script '%s'.\n", pndhup );
@@ -742,13 +754,16 @@ void process_discoveries ( pnd_box_handle applist, char *emitdesktoppath, char *
 
     // info .desktop
     if ( g_info_p && info_dotdesktoppath ) {
-      if ( pnd_emit_dotinfo ( info_dotdesktoppath, pndrun, d ) ) {
-       // nada
-      } else {
+      if ( ! pnd_emit_dotinfo ( info_dotdesktoppath, pndrun, d ) ) {
        pnd_log ( pndn_rem, "ERROR: Error creating info .desktop file for app: %s\n", pnd_box_get_key ( d ) );
       }
     }
 
+    // file association requests
+    if ( ! pnd_emit_dotassoc ( info_dotdesktoppath, pndrun, d ) ) {
+      pnd_log ( pndn_rem, "ERROR: Error creating file association .desktop file for app: %s\n", pnd_box_get_key ( d ) );
+    }
+
     // does this object request any mkdir's?
     if ( d -> mkdir_sp ) {