00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef NOTIFY_MGR_SERVER_PRV_H
00026 #define NOTIFY_MGR_SERVER_PRV_H
00027
00028 #include <pthread.h>
00029 #include <time.h>
00030 #include <hiker/ipc.h>
00031
00033 #define ALP_NOTIFY_MAX_BROADCASTS 100
00034
00036 #define ALP_NOTIFY_MAX_REGISTRATIONS 5000
00037
00038
00039
00040 typedef struct _AlpNotifyRegisterEntry AlpNotifyRegisterEntry;
00041 struct _AlpNotifyRegisterEntry {
00042 char * notifyType;
00043 char * appID;
00044 void * callback;
00045 void * userData;
00046 int priority;
00047 int flags;
00048 int pid;
00049 struct _AlpNotifyRegisterEntry * next;
00050 };
00051
00052 typedef struct _AlpNotifyRegisterHead AlpNotifyRegisterHead;
00053 struct _AlpNotifyRegisterHead {
00054 int hash;
00055 AlpNotifyRegisterEntry * entry;
00056 struct _AlpNotifyRegisterHead * next;
00057 };
00058
00059
00060
00061 typedef struct _AlpNotifyNotificationEntry AlpNotifyNotificationEntry;
00062 struct _AlpNotifyNotificationEntry {
00063 char * notifyType;
00064 char * details;
00065 char * appID;
00066 int length;
00067 int queue;
00068 int flags;
00069 int busy;
00070 int handled;
00071 int pid;
00072 pthread_t thread;
00073 AlpConnection * connect;
00074 AlpNotifyRegisterEntry * entry;
00075 struct _AlpNotifyNotificationEntry * next;
00076 };
00077
00078
00079
00080 typedef struct _AlpNotifyConnectionEntry AlpNotifyConnectionEntry;
00081 struct _AlpNotifyConnectionEntry {
00082 AlpConnection * connect;
00083 char * appID;
00084 struct _AlpNotifyConnectionEntry * next;
00085 };
00086
00087
00088
00089 typedef struct _AlpNotifyBroadcastEntry AlpNotifyBroadcastEntry;
00090 struct _AlpNotifyBroadcastEntry {
00091 int pid;
00092 time_t seconds;
00093 char * appID;
00094 struct _AlpNotifyBroadcastEntry * next;
00095 };
00096
00097
00098
00099 typedef struct _AlpNotifyPackageEntry AlpNotifyPackageEntry;
00100 struct _AlpNotifyPackageEntry {
00101 int count;
00102 char * appID;
00103 struct _AlpNotifyPackageEntry * next;
00104 };
00105
00106
00107 extern int alp_notify_register_add(AlpNotifyCmdRegister * request, int pid);
00108 extern AlpNotifyRegisterHead * alp_notify_register_get(const char * notifyType);
00109 extern void alp_notify_register_cleanup(void);
00110 extern int alp_notify_register_remove(AlpNotifyCmdUnregister * request);
00111 extern int alp_notify_register_remove_all(const char * appID, int server);
00112 extern int alp_notify_register_is_defined(const char * notifyType, const char * appID);
00113
00114
00115 extern int alp_notify_broadcast_get_pending(void);
00116 extern int alp_notify_broadcast_add(AlpNotifyCmdBroadcast * request, AlpConnection * connect);
00117 extern int alp_notify_broadcast_done(AlpNotifyCmdNotificationDone * done);
00118 extern void alp_notify_broadcast_do_pending(void);
00119 extern void alp_notify_broadcast_fixup(AlpNotifyRegisterEntry * old, AlpNotifyRegisterEntry * new);
00120 extern void alp_notify_broadcast_cleanup(void);
00121 extern int alp_notify_broadcast_is_active(AlpNotifyRegisterEntry * entry);
00122 extern void alp_notify_broadcast_set_inactive(const char * appID);
00123 extern void alp_notify_broadcast_cancel_sync(AlpConnection * connect);
00124
00125
00126
00127 extern int alp_notify_add(const char * appID, int pid);
00128 extern void alp_notify_remove(const char * appID);
00129 extern int alp_notify_get_pid(const char * appID);
00130 extern void alp_notify_cleanup(void);
00131
00132
00133 extern int alp_notify_ipc_send(const char * appID, void * buf, int length);
00134 extern void alp_notify_ipc_start_timer(void);
00135 extern void alp_notify_ipc_init(void);
00136
00137
00138 extern void alp_notify_base64_encode(unsigned char src[], unsigned char dst[], int length);
00139 extern int alp_notify_base64_encode_size(int length);
00140
00141
00142 extern int alp_notify_package_install(const char * appID);
00143 extern int alp_notify_package_uninstall(const char * appID);
00144 extern int alp_notify_package_cleanup(const char * notifyType);
00145 extern void alp_notify_package_remove(const char * appID);
00146 extern void alp_notify_package_init(void);
00147
00148
00149 extern int alp_notify_database_init(void);
00150 extern int alp_notify_database_add(AlpNotifyRegisterEntry * entry);
00151 extern int alp_notify_database_remove(AlpNotifyRegisterEntry * entry);
00152 extern int alp_notify_database_restore(void);
00153
00154 #endif