isolationserver/isoserver/inc/isoservermain.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : isoservermain.h
       
     4 *  Part of     : isolation server.
       
     5 *  Version     : %version: 18 %
       
     6 *
       
     7 *  Copyright © 2007-2008 Nokia.  All rights reserved.
       
     8 *  All rights reserved.
       
     9 *  Redistribution and use in source and binary forms, with or without modification, 
       
    10 *  are permitted provided that the following conditions are met:
       
    11 *  Redistributions of source code must retain the above copyright notice, this list 
       
    12 *  of conditions and the following disclaimer.Redistributions in binary form must 
       
    13 *  reproduce the above copyright notice, this list of conditions and the following 
       
    14 *  disclaimer in the documentation and/or other materials provided with the distribution.
       
    15 *  Neither the name of the Nokia Corporation nor the names of its contributors may be used 
       
    16 *  to endorse or promote products derived from this software without specific prior written 
       
    17 *  permission.
       
    18 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
       
    19 *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
       
    20 *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
       
    21 *  SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
       
    22 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
       
    23 *  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
       
    24 *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
       
    25 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
       
    26 *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    27 * ============================================================================
       
    28 * Template version: 1.0
       
    29 */
       
    30 
       
    31 /*!
       
    32 * /def To avoid multiple inclusion of header
       
    33 */
       
    34 #ifndef __ISO_SERVER_H_
       
    35 #define __ISO_SERVER_H_
       
    36 
       
    37 #include <glib.h>
       
    38 #include <gtypes.h>
       
    39 #include <sys/cdefs.h>
       
    40 #include <sys/types.h> 
       
    41 
       
    42 
       
    43 #include "tp-chan-type-text-gen.h"
       
    44 #include "tp-conn.h"
       
    45 #include "tp-connmgr.h"
       
    46 #include "tp-chan.h"
       
    47 #include "tp-conn-gen.h"
       
    48 #include "tp-props-iface.h"
       
    49 #include "tp-interfaces.h"
       
    50 #include "tp-conn-iface-presence-gen.h"
       
    51 
       
    52 #include "msg_enums.h"
       
    53 
       
    54 /*! /file 
       
    55 *	Header file for the isolation server main. This file has implimentations
       
    56 *	to recieve messages from client and delegate the requests to other 
       
    57 *	funtions based on the message type.
       
    58 *	client anywhere in the documentation refers to anyone
       
    59 *	using the isoserver
       
    60 */
       
    61 
       
    62 enum connection_status
       
    63     {
       
    64     connecting = -1,
       
    65     connected,
       
    66     disconnected,
       
    67     disconnecting,
       
    68     not_connected
       
    69     };
       
    70 /*! /typedef struct userConnection typedefed to userConnection
       
    71 */
       
    72 typedef struct userConnection  userConnection;
       
    73 
       
    74 /*! /struct userConnection isoservermain.h
       
    75 *	/brief There is only one object of this struct. This struct represents
       
    76 *	one login session. This strcut has all the necessary data members to
       
    77 *	maintain a session.
       
    78 *	
       
    79 *	/var conn telepathy connection object
       
    80 *	/var connmgr telepathy connection manager object
       
    81 *	/var dbusCon D-Bus
       
    82 *
       
    83 *	/var isConnected Boolean : If loged in
       
    84 *
       
    85 *	/var current_members_names : 2D char array having the current members list
       
    86 *	/var local_pending_names : 2D char array having the locally pending members list
       
    87 *	/var remote_pending_names : 2D char array having the remotely pending members list
       
    88 *
       
    89 *	/var group_iface_subscribe : Interface to subscribe list
       
    90 *	/var group_iface_publish : Interface to publish list
       
    91 *	/var group_iface_known : Interface to known list
       
    92 *
       
    93 *	/var connmgr_bus : connection manager bus 
       
    94 *
       
    95 *	/var text_channels : open text(chat) channels
       
    96 *
       
    97 *	/var pres_iface : Interface for presence
       
    98 *
       
    99 *	/var search_chan : channel for search
       
   100 *	/var search_hdr_req : request header for search
       
   101 *
       
   102 */
       
   103 struct userConnection 
       
   104 	{
       
   105 	TpConn* conn;
       
   106 	DBusGConnection* dbusConn;
       
   107 	TpConnMgr* connmgr;
       
   108 	enum connection_status conn_stat;
       
   109 	
       
   110 	gchar** current_members_names;
       
   111 	gchar** local_pending_names;
       
   112 	gchar** remote_pending_names;
       
   113 	
       
   114 	
       
   115 	DBusGProxy    *group_iface_subscribe;
       
   116 	DBusGProxy    *group_iface_publish;
       
   117 	DBusGProxy    *group_iface_known;
       
   118 	
       
   119 	gchar* connmgr_bus;
       
   120 	
       
   121 	GHashTable *text_channels;
       
   122 	
       
   123 	TpPropsIface *pres_iface;
       
   124 	
       
   125 	TpChan *search_chan;
       
   126 	message_hdr_req* search_hdr_req;	
       
   127 	
       
   128 	gboolean logout_flag;
       
   129 	};
       
   130 
       
   131 /*! /typedef struct globalMainloop to globalMainloop
       
   132 */
       
   133 typedef struct globalMainloop globalMainloop;
       
   134 
       
   135 /*!	/struct globalMainloop isoservermain.h
       
   136 *	/brief Has a pointer to the mainloop. This mainloop runs in a 
       
   137 *	thread created by the main thread(isoserver.exe). This loop 
       
   138 *	listens to the event from telepathygabble
       
   139 *
       
   140 *	/var mainloop pointer to the mainloop
       
   141 */
       
   142 struct globalMainloop 
       
   143 	{
       
   144 	GMainLoop* mainloop;
       
   145 	};
       
   146 
       
   147 /*! /var mainloop_struct global variable for mainloop
       
   148 *	/brief This variable can not be put into userConnection as the life 
       
   149 *	time of a mainloop is not related to per login session
       
   150 */
       
   151 extern globalMainloop mainloop_struct;
       
   152 
       
   153 /*!	/var globalCon represents one login session 
       
   154 */
       
   155 extern userConnection globalCon;
       
   156 
       
   157 /*!	/brief This message reads message type from the message buffer
       
   158 *	passed as argument
       
   159 *
       
   160 * 	/var pc message buffer
       
   161 *	
       
   162 *	/return pointer to message header response which has the message type
       
   163 */
       
   164 message_hdr_resp* read_message_type( gchar* pc ) ;
       
   165 
       
   166 /*! /brief This is an entry point to the thread. isoserver.exe
       
   167 *	creates a thread which runs a mainloop. mainloop is passed as 
       
   168 *	argument to the thread entry function. This mainloop which is 
       
   169 *	run in the thread listens for the events from telepathygabble
       
   170 *
       
   171 *	/var data unused param
       
   172 */
       
   173 gpointer thread_entry( gpointer data ) ;
       
   174 
       
   175 /*! /brief If there are any parse error, this function is called to
       
   176 *	dispatch the error to client.
       
   177 *	
       
   178 *	/param msg_struct The response header to be sent 
       
   179 *	/param err Error
       
   180 */
       
   181 gint send_error( message_hdr_resp* msg_struct, gint err );
       
   182 
       
   183 /*! /brief This function waits for the requests from the client.
       
   184 *	Requests are parsed, validated and appropriate actions taken.
       
   185 *	A new thread is created when login happens. This function runs 
       
   186 *	a while loop which is only quit when a kill request is recieved 
       
   187 *	from the client.
       
   188 *
       
   189 *	/remark should this thread be created before login?
       
   190 *	/remark when is the mainloop quit ? (Should that be after logout or 
       
   191 *	after getting a kill request from the client)
       
   192 */
       
   193 int message_send_recv() ;
       
   194 
       
   195 #endif //__ISO_SERVER_H_