]> arthur.barton.de Git - netatalk.git/commitdiff
Spotlight module
authorFrank Lahm <frankahm@gmail.com>
Wed, 4 Jul 2012 13:36:08 +0000 (15:36 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 15 Aug 2012 18:14:22 +0000 (20:14 +0200)
etc/afpd/.gitignore
etc/afpd/Makefile.am
etc/afpd/main.c
etc/afpd/spotlight.c
etc/afpd/spotlight.h
etc/uams/uams_dhx2_pam.c

index 1138fa6bb558238558227316330a64af3a1dc264..bb2f33a71f728ddcb0b9238bc9fcb7baee5def05 100644 (file)
@@ -8,4 +8,5 @@ test_parse_mtab
 .deps
 .libs
 *.o
-
+*.la
+*.lo
\ No newline at end of file
index ca0d614d75658c2f4438afd59e4f22a31f6a0ec1..70bdf4e58b587c1f5887f2e662ee4e23e290ae40 100644 (file)
@@ -80,3 +80,14 @@ fce_LDADD = $(top_builddir)/libatalk/libatalk.la
 spot_SOURCES = spotlight.c spotlight_marshalling.c
 spot_CFLAGS = -DSPOT_TEST_MAIN
 spot_LDADD = $(top_builddir)/libatalk/libatalk.la
+
+moduledir = @UAMS_PATH@
+module_LTLIBRARIES = mod_spotlight.la
+
+mod_spotlight_la_SOURCES = spotlight_module.c
+mod_spotlight_la_CFLAGS  = \
+       -DDBUS_API_SUBJECT_TO_CHANGE \
+       -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include  
+mod_spotlight_la_LDFLAGS = \
+       -module -avoid-version \
+       -pthread -L/lib -ltrackerclient -ldbus-glib-1 -ldbus-1 -lpthread -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0
\ No newline at end of file
index e89d0a2e9e58d6aacf2e2cc5af061a56959bb5dc..e2a353e9bb2630c5911876aa7e19b93a9d3951cd 100644 (file)
@@ -38,6 +38,7 @@
 #include "fork.h"
 #include "uam_auth.h"
 #include "afp_zeroconf.h"
+#include "spotlight.h"
 
 #define AFP_LISTENERS 32
 #define FDSET_SAFETY  5
@@ -343,7 +344,8 @@ int main(int ac, char **av)
 
     /* Initialize */
     cnid_init();
-    
+    sl_mod_load(_PATH_AFPDUAMPATH "mod_spotlight.so");
+
     /* watch atp, dsi sockets and ipc parent/child file descriptor. */
 
     if (obj.options.flags & OPTION_KEEPSESSIONS) {
index 8eb26a7eb7fddea7b0626a6d525ac0e9a8d6ebbe..dc607a077ae215fd23e1f386fe7e7d8ed9cfd458 100644 (file)
@@ -35,6 +35,9 @@
 
 #include "spotlight.h"
 
+void *sl_module;
+struct sl_module_export *sl_module_export;
+
 
 /* Helper functions and stuff */
 static const char *neststrings[] = {
@@ -148,6 +151,30 @@ EC_CLEANUP:
     EC_EXIT;
 }
 
+/**************************************************************************************************
+ * Spotlight module functions
+ **************************************************************************************************/
+
+int sl_mod_load(const char *path)
+{
+    EC_INIT;
+
+    if ((sl_module = mod_open(path)) == NULL) {
+        LOG(log_error, logtype_sl, "sl_mod_load(%s): failed to load: %s", path, mod_error());
+        EC_FAIL;
+    }
+
+    if ((sl_module_export = mod_symbol(sl_module, "sl_mod")) == NULL) {
+        LOG(log_error, logtype_sl, "sl_mod_load(%s): mod_symbol error for symbol %s", path, "sl_mod");
+        EC_FAIL;
+    }
+
+    sl_module_export->sl_mod_init("test");
+   
+EC_CLEANUP:
+    EC_EXIT;
+}
+
 /**************************************************************************************************
  * AFP functions
  **************************************************************************************************/
@@ -204,16 +231,11 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_
         DALLOC_CTX *reply;
         EC_NULL( reply = talloc_zero(tmp_ctx, DALLOC_CTX) );
 
-        ret = sl_unpack(query, ibuf + 22);
-        dd_dump(query, 0);
-        if (ret != 0) {
-            LOG(log_error, logtype_sl, "sl_unpack");
-            EC_FAIL;
-        }
+        EC_NEG1_LOG( sl_unpack(query, ibuf + 22) );
+
         char **cmd;
         EC_NULL_LOG( cmd = dalloc_get(query, "DALLOC_CTX", 0, "DALLOC_CTX", 0, "char *", 0) );
 
-
         if (STRCMP(*cmd, ==, "fetchPropertiesForContext:")) {
             EC_ZERO_LOG( sl_rpc_fetchPropertiesForContext(obj, query, reply, vol) );
         } else if (STRCMP(*cmd, ==, "openQueryWithParams:forContext:")) {
@@ -225,19 +247,15 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_
             }
         }
 
-        /* Spotlight RPC status code ? 0 in all traces, we use 0xffffffff for an error, never seen from Apple */
-        if (ret == 0)
-            memset(rbuf, 0, 4);
-        else
-            memset(rbuf, 0xff, 4);
+        dd_dump(reply, 0);
+
+        memset(rbuf, 0, 4);
         *rbuflen += 4;
 
         int len;
         EC_NEG1_LOG( len = sl_pack(reply, rbuf + 4) );
         *rbuflen += len;
 
-        dd_dump(reply, 0);
-
         break;
     }
     }
index 241de83b351aa1bf5191d6d76a86f7e823d6551e..b845a47c986319ff159a275706d2c2f12361a7f2 100644 (file)
 #define SPOTLIGHT_H
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #include <atalk/dalloc.h>
 #include <atalk/globals.h>
 
+/**************************************************************************************************
+ * Spotlight module stuff
+ **************************************************************************************************/
+
+#define SL_MODULE_VERSION 1
+
+struct sl_module_export {
+    int sl_mod_version;
+    int (*sl_mod_init)        (void *);
+    int (*sl_mod_start_search)(void *);
+    int (*sl_mod_fetch_result)(void *);
+    int (*sl_mod_end_search)  (void *);
+};
+
+extern int sl_mod_load(const char *path);
+
+
+/**************************************************************************************************
+ * Spotlight RPC and marshalling stuff
+ **************************************************************************************************/
+
 /* FPSpotlightRPC subcommand codes */
 #define SPOTLIGHT_CMD_OPEN    1
 #define SPOTLIGHT_CMD_FLAGS   2
index d033d96b12c76e322a8fd143b90e283ff8847738..f20e5f11f29b430d82b9bcc7f5fbee507a8ce5df 100644 (file)
@@ -949,7 +949,6 @@ static void uam_cleanup(void)
     gcry_mpi_release(g);
 }
 
-
 UAM_MODULE_EXPORT struct uam_export uams_dhx2 = {
     UAM_MODULE_SERVER,
     UAM_MODULE_VERSION,