Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

bundlemgr.h

Go to the documentation of this file.
00001 /********************************************************************
00002 
00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved.
00004 
00005 The contents of this file are subject to the Mozilla Public License Version
00006 1.1 (the "License"); you may not use this file except in compliance with
00007 the License. You may obtain a copy of the License at
00008 http://www.mozilla.org/MPL/
00009 
00010 Software distributed under the License is distributed on an "AS IS" basis,
00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012 for the specific language governing rights and limitations under the
00013 License.
00014 
00015 The Original Code is the entire contents of this file.
00016 
00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc.
00018 
00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All
00020 Rights Reserved.
00021 
00022 Contributor(s): none.
00023 
00024 ********************************************************************/
00033 #ifndef ALP_BUNDLEMGR_H_
00034 #define ALP_BUNDLEMGR_H_
00035 
00036 #include <hiker/types.h> // for alp_status_t
00037 #include <glib.h> //for gboolean, GList, GArray, gchar
00038 #include <glib-object.h> // for GClosure*
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00261 // -----------------------------------------------------------------------
00262 
00277 alp_status_t alp_bundle_init(void);
00278 
00284 alp_status_t alp_bundle_fini(void);
00285 
00287 
00288 // -----------------------------------------------------------------------
00289 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307 
00308 
00309 
00310 typedef struct _AlpBundle { guint value; } AlpBundle;
00311 
00315 typedef struct _AlpBundleRef * AlpBundleRef;
00316 
00320 static inline gboolean alp_bundle_is_NULL(AlpBundle index)
00321 {
00322         return index.value == 0;
00323 }
00324 
00326 #define ALP_BUNDLE_NULL ((struct _AlpBundle){0})
00327 
00328 #define ALP_BUNDLE_REF_NULL (NULL)
00329                            
00331 #define ALP_STATUS_BUNDLEMGR_FAILURE (ALP_CLASS_BUNDLEMGR | 0x00010000)
00332                            
00333   
00335 
00336 // -----------------------------------------------------------------------
00337 
00343 
00344 
00345 
00346 
00347 
00348 AlpBundle alp_bundle_by_name(const char * name);
00349 
00376 GArray * alp_bundle_search(const char * name, gboolean named, const char * scheme, const char * store, const char * property);
00377 
00381 GList * alp_bundle_list_schemes(void);
00384 GList * alp_bundle_list_stores(void);
00387 GList * alp_bundle_list_names(void);
00390 GList * alp_bundle_list_properties(void);
00391 
00393 
00394 // -----------------------------------------------------------------------
00395 
00400 
00401 
00402 
00403 
00404 
00405 
00406 
00407 
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 AlpBundle alp_bundle_move_to_store(AlpBundle bundle, const char * store, int flags);
00419 
00420           
00436 AlpBundle alp_bundle_copy_to_store(AlpBundle bundle, const char * store, int flags);
00437 
00442 alp_status_t alp_bundle_delete(AlpBundle bundle, int everything);
00443 
00444 // metadata includes name, refcount, version, misc data
00445 GHashTable * alp_bundle_metadata(AlpBundle);
00446 
00456 gchar * alp_bundle_metadata_value(AlpBundle index, const char * key);
00457 
00473 gchar * alp_bundle_rw_pathname(AlpBundle index, const char * file_path, gboolean vivify);
00474 
00480 #define ALP_BUNDLE_RW_SAVED     "/saved/"
00481 
00482 
00493 alp_status_t alp_bundle_rw_delete(AlpBundle index, const char * folder_path, gboolean itself);
00494 
00495 GHashTable * alp_bundle_properties(AlpBundle index, const char * property, int which);
00496 
00497 GList * alp_bundle_all_properties(AlpBundle index);
00498 
00509 gchar * alp_bundle_property_value(AlpBundle index, const char * property, int which, const char * key);
00510 
00519 AlpBundle alp_bundle_locate_file(const char * filename);
00520 
00537 AlpBundle alp_bundle_me();
00538 
00545 AlpBundle alp_bundle_application();
00546 
00548 
00549 // -----------------------------------------------------------------------
00550 
00557 GHashTable * alp_bundle_store(const char * store);
00558  
00561 gchar * alp_bundle_store_value(const char * store, const char * key);
00562 
00564 
00565 // -----------------------------------------------------------------------  
00566 
00581 AlpBundleRef alp_bundle_open(AlpBundle idx);
00582 
00593 alp_status_t alp_bundle_close(AlpBundleRef ref);
00594            
00602 AlpBundle alp_bundle_ref_bundle(AlpBundleRef ref);
00603 
00628 AlpBundleRef alp_bundle_ref_me();
00629 
00630            
00642 AlpBundleRef alp_bundle_ref_application();
00643 
00662 GIOChannel * alp_bundle_ref_ro_channel(AlpBundleRef ref, const char * path);
00663 
00664            
00682 gchar * alp_bundle_ref_ro_pathname(AlpBundleRef ref, const char * path);
00683 
00702 alp_status_t alp_bundle_ref_ro_data(AlpBundleRef ref, const char * path, gchar ** data, size_t * length);
00703 
00704 
00721 GList * alp_bundle_ref_ro_directory(AlpBundleRef ref, const char * path, gboolean recurse);
00722 
00747 gchar * alp_bundle_ref_ro_tempfile(AlpBundleRef ref, const char * path, gboolean keep, const char * ext);
00748 
00757 alp_status_t alp_bundle_tempfile_release(gchar * tempfile);
00758 
00760 #define ALP_BUNDLE_BAR_MANIFEST "/Manifest.xml"
00761 
00763 
00764 // -----------------------------------------------------------------------
00765 
00786 typedef struct _AlpBundleProgressiveData AlpBundleProgressiveData;
00787 struct _AlpBundleProgressiveData {
00790         gint version;
00793         gboolean (*callback)(AlpBundleProgressiveData*);
00794         
00795         enum {
00796                 ALP_BUNDLE_PROGRESSIVE_HAVE_BYTES_SO_FAR        = 1<<0,
00797                 ALP_BUNDLE_PROGRESSIVE_HAVE_TOTAL_BYTES = 1<<1,
00798                 ALP_BUNDLE_PROGRESSIVE_HAVE_MAX_OVERHEAD        = 1<<2,
00799                 ALP_BUNDLE_PROGRESSIVE_HAVE_METADATA            = 1<<3,
00800                 ALP_BUNDLE_PROGRESSIVE_HAVE_PROPERTIES          = 1<<4,
00801                 ALP_BUNDLE_PROGRESSIVE_HAVE_FILENAME            = 1<<5,
00802                 ALP_BUNDLE_PROGRESSIVE_HAVE_MIMETYPE            = 1<<6,
00803                 ALP_BUNDLE_PROGRESSIVE_HAVE_STORE               = 1<<7,
00804                 ALP_BUNDLE_PROGRESSIVE_HAVE_OVERWRITING_PKGINDEX = 1<<8,
00805                 ALP_BUNDLE_PROGRESSIVE_HAVE_PKGINDEX            = 1<<9,
00806                 ALP_BUNDLE_PROGRESSIVE_HAVE_FINISHED            = 1<<10
00807         } ALP_BUNDLE_PROGRESSIVE_ENUM;
00808         
00812         guint new_state;
00813         
00816         guint current_state;
00817 
00820         guint bytes_so_far;
00823         guint total_bytes;
00828         guint max_overhead;
00829 
00831         GHashTable * metadata;
00833         GHashTable * properties;
00835         const char * recommended_filename;
00837         const char * recommended_mimetype;
00839         const char * store;
00841         AlpBundle overwriting_index;
00843         AlpBundle index;
00844         
00847         void * userdata;
00848 };
00849 
00850 enum {
00853         ALP_BUNDLE_PROGRESSIVE_DATA_VERSION = 1
00854 };
00855 
00856 
00880 int alp_bundle_image_verify(const char * provide_filename, const char * provide_mimetype, GIOChannel * image, gboolean full_check, GHashTable ** metadata, GHashTable ** properties, AlpBundleProgressiveData * progress);
00881 
00882 
00904 AlpBundle alp_bundle_image_install(const char * provide_filename, const char * provide_mimetype, GIOChannel * image, const char * destination_store, int flags, GHashTable ** metadata, GHashTable ** properties,  AlpBundleProgressiveData * progress); 
00905 
00922 alp_status_t alp_bundle_image_archive(AlpBundle index, char ** desired_filename, char ** desired_mimetype, GIOChannel * image, AlpBundleProgressiveData * progress); 
00923 
00925 
00926 // -----------------------------------------------------------------------
00927 
01018 GClosure * alp_bundle_acquire_entrypoint(const char * url, AlpBundleRef relativeRef /* may be NULL */);
01019 
01052 gchar * alp_bundle_acquire_ro_pathname(const char * url, AlpBundleRef* openRef, AlpBundleRef relativeRef /* may be NULL */);
01053 
01089 GIOChannel * alp_bundle_acquire_ro_channel(const char * url, AlpBundleRef relativeRef/* may be NULL */);
01090 
01123 alp_status_t alp_bundle_acquire_ro_data(const char * url, gchar ** data, size_t * length, AlpBundleRef relativeRef /* may be NULL */);
01124 
01167 gchar * alp_bundle_acquire_ro_tempfile(const char * url, AlpBundleRef* openRef, gboolean keep, const char * ext, AlpBundleRef relativeRef /* may be NULL */);
01168 
01173 typedef struct {
01174   // initial layout should match that of GCClosure
01175   GClosure      closure;
01176   gpointer      callback;
01177   int           struct_version;
01178   AlpBundleRef  ref;
01179   void *        dlhandle;
01180   gchar *       path;
01181   gchar *       sym;
01182   int           result_signal;
01183 } AlpBundleEntrypointClosure;
01184 
01185 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_VERSION 1
01186 
01188 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_REF(closure) (((AlpBundleEntrypointClosure*)(closure))->ref)
01189 
01191 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_DLHANDLE(closure) (((AlpBundleEntrypointClosure*)(closure))->dlhandle)
01192 
01194 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_CALLBACK(closure) (((AlpBundleEntrypointClosure*)(closure))->callback)
01195 
01197 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_PATH(closure) (((AlpBundleEntrypointClosure*)(closure))->path)
01198 
01200 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_SYM(closure) (((AlpBundleEntrypointClosure*)(closure))->sym)
01201 
01204 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_RESULT_SIGNAL(closure) (((AlpBundleEntrypointClosure*)(closure))->result_signal)
01205 
01226 int alp_bundle_entrypoint_closure_execve(GClosure * closure, char * const argv[], char * const envp[]);
01227 
01245 int alp_bundle_entrypoint_closure_execl(GClosure * closure, const char * arg, ...);
01246 
01248 // -----------------------------------------------------------------------
01249 
01258 #define ALP_NOTIFY_EVENT_BUNDLE_DELETE "/alp/bundlemgr/delete_bundle"
01259 typedef struct _AlpNotifyEventBundleDelete AlpNotifyEventBundleDelete;
01260 struct _AlpNotifyEventBundleDelete {
01261     AlpBundle index;
01262     int flags;
01263     gboolean named;
01264     char name[];
01265 };
01266  
01271 #define ALP_NOTIFY_EVENT_BUNDLE_MOVE "/alp/bundlemgr/move_bundle"
01272 typedef struct _AlpNotifyEventBundleMove AlpNotifyEventBundleMove;
01273 struct _AlpNotifyEventBundleMove {
01274     AlpBundle index;
01275     char store[];
01276 };
01277 
01282 #define ALP_NOTIFY_EVENT_BUNDLE_COPY "/alp/bundlemgr/copy_bundle"
01283 typedef struct _AlpNotifyEventBundleCopy AlpNotifyEventBundleCopy;
01284 struct _AlpNotifyEventBundleCopy {
01285     AlpBundle index;
01286     char store[];
01287 };
01288  
01291 #define ALP_NOTIFY_EVENT_BUNDLE_REGISTER "/alp/bundlemgr/register_bundle"
01292 typedef struct _AlpNotifyEventBundleRegister AlpNotifyEventBundleRegister;
01293 struct _AlpNotifyEventBundleRegister {
01294     AlpBundle index;
01295 };
01296 
01299 #define ALP_NOTIFY_EVENT_BUNDLE_UNREGISTER "/alp/bundlemgr/unregister_bundle"
01300 typedef struct _AlpNotifyEventBundleUnregister AlpNotifyEventBundleUnregister;
01301 struct _AlpNotifyEventBundleUnregister {
01302     AlpBundle index;
01303 };
01304  
01307 #define ALP_NOTIFY_EVENT_BUNDLE_RESET_EVERYTHING "/alp/bundlemgr/reset_everything"
01308 typedef struct _AlpNotifyEventBundleResetEverything AlpNotifyEventBundleResetEverything;
01309 struct _AlpNotifyEventBundleResetEverything {
01310 };
01311 
01314 #define ALP_NOTIFY_EVENT_BUNDLE_NAME_ADDED "/alp/bundlemgr/name_added"
01315 typedef struct _AlpNotifyEventBundleNameAdded AlpNotifyEventBundleNameAdded;
01316 struct _AlpNotifyEventBundleNameAdded {
01317     AlpBundle index;
01318     char name[];
01319 };
01320 
01323 #define ALP_NOTIFY_EVENT_BUNDLE_NAME_REMOVED "/alp/bundlemgr/name_removed"
01324 typedef struct _AlpNotifyEventBundleNameRemoved AlpNotifyEventBundleNameRemoved;
01325 struct _AlpNotifyEventBundleNameRemoved {
01326     AlpBundle index;
01327     char name[];
01328 };
01329 
01333 #define ALP_NOTIFY_EVENT_BUNDLE_NAME_CHANGED "/alp/bundlemgr/name_changed"
01334 typedef struct _AlpNotifyEventBundleNameChanged AlpNotifyEventBundleNameChanged;
01335 struct _AlpNotifyEventBundleNameChanged {
01336     AlpBundle old_index;
01337     AlpBundle new_index;
01338     char name[];
01339 };
01340  
01341  
01343 
01344 // -----------------------------------------------------------------------
01350 
01351 #define ALP_BUNDLE_PROPERTY_APPLICATION "application"
01352 
01353 
01355 
01356 // -----------------------------------------------------------------------
01362 
01363 #define ALP_BUNDLE_TYPE_BAR             "bar"
01364 
01365 
01367 
01368 // -----------------------------------------------------------------------
01373 
01374 #define ALP_BUNDLE_FLAG_DELETE_EVERYTHING 1
01375 
01376 #define ALP_BUNDLE_FLAG_OVERWRITE_DUPLICATE 128
01377 
01378 
01389 const char * alp_bundle_ref_gettextdomain(AlpBundleRef ref);
01390 
01397 const char * alp_bundle_ref_name(AlpBundleRef ref);
01398 
01405 gchar * alp_bundle_name(AlpBundle index);
01406 
01419 gchar * alp_bundle_saved_settings(AlpBundle index, const char * key);
01420 
01433 gchar * alp_bundle_unsaved_settings(AlpBundle index, const char * key);
01434 
01435 
01442 #define alp_bundle_acquire_glade_xml(url, root) \
01443 ({                                                      \
01444   AlpBundleRef _ref;                                    \
01445   AlpBundleRef _me = alp_bundle_ref_me();               \
01446   gchar * _pathname = alp_bundle_acquire_ro_pathname((url), &_ref, _me);        \
01447   GladeXML * _result = glade_xml_new_with_domain(_pathname, (root), alp_bundle_ref_gettextdomain(_ref));        \
01448   g_free(_pathname);                                    \
01449   alp_bundle_close(_ref);                               \
01450   _result;                                              \
01451 })
01452 
01460 #define alp_bundle_ref_cgettext(ref, text, category)            \
01461   dcgettext(alp_bundle_ref_gettextdomain((ref)), (text), (category))    \
01462 
01463 
01469 #define alp_bundle_ref_gettext(ref, text)                       \
01470   dgettext(alp_bundle_ref_gettextdomain((ref)), (text)) \
01471 
01472 
01484 #define alp_bundle_gettext(text)                                \
01485   dgettext(alp_bundle_ref_gettextdomain(alp_bundle_ref_me()), (text))
01486 
01499 alp_status_t alp_bundle_error(void);
01500 
01502 
01503 
01504 // -----------------------------------------------------------------------
01521 GHashTable * alp_bundle_scheme_values(const char * scheme);
01522 
01533 gchar * alp_bundle_scheme_value(const char * scheme, const char * key);
01534 
01550 gchar * alp_bundle_scheme_identify(const char * filename, const char * mimetype);
01551 
01553 
01554 
01556 
01557 #ifdef __cplusplus
01558 }
01559 #endif
01560 
01561 
01562 #endif /* ALP_BUNDLEMGR_H_ */
01563 

Generated on Sat Dec 16 20:29:47 2006 for hiker-0.9 by  doxygen 1.4.4