00001 /******************************************************************** 00002 * 00003 * Copyright (c) 1999-2008 ACCESS CO., LTD. All rights reserved. 00004 * Copyright 2006, 2007, ACCESS Systems Americas, Inc. All rights reserved. 00005 * 00006 * Version: MPL 1.1/LGPL 2.1 00007 * 00008 * The contents of this file are subject to the Mozilla Public License Version 00009 * 1.1 (the "License"); you may not use this file except in compliance with 00010 * the License. You may obtain a copy of the License at 00011 * http://www.mozilla.org/MPL/ 00012 * 00013 * Software distributed under the License is distributed on an "AS IS" basis, 00014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00015 * for the specific language governing rights and limitations under the 00016 * License. 00017 * 00018 * The Original Code is hikerproject.org code. 00019 * 00020 * The Initial Developer of the Original Code is ACCESS Systems Americas, Inc. 00021 * Portions created by the Initial Developer are 00022 * Copyright 2006-2007 the Initial Developer. All Rights Reserved. 00023 * 00024 * Contributor(s): 00025 * 00026 * Alternatively, the contents of this file may be used under the terms of 00027 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which 00028 * case the provisions of the LGPL are applicable instead of those above. 00029 * If you wish to allow use of your version of this file only under the terms 00030 * of the LGPL, and not to allow others to use your version of this file under 00031 * the terms of the MPL, indicate your decision by deleting the provisions 00032 * above and replace them with the notice and other provisions required by 00033 * the LGPL. If you do not delete the provisions above, a recipient may use 00034 * your version of this file under the terms of either the MPL or the LGPL. 00035 * You may obtain a copy of the LGPL at http://www.gnu.org/licenses/lgpl.txt. 00036 * 00037 ********************************************************************/ 00046 #ifndef ALP_BUNDLEMGR_H_ 00047 #define ALP_BUNDLEMGR_H_ 00048 00049 #include <hiker/types.h> // for alp_status_t 00050 #include <glib.h> //for gboolean, GList, GArray, gchar 00051 #include <glib-object.h> // for GClosure* 00052 00053 #ifdef __cplusplus 00054 extern "C" { 00055 #endif 00056 00274 // ----------------------------------------------------------------------- 00275 00290 alp_status_t alp_bundle_init(void); 00291 00297 alp_status_t alp_bundle_fini(void); 00298 00300 00301 // ----------------------------------------------------------------------- 00302 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 typedef struct _AlpBundle { guint value; } AlpBundle; 00324 00328 typedef struct _AlpBundleRef * AlpBundleRef; 00329 00333 static inline gboolean alp_bundle_is_NULL(AlpBundle index) 00334 { 00335 return index.value == 0; 00336 } 00337 00339 #define ALP_BUNDLE_NULL ((struct _AlpBundle){0}) 00340 00341 #define ALP_BUNDLE_REF_NULL (NULL) 00342 00344 #define ALP_STATUS_BUNDLEMGR_FAILURE (ALP_CLASS_BUNDLE | 0x00010000) 00345 00347 #define ALP_STATUS_BUNDLEMGR_CANCELED (ALP_CLASS_BUNDLE | 0x00020000) 00348 00349 00351 00352 // ----------------------------------------------------------------------- 00353 00359 00360 00361 00362 00363 00364 AlpBundle alp_bundle_by_name(const char * name); 00365 00394 GArray * alp_bundle_search(const char * name, gboolean named, const char * scheme, const char * store, const char * property); 00395 00399 GList * alp_bundle_list_schemes(void); 00402 GList * alp_bundle_list_stores(void); 00405 GList * alp_bundle_list_names(void); 00408 GList * alp_bundle_list_properties(void); 00409 00411 00412 // ----------------------------------------------------------------------- 00413 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 AlpBundle alp_bundle_move_to_store(AlpBundle bundle, const char * store, int flags); 00437 00438 00454 AlpBundle alp_bundle_copy_to_store(AlpBundle bundle, const char * store, int flags); 00455 00460 alp_status_t alp_bundle_delete(AlpBundle bundle, int everything); 00461 00462 // metadata includes name, refcount, version, misc data 00463 GHashTable * alp_bundle_metadata(AlpBundle); 00464 00474 gchar * alp_bundle_metadata_value(AlpBundle index, const char * key); 00475 00491 gchar * alp_bundle_rw_pathname(AlpBundle index, const char * file_path, gboolean vivify); 00492 00498 #define ALP_BUNDLE_RW_SAVED "/saved/" 00499 00500 00511 alp_status_t alp_bundle_rw_delete(AlpBundle index, const char * folder_path, gboolean itself); 00512 00525 GHashTable * alp_bundle_properties(AlpBundle index, const char * property, int which); 00526 00557 GList * alp_bundle_all_properties(AlpBundle index); 00558 00569 gchar * alp_bundle_property_value(AlpBundle index, const char * property, int which, const char * key); 00570 00579 AlpBundle alp_bundle_locate_file(const char * filename); 00580 00597 AlpBundle alp_bundle_me(); 00598 00605 AlpBundle alp_bundle_application(); 00606 00608 00609 // ----------------------------------------------------------------------- 00610 00617 GHashTable * alp_bundle_store(const char * store); 00618 00621 gchar * alp_bundle_store_value(const char * store, const char * key); 00622 00624 00625 // ----------------------------------------------------------------------- 00626 00641 AlpBundleRef alp_bundle_open(AlpBundle idx); 00642 00653 alp_status_t alp_bundle_close(AlpBundleRef ref); 00654 00662 AlpBundle alp_bundle_ref_bundle(AlpBundleRef ref); 00663 00688 AlpBundleRef alp_bundle_ref_me(); 00689 00690 00702 AlpBundleRef alp_bundle_ref_application(); 00703 00722 GIOChannel * alp_bundle_ref_ro_channel(AlpBundleRef ref, const char * path); 00723 00724 00742 gchar * alp_bundle_ref_ro_pathname(AlpBundleRef ref, const char * path); 00743 00762 alp_status_t alp_bundle_ref_ro_data(AlpBundleRef ref, const char * path, gchar ** data, size_t * length); 00763 00764 00781 GList * alp_bundle_ref_ro_directory(AlpBundleRef ref, const char * path, gboolean recurse); 00782 00807 gchar * alp_bundle_ref_ro_tempfile(AlpBundleRef ref, const char * path, gboolean keep, const char * ext); 00808 00817 alp_status_t alp_bundle_tempfile_release(gchar * tempfile); 00818 00820 #define ALP_BUNDLE_BAR_MANIFEST "/Manifest.xml" 00821 00823 00824 // ----------------------------------------------------------------------- 00825 00846 typedef struct _AlpBundleProgressiveData AlpBundleProgressiveData; 00847 struct _AlpBundleProgressiveData { 00850 gint version; 00853 gboolean (*callback)(AlpBundleProgressiveData*); 00854 00855 enum { 00856 ALP_BUNDLE_PROGRESSIVE_HAVE_BYTES_SO_FAR = 1<<0, 00857 ALP_BUNDLE_PROGRESSIVE_HAVE_TOTAL_BYTES = 1<<1, 00858 ALP_BUNDLE_PROGRESSIVE_HAVE_MAX_OVERHEAD = 1<<2, 00859 ALP_BUNDLE_PROGRESSIVE_HAVE_METADATA = 1<<3, 00860 ALP_BUNDLE_PROGRESSIVE_HAVE_PROPERTIES = 1<<4, 00861 ALP_BUNDLE_PROGRESSIVE_HAVE_FILENAME = 1<<5, 00862 ALP_BUNDLE_PROGRESSIVE_HAVE_MIMETYPE = 1<<6, 00863 ALP_BUNDLE_PROGRESSIVE_HAVE_STORE = 1<<7, 00864 ALP_BUNDLE_PROGRESSIVE_HAVE_OVERWRITING_PKGINDEX = 1<<8, 00865 ALP_BUNDLE_PROGRESSIVE_HAVE_PKGINDEX = 1<<9, 00866 ALP_BUNDLE_PROGRESSIVE_HAVE_FINISHED = 1<<10 00867 } ALP_BUNDLE_PROGRESSIVE_ENUM; 00868 00872 guint new_state; 00873 00876 guint current_state; 00877 00880 guint bytes_so_far; 00883 guint total_bytes; 00888 guint max_overhead; 00889 00891 GHashTable * metadata; 00893 GHashTable * properties; 00895 const char * recommended_filename; 00897 const char * recommended_mimetype; 00899 const char * store; 00901 AlpBundle overwriting_index; 00903 AlpBundle index; 00904 00907 void * userdata; 00908 }; 00909 00910 enum { 00913 ALP_BUNDLE_PROGRESSIVE_DATA_VERSION = 1 00914 }; 00915 00916 00940 int alp_bundle_image_verify(const char * provide_filename, const char * provide_mimetype, GIOChannel * image, gboolean full_check, GHashTable ** metadata, GHashTable ** properties, AlpBundleProgressiveData * progress); 00941 00942 00964 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); 00965 00982 alp_status_t alp_bundle_image_archive(AlpBundle index, char ** desired_filename, char ** desired_mimetype, GIOChannel * image, AlpBundleProgressiveData * progress); 00983 00985 00986 // ----------------------------------------------------------------------- 00987 01078 GClosure * alp_bundle_acquire_entrypoint(const char * url, AlpBundleRef relativeRef /* may be NULL */); 01079 01112 gchar * alp_bundle_acquire_ro_pathname(const char * url, AlpBundleRef* openRef, AlpBundleRef relativeRef /* may be NULL */); 01113 01149 GIOChannel * alp_bundle_acquire_ro_channel(const char * url, AlpBundleRef relativeRef/* may be NULL */); 01150 01183 alp_status_t alp_bundle_acquire_ro_data(const char * url, gchar ** data, size_t * length, AlpBundleRef relativeRef /* may be NULL */); 01184 01227 gchar * alp_bundle_acquire_ro_tempfile(const char * url, AlpBundleRef* openRef, gboolean keep, const char * ext, AlpBundleRef relativeRef /* may be NULL */); 01228 01233 typedef struct { 01234 // initial layout should match that of GCClosure 01235 GClosure closure; 01236 gpointer callback; 01237 int struct_version; 01238 AlpBundleRef ref; 01239 void * dlhandle; 01240 gchar * path; 01241 gchar * sym; 01242 int result_signal; 01243 } AlpBundleEntrypointClosure; 01244 01245 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_VERSION 1 01246 01248 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_REF(closure) (((AlpBundleEntrypointClosure*)(closure))->ref) 01249 01251 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_DLHANDLE(closure) (((AlpBundleEntrypointClosure*)(closure))->dlhandle) 01252 01254 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_CALLBACK(closure) (((AlpBundleEntrypointClosure*)(closure))->callback) 01255 01257 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_PATH(closure) (((AlpBundleEntrypointClosure*)(closure))->path) 01258 01260 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_SYM(closure) (((AlpBundleEntrypointClosure*)(closure))->sym) 01261 01264 #define ALP_BUNDLE_ENTRYPOINT_CLOSURE_RESULT_SIGNAL(closure) (((AlpBundleEntrypointClosure*)(closure))->result_signal) 01265 01286 int alp_bundle_entrypoint_closure_execve(GClosure * closure, char * const argv[], char * const envp[]); 01287 01305 int alp_bundle_entrypoint_closure_execl(GClosure * closure, const char * arg, ...); 01306 01308 // ----------------------------------------------------------------------- 01309 01318 #define ALP_NOTIFY_EVENT_BUNDLE_DELETE "/alp/bundlemgr/delete_bundle" 01319 typedef struct _AlpNotifyEventBundleDelete AlpNotifyEventBundleDelete; 01320 struct _AlpNotifyEventBundleDelete { 01321 AlpBundle index; 01322 int flags; 01323 gboolean named; 01324 char name[]; 01325 }; 01326 01331 #define ALP_NOTIFY_EVENT_BUNDLE_MOVE "/alp/bundlemgr/move_bundle" 01332 typedef struct _AlpNotifyEventBundleMove AlpNotifyEventBundleMove; 01333 struct _AlpNotifyEventBundleMove { 01334 AlpBundle index; 01335 char store[]; 01336 }; 01337 01342 #define ALP_NOTIFY_EVENT_BUNDLE_COPY "/alp/bundlemgr/copy_bundle" 01343 typedef struct _AlpNotifyEventBundleCopy AlpNotifyEventBundleCopy; 01344 struct _AlpNotifyEventBundleCopy { 01345 AlpBundle index; 01346 char store[]; 01347 }; 01348 01351 #define ALP_NOTIFY_EVENT_BUNDLE_REGISTER "/alp/bundlemgr/register_bundle" 01352 typedef struct _AlpNotifyEventBundleRegister AlpNotifyEventBundleRegister; 01353 struct _AlpNotifyEventBundleRegister { 01354 AlpBundle index; 01355 }; 01356 01359 #define ALP_NOTIFY_EVENT_BUNDLE_UNREGISTER "/alp/bundlemgr/unregister_bundle" 01360 typedef struct _AlpNotifyEventBundleUnregister AlpNotifyEventBundleUnregister; 01361 struct _AlpNotifyEventBundleUnregister { 01362 AlpBundle index; 01363 }; 01364 01367 #define ALP_NOTIFY_EVENT_BUNDLE_RESET_EVERYTHING "/alp/bundlemgr/reset_everything" 01368 typedef struct _AlpNotifyEventBundleResetEverything AlpNotifyEventBundleResetEverything; 01369 struct _AlpNotifyEventBundleResetEverything { 01370 }; 01371 01374 #define ALP_NOTIFY_EVENT_BUNDLE_NAME_ADDED "/alp/bundlemgr/name_added" 01375 typedef struct _AlpNotifyEventBundleNameAdded AlpNotifyEventBundleNameAdded; 01376 struct _AlpNotifyEventBundleNameAdded { 01377 AlpBundle index; 01378 char name[]; 01379 }; 01380 01383 #define ALP_NOTIFY_EVENT_BUNDLE_NAME_REMOVED "/alp/bundlemgr/name_removed" 01384 typedef struct _AlpNotifyEventBundleNameRemoved AlpNotifyEventBundleNameRemoved; 01385 struct _AlpNotifyEventBundleNameRemoved { 01386 AlpBundle index; 01387 char name[]; 01388 }; 01389 01393 #define ALP_NOTIFY_EVENT_BUNDLE_NAME_CHANGED "/alp/bundlemgr/name_changed" 01394 typedef struct _AlpNotifyEventBundleNameChanged AlpNotifyEventBundleNameChanged; 01395 struct _AlpNotifyEventBundleNameChanged { 01396 AlpBundle old_index; 01397 AlpBundle new_index; 01398 char name[]; 01399 }; 01400 01403 #define ALP_NOTIFY_EVENT_BUNDLE_STORE_ADDED "/alp/bundlemgr/store_added" 01404 typedef char AlpNotifyEventBundleStoreAdded[]; 01405 01408 #define ALP_NOTIFY_EVENT_BUNDLE_STORE_REMOVED "/alp/bundlemgr/store_removed" 01409 typedef char AlpNotifyEventBundleStoreRemoved[]; 01410 01411 01413 01414 // ----------------------------------------------------------------------- 01420 01421 #define ALP_BUNDLE_PROPERTY_APPLICATION "application" 01422 01423 01425 01426 // ----------------------------------------------------------------------- 01432 01433 #define ALP_BUNDLE_TYPE_BAR "bar" 01434 01436 #define ALP_BUNDLE_TYPE_GVM "GHost" 01437 01439 #define ALP_BUNDLE_TYPE_JAVA "java" 01440 01441 01443 #define ALP_BUNDLE_SCHEME_EXTENSION_BAR ".bar" 01444 01446 #define ALP_BUNDLE_SCHEME_EXTENSION_GVM ".prc" 01447 01449 #define ALP_BUNDLE_SCHEME_EXTENSION_JAVA ".jar" 01450 01451 // From: 01452 // http://www.iana.org/assignments/media-types/application/vnd.palm 01453 // http://developers.sun.com/techtopics/mobility/midp/articles/deploy/ 01454 01456 #define ALP_BUNDLE_SCHEME_MIMETYPE_BAR "x-application/access-bar" 01457 01459 #define ALP_BUNDLE_SCHEME_MIMETYPE_GVM "application/vnd.palm" 01460 01462 #define ALP_BUNDLE_SCHEME_MIMETYPE_GVM_2 "application/x-pilot" 01463 01465 #define ALP_BUNDLE_SCHEME_MIMETYPE_JAVA "application/java-archive" 01466 01468 #define ALP_BUNDLE_SCHEME_MIMETYPE_JAVA_2 "text/vnd.sun.j2me.app-descriptor" 01469 01471 01472 // ----------------------------------------------------------------------- 01477 01478 #define ALP_BUNDLE_FINGERTOUCH_RSC_PREFIX "finger-" 01479 01481 #define ALP_BUNDLE_FLAG_DELETE_EVERYTHING 1 01482 01483 #define ALP_BUNDLE_FLAG_OVERWRITE_DUPLICATE 128 01484 01485 01496 const char * alp_bundle_ref_gettextdomain(AlpBundleRef ref); 01497 01504 const char * alp_bundle_ref_name(AlpBundleRef ref); 01505 01512 gchar * alp_bundle_name(AlpBundle index); 01513 01526 gchar * alp_bundle_saved_settings(AlpBundle index, const char * key); 01527 01540 gchar * alp_bundle_unsaved_settings(AlpBundle index, const char * key); 01541 01542 01549 #define alp_bundle_acquire_glade_xml(url, root) \ 01550 ({ \ 01551 AlpBundleRef _ref; \ 01552 AlpBundleRef _me = alp_bundle_ref_me(); \ 01553 gchar * _pathname = alp_bundle_acquire_ro_pathname((url), &_ref, _me); \ 01554 GladeXML * _result = glade_xml_new_with_domain(_pathname, (root), alp_bundle_ref_gettextdomain(_ref)); \ 01555 g_free(_pathname); \ 01556 alp_bundle_close(_ref); \ 01557 _result; \ 01558 }) 01559 01567 #define alp_bundle_ref_cgettext(ref, text, category) \ 01568 dcgettext(alp_bundle_ref_gettextdomain((ref)), (text), (category)) \ 01569 01570 01576 #define alp_bundle_ref_gettext(ref, text) \ 01577 dgettext(alp_bundle_ref_gettextdomain((ref)), (text)) \ 01578 01579 01591 #define alp_bundle_gettext(text) \ 01592 dgettext(alp_bundle_ref_gettextdomain(alp_bundle_ref_me()), (text)) 01593 01606 alp_status_t alp_bundle_error(void); 01607 01609 01610 01611 // ----------------------------------------------------------------------- 01628 GHashTable * alp_bundle_scheme_values(const char * scheme); 01629 01640 gchar * alp_bundle_scheme_value(const char * scheme, const char * key); 01641 01657 gchar * alp_bundle_scheme_identify(const char * filename, const char * mimetype); 01658 01660 01661 01663 01664 #ifdef __cplusplus 01665 } 01666 #endif 01667 01668 01669 #endif /* ALP_BUNDLEMGR_H_ */ 01670
Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.