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 ********************************************************************/ 00044 #ifndef ALP_IPC_H_ 00045 #define ALP_IPC_H_ 1 00046 00047 #include <glib.h> 00048 00049 #include <hiker/config.h> 00050 #include <hiker/sysclass.h> 00051 #include <hiker/types.h> 00052 00053 #define ALP_STATUS_IPC_ERROR ((alp_status_t)ALP_CLASS_IPC | 0x00010000) 00054 #define ALP_STATUS_IPC_TIMEOUT ((alp_status_t)ALP_CLASS_IPC | 0x00020000) 00055 #define ALP_STATUS_IPC_BROKEN_CONNECTION ((alp_status_t)ALP_CLASS_IPC | 0x00030000) 00056 #define ALP_STATUS_IPC_NOT_CONNECTED ((alp_status_t)ALP_CLASS_IPC | 0x00040000) 00057 #define ALP_STATUS_IPC_NO_SERVER ((alp_status_t)ALP_CLASS_IPC | 0x00050000) 00058 #define ALP_STATUS_IPC_INVALID_RESPONSE ((alp_status_t)ALP_CLASS_IPC | 0x00060000) 00059 00060 #define ALP_IPC_RECEIVE_ANY -1 00061 00062 #ifdef __cplusplus 00063 extern "C" { 00064 #endif 00065 00072 // 00073 // Opaque typedef's 00074 // 00075 00079 typedef struct _AlpChannel AlpChannel; 00080 00085 typedef struct _AlpConnection AlpConnection; 00086 00090 typedef struct _AlpMessage AlpMessage; 00091 00095 typedef enum { 00096 ALP_IPC_CHANNEL_ACCESS_OWNER, 00097 ALP_IPC_CHANNEL_ACCESS_ALL, 00098 } AlpIpcChannelAccessMode; 00099 00103 typedef enum { 00104 ALP_IPC_CONNECTION_USAGE_HINT_NONE = 0x0, 00105 ALP_IPC_CONNECTION_USAGE_HINT_SYNCH_ONLY = 0x1, 00106 } AlpConnectionUsageHint; 00107 00108 // 00109 // Callback function signatures 00110 // 00111 00112 // typedef's for connect, disconnect, and message receive callback functions 00113 00117 typedef void (*AlpChannelConnectCB) (AlpConnection* connection, 00118 gpointer cbData); 00119 00123 typedef void (*AlpChannelDisconnectCB) (AlpConnection* connection, 00124 gpointer cbData); 00125 00129 typedef void (*AlpMessageReceiveCB) (AlpConnection* connection, 00130 AlpMessage* message, 00131 gpointer cbData); 00132 00133 00153 AlpChannel* 00154 alp_ipc_channel_create(const gchar* channelName, AlpIpcChannelAccessMode accessMode); 00155 00156 00170 alp_status_t 00171 alp_ipc_channel_destroy(AlpChannel* channel); 00172 00173 00188 alp_status_t 00189 alp_ipc_channel_register_connect_callback(AlpChannel* channel, 00190 AlpChannelConnectCB callback, 00191 gpointer cbData); 00192 00193 00206 alp_status_t 00207 alp_ipc_channel_register_disconnect_callback(AlpChannel* channel, 00208 AlpChannelDisconnectCB callback, 00209 gpointer cbData); 00210 00226 AlpConnection* 00227 alp_ipc_channel_connect(const gchar* channelName, 00228 AlpConnectionUsageHint hint, 00229 AlpChannelConnectCB callback, 00230 gpointer cbData); 00231 00258 alp_status_t 00259 alp_ipc_channel_connect_synch(const gchar* channelName, 00260 AlpConnectionUsageHint usageHint, 00261 guint timeout, 00262 AlpConnection** connection); 00263 00264 00265 00281 alp_status_t 00282 alp_ipc_channel_disconnect(AlpConnection* connection); 00283 00284 00293 void 00294 alp_ipc_channel_set_custom_data(AlpChannel* channel, 00295 gpointer customData); 00296 00306 gpointer 00307 alp_ipc_channel_get_custom_data(AlpChannel* channel); 00308 00309 00321 alp_status_t 00322 alp_ipc_connection_register_disconnect_callback(AlpConnection* connection, 00323 AlpChannelDisconnectCB callback, 00324 gpointer cbData); 00325 00333 gint 00334 alp_ipc_connection_get_peer_pid(const AlpConnection* connection); 00335 00343 gint 00344 alp_ipc_connection_get_peer_uid(const AlpConnection* connection); 00345 00353 gint 00354 alp_ipc_connection_get_peer_gid(const AlpConnection* connection); 00355 00356 00364 gint 00365 alp_prv_ipc_connection_set_context(AlpConnection* connection, GMainContext * context); 00366 00367 00374 AlpMessage* 00375 alp_ipc_message_create(); 00376 00383 alp_status_t 00384 alp_ipc_message_destroy(AlpMessage* message); 00385 00386 00397 gint 00398 alp_ipc_message_get_message_ID(AlpMessage* message); 00399 00400 00411 alp_status_t 00412 alp_ipc_connection_send(AlpConnection* connection, AlpMessage* message); 00413 00445 alp_status_t 00446 alp_ipc_connection_send_with_response(AlpConnection* connection, 00447 AlpMessage* message, 00448 guint timeout, 00449 AlpMessage** response); 00450 00473 alp_status_t 00474 alp_ipc_connection_receive(AlpConnection* connection, gint messageID, 00475 guint timeout, AlpMessage** message); 00476 00477 00499 alp_status_t 00500 alp_ipc_connection_register_receive_callback(AlpConnection* connection, 00501 AlpMessageReceiveCB callback, 00502 gpointer cbData); 00503 00512 void 00513 alp_ipc_connection_set_custom_data(AlpConnection* connection, 00514 gpointer customData); 00515 00525 gpointer 00526 alp_ipc_connection_get_custom_data(AlpConnection* connection); 00527 00546 alp_status_t 00547 alp_ipc_message_pack_start(AlpMessage* message, gint messageID); 00548 00569 alp_status_t 00570 alp_ipc_message_response_pack_start(AlpMessage* message, gint messageID, 00571 AlpMessage* messageToRespondTo); 00572 00573 00581 alp_status_t 00582 alp_ipc_message_pack_end(AlpMessage* message); 00583 00584 00593 alp_status_t 00594 alp_ipc_message_pack_int32(AlpMessage* message, gint32 val); 00595 00596 00605 alp_status_t 00606 alp_ipc_message_pack_uint32(AlpMessage* message, guint32 val); 00607 00608 00617 alp_status_t 00618 alp_ipc_message_pack_float(AlpMessage* message, gfloat val); 00619 00620 00629 alp_status_t 00630 alp_ipc_message_pack_pointer(AlpMessage* message, gpointer val); 00631 00632 00641 alp_status_t 00642 alp_ipc_message_pack_string(AlpMessage* message, const gchar* val); 00643 00644 00654 alp_status_t 00655 alp_ipc_message_pack_byte_array(AlpMessage* message, 00656 guchar* byteArray, 00657 guint numElements); 00658 00659 00676 alp_status_t 00677 alp_ipc_message_unpack_start(AlpMessage* message); 00678 00679 00687 alp_status_t 00688 alp_ipc_message_unpack_end(AlpMessage* message); 00689 00690 00699 alp_status_t 00700 alp_ipc_message_unpack_int32(AlpMessage* message, gint32* val); 00701 00702 00703 00712 alp_status_t 00713 alp_ipc_message_unpack_uint32(AlpMessage* message, guint32* val); 00714 00715 00716 00725 alp_status_t 00726 alp_ipc_message_unpack_float(AlpMessage* message, gfloat* val); 00727 00728 00737 alp_status_t 00738 alp_ipc_message_unpack_pointer(AlpMessage* message, gpointer* val); 00739 00740 00751 alp_status_t 00752 alp_ipc_message_unpack_string(AlpMessage* message, gchar** val); 00753 00754 00766 alp_status_t 00767 alp_ipc_message_unpack_byte_array(AlpMessage* message, 00768 guchar** array, 00769 guint* numElements); 00770 00776 #ifdef __cplusplus 00777 } // extern "C" 00778 #endif 00779 00780 #endif // #ifndef ALP_IPC_H_ 00781
Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.