--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: constant declaration class
+ *
+ *
+*/
+// Project configuration file for dbus
+
+// Project platforms
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+
+// Project exports
+PRJ_EXPORTS
+
+// MMP files for project components
+PRJ_MMPFILES
+#include "../opensrv_plat/group/bld.inf"
+#include "../loudmouth/group/bld.inf"
+#include "../libtelepathy/group/bld.inf"
+#include "../telepathygabble/group/bld.inf"
+#include "../isolationserver/group/bld.inf"
+
+
+PRJ_TESTMMPFILES
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* ============================================================================
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+
+PRJ_EXPORTS
+../rom/isoserver.iby CORE_MW_LAYER_IBY_EXPORT_PATH(isoserver.iby)
+
+PRJ_MMPFILES
+
+
+#include "../messagequeue/group/bld.inf"
+#include "../isoserver/group/bld.inf"
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/install/isolationserver.pkg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,60 @@
+;
+; ============================================================================
+; Name : isoserver.iby
+; Part of : isolation server.
+; Version : %version: %
+;
+; Copyright © 2007-2008 Nokia. All rights reserved.
+; All rights reserved.
+; Redistribution and use in source and binary forms, with or without modification,
+; are permitted provided that the following conditions are met:
+; Redistributions of source code must retain the above copyright notice, this list
+; of conditions and the following disclaimer.Redistributions in binary form must
+; reproduce the above copyright notice, this list of conditions and the following
+; disclaimer in the documentation and/or other materials provided with the distribution.
+; Neither the name of the Nokia Corporation nor the names of its contributors may be used
+; to endorse or promote products derived from this software without specific prior written
+; permission.
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+; SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+; OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+; ============================================================================
+; Template version: 1.0
+;
+
+
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"MessageQueueClient"},(0xA0001320),1,0,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+;Files to install
+"\epoc32\release\armv5\urel\messagequeueclient.exe" -"!:\sys\bin\messagequeueclient.exe"
+"\epoc32\release\armv5\urel\messagequeuelibrary.dll" -"!:\sys\bin\messagequeuelibrary.dll"
+
+"\epoc32\data\z\private\10003a3f\import\apps\opencmessagequeueclient_reg.rsc" -"!:\private\10003a3f\import\apps\opencmessagequeueclient_reg.rsc"
+
+;required for application to be covered by backup/restore facility
+;"backup_registration.xml" -"c:\private\0xA0001320\backup_registration.xml"
+
+"\epoc32\release\armv5\urel\isoserver.exe" - "!:\sys\bin\isoserver.exe"
+
+"\epoc32\release\armv5\urel\opencstringutilitieslibex.dll" - "!:\sys\bin\opencstringutilitieslibex.dll"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/data/isoServer_reg.rss Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/*
+* ============================================================================
+* Name : isoServer_reg.rss
+* Part of : isolation server.
+* Version : %version: 2 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0xA0001320
+
+RESOURCE APP_REGISTRATION_INFO
+ {
+ app_file="OpenCMessageQueueClient";
+
+ embeddability=KAppNotEmbeddable;
+ newfile=KAppDoesNotSupportNewFile;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* ============================================================================
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+isoserver.mmp
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/group/isoserver.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,77 @@
+/*
+* ============================================================================
+*
+* Copyright © 2007-2008 Nokia and/or its subsidiary/subsidiaries. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+#include<platform_paths.hrh>
+TARGET isoserver.exe
+TARGETTYPE EXE
+UID 0x100039CE 0x2001241A //0x100039CE
+
+CAPABILITY All -Tcb
+
+VENDORID VID_DEFAULT
+EPOCSTACKSIZE 0x13880 // 0x11170 0x15F90
+
+VERSION 10.0
+
+SOURCEPATH ../src
+SOURCE isoservermain.c
+SOURCE isoconnectionmanager.c
+SOURCE isofetchcontactlist.c
+SOURCE isoim.c
+SOURCE isoutils.c
+SOURCE isomodifycontactlist.c
+SOURCE isopresence.c
+SOURCE isosearch.c
+SOURCE isogetsearchkeys.c
+SOURCE isoavtar.c
+MACRO SYMBIAN
+USERINCLUDE ../inc
+
+EPOCALLOWDLLDATA
+
+USERINCLUDE ../../../libtelepathy/inc
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+
+STATICLIBRARY libcrt0.lib
+LIBRARY euser.lib
+LIBRARY libc.lib
+LIBRARY libglib.lib
+LIBRARY libgthread.lib
+LIBRARY libdbus-glib.lib
+LIBRARY libtelepathy.lib
+LIBRARY libgobject.lib
+LIBRARY libdbus.lib
+LIBRARY libpthread.lib
+LIBRARY opencmessagequeuelibrary.lib
+
+LANG SC
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isoavtar.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,115 @@
+/*
+* ============================================================================
+* Name : isoconnectionmanager.h
+* Part of : isolation server.
+* Version : %version: 5 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+/*!
+* \def To avoid multiple inclusion of header
+*/
+
+#ifndef __ISOAVTAR_H__
+#define __ISOAVTAR_H__
+
+#include <glib.h>
+#include <gtypes.h>
+
+#include "isoservermain.h"
+#include "msg_enums.h"
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-props-iface.h"
+#include "tp-conn-iface-avatars-gen.h"
+#include "tp-interfaces.h"
+G_BEGIN_DECLS
+
+/*! \file
+* This file has interfaces for avtar implimentation.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+
+
+/*! \brief callback for updating own avtar. This function
+ * sends response to client
+ *
+ * \param proxy : unused
+ * \param avatar_sha1: token string
+ * \param error : error if any
+ * \param message : message header
+ * \return : void
+ */
+void update_avtar_cb(DBusGProxy *proxy, char* avatar_sha1,
+ GError* error,
+ gpointer message);
+
+
+/*! \brief sends avtar of the client to n/w server thru' gabble
+ * calls tp_conn_iface_avatars_set_avatar_async to set avatar
+ *
+ * \param avtarcontent : avatar image content
+ * \param mimetype : mime type
+ * \param msghdr request header that will be passed back to client
+ *
+ * \return : error code on failure, 0 on success
+ */
+gint send_avtar( GArray* avtarcontent , char * mimetype , message_hdr_req *msg_hdr );
+
+/*! \brief callback for clearing own avtar. This function
+ * sends response to client
+ *
+ * \param proxy : unused
+ * \param error : error if any
+ * \param userdata : message header
+ * \return : void
+ */
+void clear_avtar_cb( DBusGProxy *proxy, GError* error, gpointer userdata );
+
+/*! \brief clears the self avtar
+ *
+ * \param msghdr request header that will be passed back to client
+ *
+ * \return : error code on failure, 0 on success
+ */
+gint clear_avatar( message_hdr_req *msg_hdr );
+
+/*! \brief clears the self avtar
+ * \param rmsg : message buffer to be parsed
+ * \param msg_struct : request header
+ * \param result : message buffer length
+ * \param avtarcontent : pointer to the avatar image data
+ *
+ * \return : error code on failure, 0 on success
+ */
+gint update_own_avatar(char* rmsg,message_hdr_resp* msg_struct,gint result, GArray** avtarcontent);
+
+G_END_DECLS
+
+
+#endif //__ISOAVTAR_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isoconnectionmanager.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,171 @@
+/*
+* ============================================================================
+* Name : isoconnectionmanager.h
+* Part of : isolation server.
+* Version : %version: 9 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* \def To avoid multiple inclusion of header
+*/
+
+#ifndef __ICONNECTIONMANAGER_H__
+#define __ICONNECTIONMANAGER_H__
+
+#include <glib.h>
+#include <gtypes.h>
+#include "isoservermain.h"
+# include "msg_enums.h"
+
+#ifdef __WINSCW__
+/*! \remark Should LOGIN_ARG_COUNT this be hardcoded ?
+*/
+#define LOGIN_ARG_COUNT 12
+#else
+#define LOGIN_ARG_COUNT 10
+#endif
+
+/*! \file
+* Connection related interfaces.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+
+/*! \typedef struct login_struct typedefed to login_struct
+*/
+typedef struct login_struct login_struct;
+
+/*! \struct login_struct isoconnectionmanager.h
+ * \brief Buffer recieved from client for login request is parsed and the
+ * arguments are put into this structure
+ * \param hdr_req header request
+ * \param strs array of strings( which are arguments for login )
+ */
+struct login_struct
+ {
+ message_hdr_req* hdr_req;
+ char *strs[LOGIN_ARG_COUNT];
+ };
+
+/*! \brief This does things after login is successful. Now it sets the isConnected
+ * variable to ETrue
+ */
+void action_logedin( ) ;
+
+/*! \brief This function is registered in action_login for statuschanged signal.
+ * This function is called by telepathygabble when the status of the user changes
+ * Once user is connected this function registers for NewChannel signal with telepathygabble
+ * client is also informed of the status change..
+ *
+ * \param proxy
+ * \param status status of the user ( connected/connecting/disconnected )
+ * \param reason reason for status change(server disconnected/ user requested etc.,)
+ * \param user_data message header request
+ *
+ * \return : Boolean True on success, false on failure
+ */
+
+static gboolean status_changed_cb(DBusGProxy *proxy,
+ guint status, guint reason,
+ gpointer user_data) ;
+
+/*! \brief new_channel_handler is registered as a callback for any new
+ * channels craetion request, in function status_changed_cb after status is changed
+ * to log in. new_channel_handler creates channel and also registers for the signals
+ * MembersChanged for contact related channels and Recieved and SendError for IM
+ * related channels.
+ *
+ * \param proxy unused
+ * \param object_path object path of the channel
+ * \param channel_type used to get a new channel
+ * \param handle_type used to get a new channel, channel handle type
+ * \param handle used to get a new channel, channel handle
+ * \param suppress_handler unused
+ * \param user_data unused
+ *
+ * \return void
+ */
+
+static void new_channel_handler( DBusGProxy *proxy, const char *object_path,
+ const char *channel_type, guint handle_type,
+ guint handle, gboolean suppress_handler,
+ gpointer user_data ) ;
+
+
+/*! \brief Is called after logout.. Any cleanup operations to
+ * be performed here. Setting conn_stat to disconnected, cleaning up
+ * of resources is done
+ */
+void action_logedout() ;
+
+/*! \brief Callback for the logout
+ *
+ * \param proxy : unused
+ * \param error : unused
+ * \param userdata : unused
+ * \return : void
+ */
+void logout_cb( DBusGProxy *proxy, GError *error, gpointer userdata );
+
+/*! \brief requests for closing of session. Also closes the search channel.
+ * \remark should not close the search channel
+ *
+ * Request for log - out
+ * \param pc - message which has the request header
+ * \return : MEM_ALLOCATION_ERROR or 0
+ */
+int action_logout( char* pc ) ;
+
+/*! \brief validates params, gets a dbus, creates a connection manager,
+ * and connection. Registers for the statuschange
+ *
+ * \param ls_hdr login struct
+ * \return Errors if invalid param or getting dbus, conn mgr or conn fails else 0
+ */
+gint action_login( login_struct* ls_hdr ) ;
+
+/*! \brief parses the message buffer and validates the parameters. The values are written
+ * to ls_hdr
+ *
+ * \param aMsgBuffer - buf to be parsed
+ * \param ls_hdr - login_struct struct to which values are written
+ * \param msg_len - no. of bytes in the message buffer aMsgBuffer
+ *
+ */
+gint parse_for_login( gchar* aMsgBuffer, login_struct** ls_hdr, int msg_len ) ;
+
+/*! \brief Calls parse_for_login to parse and validate the arguments
+ * And then calls action_login for to do actual login
+ *
+ * \param aMsgBuf message buffer
+ * \param msg_len - len of the message
+ */
+gint action_parse_login( char* aMsgBuf, int msg_len ) ;
+
+
+
+#endif //__ICONNECTIONMANAGER_H__
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isofetchcontactlist.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,159 @@
+
+/* ============================================================================
+* Name : isofetchcontactlist.h
+* Part of : isolation server.
+* Version : %version: 9 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+
+/*!
+* \def To avoid multiple inclusion of header
+*/
+#ifndef __IFETCHCONTACTLIST_H__
+#define __IFETCHCONTACTLIST_H__
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include "isoim.h"
+
+/*! \file
+* Interfaces for fetching of contacts.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+
+/*! \enum channel_type
+ * type of the channel
+ */
+enum channel_type
+ {
+ ESubscribe_Channel,
+ EPublish_Channel
+ };
+
+/*! \brief This function is called as a callback to get the contact names from
+ * contact handles. Contact names are sent to client in multiple packets of
+ * size MAX_MSG_SIZE
+ *
+ * \param proxy unused
+ * \param handles_names 2D array of contact names
+ * \param error error if any
+ * \param userdata msg_type
+ */
+static void inspect_handles_cb( DBusGProxy *proxy,char **handles_names,
+ GError *error, gpointer userdata ) ;
+
+
+/*! \brief This function is called if there are 0 contacts or there was an error
+ *
+ * \param contact_type : Type of the contacts
+ * \param err : err if any, 0 otherwise
+ */
+static gint send_fetch_contacts_error( gint contact_type , gint err );
+
+/*! \brief This function is a callback for request for the contacts
+ * in local pending contatct list from server. This is
+ * only called for publish channel members. fetch_contacts is called
+ * to get the contact names from the handles. If there are no conatcts in
+ * the list it calls send_fetch_contacts_error else requests for the contact names
+ * from the contact handles
+ *
+ * \param proxy unused
+ * \param current_members array of handles of current contatcs
+ * \param local_pending_members unused
+ * \param remote_pending_members array of handles of remote pending contatcs
+ * \param error error if any
+ * \param userdata unused
+ */
+static void get_roster_local_member_cb( DBusGProxy *proxy,GArray* current_members,
+ GArray* local_pending_members, GArray* remote_pending_members,
+ GError *error, gpointer userdata );
+
+/*! \brief Requests the server to get contact names from the handles
+ * The contact names are returned in inspect_handles_cb. From there
+ * contacts are sent to client
+ *
+ * \param contact_mem : handles to contact members
+ * \param msg_type : type of the message, which wil be passed to cb
+ * \return Errors if any, else 0
+ */
+
+static gint fetch_contacts( GArray* contact_mem, gint* msg_type ) ;
+
+/*! \brief This function is a callback for request for the contacts
+ * in msg_type(subscribe or publish) contatct list from server. This is
+ * only called for subscribe channel members. fetch_contacts is called
+ * to get the contact names from the handles. If there are no conatcts in
+ * the list it calls send_fetch_contacts_error else requests for the contacts
+ * from the handles
+ *
+ * \param proxy unused
+ * \param current_members array of handles of current contatcs
+ * \param local_pending_members unused
+ * \param remote_pending_members array of handles of remote pending contatcs
+ * \param error error if any
+ * \param userdata unused
+ */
+static void get_roster_member_cb( DBusGProxy *proxy,GArray* current_members,
+ GArray* local_pending_members, GArray* remote_pending_members,
+ GError *error, gpointer userdata ) ;
+
+
+/*! \brief this function requests for the contacts in its contatct list from server
+ *
+ * \param type of the contacts channel( publish, subscribe )
+ */
+void request_roster( enum channel_type type );
+
+/*! \brief Sends contacts to the client. Contact names are sent to client in multiple
+ * packets of size less than or equal to MAX_MSG_SIZE. Contact will be sent as a whole.
+ * A single contact will not be sent in two consecutive packets
+ *
+ * \param members : Contacts to be sent to client
+ * \param mem_count : no. of contacts
+ * \param contact_type : type of the contact
+ * \return error code..
+ */
+gint send_contacts_to_client( gchar** members, gint mem_count, gint contact_type ) ;
+
+
+/*! \brief Fetches the cached contacts stored in telepathy gabble
+ * This is as good as fetching the contacts
+ */
+void fetch_cached_contacts();
+
+#endif //__IFETCHCONTACTLIST_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isogetsearchkeys.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* ============================================================================
+* Name : isogetsearchkeys.h
+* Part of : isolation server.
+* Version : %version: 5 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+*!
+* /def To avoid multiple inclusion of header
+*/
+#ifndef __ISOGETSEARCHKEYS_H__
+#define __ISOGETSEARCHKEYS_H__
+
+/*
+*! /def For message_hdr_req
+*/
+#include "msg_enums.h"
+
+/*
+*! /brief Function to get the search keys(fields on which to
+* search ) supported by server
+*
+* /param hdr_req message header request
+*
+* /return gint MEM_ALLOCATION_ERROR
+*/
+
+gint get_search_keys( message_hdr_resp* hdr_req );
+
+#endif //__ISOGETSEARCHKEYS_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isoim.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,264 @@
+/*
+* ============================================================================
+* Name : isoim.h
+* Part of : isolation server instant messaing componenet.
+* Version : %version: 14 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* /def To avoid multiple inclusion of header
+*/
+
+#ifndef _ISOIM_H_
+#define _ISOIM_H_
+
+#include <glib.h>
+#include <gtypes.h>
+
+#include "isoservermain.h"
+#include "msg_enums.h"
+
+/*! /file
+ * Interfaces for the send / recieve of messages.
+ * client anywhere in the documentation refers to anyone
+ * using the isoserver
+ */
+
+/*! /typedef struct send_msg_struct typedefed to send_msg_struct.
+ */
+typedef struct send_msg_struct send_msg_struct;
+
+/*! /struct send_msg_struct isoim.h
+ * /brief This struct is used to pass multiple pointers as userdata to callbacks
+ *
+ * /var hdr_req header request
+ * /var msg character string(message)
+ */
+struct send_msg_struct
+ {
+ message_hdr_req* hdr_req;
+ char *msg;
+ };
+
+/*! /typedef struct _Received_UserData typedefed to Received_UserData.
+ */
+typedef struct _Received_UserData Received_UserData;
+
+/*! /struct Received_UserData isoim.h
+ * /brief This struct is used to pass multiple pointers as userdata to callbacks
+ *
+ * /var message_body message
+ * /var proxy proxy This is used for acknowledging the recieved message
+ * /var message_id This is used for acknowledging the recieved message
+ */
+struct _Received_UserData
+ {
+ gchar *message_body;
+ DBusGProxy *proxy;
+ guint message_id;
+ };
+
+/*! /typedef struct send_error_struct typedefed to send_error_struct.
+ */
+typedef struct send_error_struct send_error_struct;
+
+/*! /struct send_error_struct isoim.h
+ * /brief This struct is used to pass multiple pointers as userdata to callbacks
+ *
+ * /var hdr_resp response header
+ * /var msg_type
+ * /var timestamp
+ * /var msg_body
+ */
+struct send_error_struct
+ {
+ message_hdr_resp hdr_resp;
+ guint msg_type;
+ guint timestamp;
+ gchar* msg_body;
+ };
+
+/*! /brief requests the handles for the contacts to which message should be sent.
+ * request_handles_cb is registered as a callback. necessary data to be sent is
+ * passed as userdata
+ *
+ * /param msghdr request header that will be passed back to client
+ * /param contact_id all contacts
+ * /param message
+ * /param no_cntcts no. of contacts the msg shld be sent to
+ * /return : error code on failure, 0 on success
+ */
+void send_message( send_msg_struct* msg_hdr, const gchar **contact_id ) ;
+
+/*! /brief handles for contacts are recieved and text channel created (if already
+ * there same is used) message is sent to those contacts.
+ *
+ *
+ * /param proxy unused
+ * /param handles contact handles
+ * /param error error if any in getting the handles for contact
+ * /param userdata Has request header and message to be sent to reciever
+ * The request header is used for mapping of response to correct request
+ *
+ */
+void request_handles_cb( DBusGProxy *proxy, GArray *handles, GError* error,
+ gpointer userdata ) ;
+
+
+/*! /brief parse the params for send and validates them
+ *
+ * /param aMsgBuffer message buffer to be parsed
+ * /param aContactId pointer to an array of strings, After this function this
+ * arg wil have the contacts to which message should be sent to
+ * /param aSendMsg message to be sent
+ * /param len : msg_len no. of bytes in aMsgBuffer
+ * /param contact_count : no. of contacts
+ * /return returns error code on failure, or 0
+ */
+int parse_for_send( gchar* aMsgBuffer, gchar*** aContactId,
+ gchar** aSendMsg, gint msg_len, gint* contact_count ) ;
+
+
+/*! /brief calls parse_for_send to parse the parameters, and calls
+ * send_message for sending the message
+ *
+ * /param buf : message buffer to be parsed
+ * /param len : msg_len no. of bytes in msg_buf
+ *
+ * /return gint : parse error code if any
+ */
+int action_parse_send( gchar* buf, gint msg_len ) ;
+
+/*! /brief Function to check if the channel is already present in the maintained hash
+ * text_channels_find_func.
+ *
+ * /param key unused
+ * /param text_channel hash table element
+ * /param contact_handle to be searched item
+ * /return boolean
+ */
+gboolean text_channels_find_func( gchar *key,
+ TpChan *text_channel,
+ guint *contact_handle );
+
+/*! /brief Once the send request is sent to n/w server this callback is called
+ *
+ * /param proxy unused
+ * /param error n/w error if any
+ * /param userdata message header from which a response is formed
+ * /return void
+ */
+void sendreply_cb( DBusGProxy *proxy, GError *error, gpointer userdata ) ;
+
+/*! /brief This function is called by tg to as a response to request for the
+ * handles from the text channel. If there is no error, sent message(
+ * which has failed ) with its deatils is then sent to client
+ *
+ * /param proxy unused
+ * /param handles_names contac names (sender name)
+ * /param error error if any
+ * /param userdata send_error_struct
+ * /return void
+ */
+static void inspect_handles_for_error_cb( DBusGProxy *proxy,char **handles_names,
+ GError *error, gpointer userdata );
+
+/*! /brief This function on registered for "senderror" signal is called when the message
+ * sending is failed. Calls tp_conn_inspect_handles_async to get the contact name
+ * from text channel
+ *
+ * /param proxy : unused
+ * /param error : error code
+ * /param timestamp : sent to inspect_handles_for_error_cb thru' send_error_struct
+ * /param message_type : sent to inspect_handles_for_error_cb thru' send_error_struct
+ * /param message_body : sent to inspect_handles_for_error_cb thru' send_error_struct
+ * /param user_data text_chan from where to get the contatc name of reciepien
+ * /return void
+ */
+static void senderror_cb ( DBusGProxy *proxy,
+ guint error,
+ guint timestamp,
+ guint message_type,
+ gchar *message_body,
+ gpointer user_data );
+
+/*! /brief called as a callback to acknowledge the msg ack.
+ *
+ * /param proxy unused
+ * /param error error if any
+ * /param userdata unused
+ * /return void
+ */
+void msg_ack_pending_cb( DBusGProxy *proxy, GError *error, gpointer userdata ) ;
+
+/*! /brief This function is a callback for to get the contact name from handles.
+ * This function acknowledges the recieved message and send that to client(adap)
+ *
+ * /param proxy unused
+ * /param handles_names 2D array of message sender(one contact ended with a NULL string)
+ * /param error error if any
+ * /param userdata Received_UserData that has message body, response header etc.,
+ * /return void
+ */
+static void getting_sender_cb( DBusGProxy *proxy,char **handles_names,
+ GError *error, gpointer userdata ) ;
+
+/*! /brief when a message is recieved this function is called by
+ * telepathygabble(by emitting signal). This function then requests tg
+ * to get the contact names corresponding to handles.
+ *
+ * /param proxy sent to getting_sender_cb as param in userdata
+ * /param timestamp unused
+ * /param handles_names
+ * /param message_type unused
+ * /param message_flags unused
+ * /param message_body recieved message
+ * /param userdata unused
+ */
+void receivedMessage_cb ( DBusGProxy *proxy,
+ guint message_id,
+ guint timestamp,
+ guint from_handle,
+ guint message_type,
+ guint message_flags,
+ gchar *message_body,
+ gpointer user_data );
+/*! /brief whenevr a new channel handler for text is created, this function is called. This
+ * function also registers that channel for Received and SendError signals. Also the pending
+ * messages are also retrieved in this function
+ *
+ * /param tp_chan new channel created
+ */
+void text_channel_init ( TpChan *text_chan );
+
+/*! /brief called by getting_sender_cb to send the recieved message to client
+ *
+ * /param msg message recieved
+ * /param sender message from whom recieved
+ */
+int send_message_to_client( const gchar *msg , const gchar *sender);
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isomodifycontactlist.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,159 @@
+
+/* ============================================================================
+* Name : isomodifycontacts.h
+* Part of : isolation server.
+* Version : %version: 7 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* /def To avoid multiple inclusion of header
+*/
+#ifndef __ISOADDCONTACTS_H__
+#define __ISOADDCONTACTS_H__
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include "isoim.h"
+
+/*! /file
+ * Interfaces for the maintainence of the contact list.
+ * client anywhere in the documentation refers to anyone
+ * using the isoserver
+ */
+
+/*!
+ * /brief This function is called by message_send_recv function in isoservermain.c if message type
+ * is EReject_Contact_Request, EAccept_Contact_Request, EAdd_Contact_Request and EDelete_Contact_Request.
+ * Contacts added/removed to/from list. This function parses the message buffer,
+ * validates for the arguments and calls modify_contact_list to add/remove contacts
+ *
+ * /param buf : buffer to be parsed
+ * /param buf_len : buffer length
+ * /return : error code if any, 0 on success
+ */
+gint action_parse_modify_contact_list( gchar* buf, gint buf_len ) ;
+
+/*!
+ * /brief gets the handles for contacts. Handles are returned in request_modify_contact_list_handles_cb
+ * callback which is an arg for the async request to get handles.
+ *
+ * /param msg_hdr : The header and message passed to callbacks
+ * /param contact_id : contact ids whose handles to be returned
+ * /param no_cntcts : total no. of contacts to be added
+ * /return : error code if any, handle on success
+ */
+guint get_handles_for_contacts ( send_msg_struct* msg_hdr,
+ const gchar **contact_id, gint no_cntcts );
+
+/*!
+ * /brief Handles are returned in this callback. Which will then actually do modify
+ * the contact list based on the request type(add/remove/accept/reject)
+ * modify_contact_list_cb is registered as the callback.
+ *
+ * /param proxy : unused
+ * /param handles : handles of the contacts
+ * /param error : error if any
+ * /param message : userdata(send_msg_struct) passed back
+ * /return : error code if any, handle on success
+ */
+void request_modify_contact_list_handles_cb( DBusGProxy *proxy, GArray *handles,
+ GError* error, gpointer message );
+
+/*!
+ * /brief Calls get_handles_for_contacts to get the handles for contact.
+ *
+ * /param msg_hdr : message request header passed to callbacks
+ * /param contact_id : contact ids to be added
+ * /param message : messgae if any
+ * /param no_cntcts : no of contacts to be added
+ * /return void
+ */
+gint modify_contact_list ( send_msg_struct* msg_hdr, const gchar **contact_ids,
+ gint no_cntcts );
+
+/*!
+ * /brief called as callback for request for modify contact list
+ * This function then sends the result to client
+ *
+ * /param proxy unused
+ * /param error Error if any
+ * /param userdata request message header
+ * /return void
+ */
+void modify_contact_list_cb( DBusGProxy *proxy, GError *error, gpointer userdata );
+
+/*!
+ * /brief The contact names corresponding to the contact handles that are changed
+ * are passed to the client
+ * /param proxy
+ * /param handles_name
+ * /param error
+ * /param userdata
+ * /return void
+ */
+static void rosters_changed_contacts_cb( DBusGProxy *proxy,
+ gchar **handles_names, GError *error, gpointer userdata );
+
+
+/*! /brief Whenever contact list is changed by others( someone trying to add this user
+ * or someone rejecting the add request etc., ) this callback registered as a signal
+ * is called with the handles of the changed contacts. rosters_changed_contacts_cb is
+ * passed as callback to get the contact name of the changed handles
+ *
+ * /param group_iface unused
+ * /param message unused
+ * /param added List of contacts that are recently added
+ * /param removed List of contacts that were recently removed
+ * /param local_pending List of contacts that are locally pending for approval
+ * /param remote_pending List of contacts that are remotely pending for approval
+ * /param actor unused
+ * /param reason unused
+ * /param userdata unused
+ * /return void
+ */
+void roster_members_changed_cb ( DBusGProxy *group_iface,
+ gchar *message,
+ GArray *added,
+ GArray *removed,
+ GArray *local_pending,
+ GArray *remote_pending,
+ guint actor,
+ guint reason,
+ gpointer userdata );
+
+
+
+#endif //__ISOADDCONTACTS_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isopresence.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,338 @@
+/* ============================================================================
+* Name : isopresence.h
+* Part of : isolation server.
+* Version : %version: 7 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* /def To avoid multiple inclusion of header
+*/
+
+#ifndef __ISOPRESENCE_H__
+#define __ISOPRESENCE_H__
+#include <glib.h>
+#include <gtypes.h>
+
+#include "isoservermain.h"
+#include "msg_enums.h"
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-props-iface.h"
+#include "tp-interfaces.h"
+#include "tp-conn-iface-presence-gen.h"
+
+G_BEGIN_DECLS
+
+/*! /file
+* This file has interfaces for presence implimentation.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+
+/*! /typedef struct presence_msg_struct typedefed to presence_msg_struct
+ */
+typedef struct presence_msg_struct presence_msg_struct;
+
+/*! /struct presence_msg_struct isopresence
+ * /brief
+ *
+ * /var hdr_req header request
+ * /var useravailability availability, presence
+ * /var statustext status text
+ */
+struct presence_msg_struct
+ {
+ message_hdr_req* hdr_req;
+ char *useravailability;
+ char *statustext;
+ };
+
+
+#define TELEPATHY_TYPE_PRESENCE (telepathy_presence_get_type ())
+#define TELEPATHY_PRESENCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TELEPATHY_TYPE_PRESENCE, TelepathyPresence))
+#define TELEPATHY_PRESENCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TELEPATHY_TYPE_PRESENCE, TelepathyPresenceClass))
+#define TELEPATHY_IS_PRESENCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TELEPATHY_TYPE_PRESENCE))
+#define TELEPATHY_IS_PRESENCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TELEPATHY_TYPE_PRESENCE))
+#define TELEPATHY_PRESENCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TELEPATHY_TYPE_PRESENCE, TelepathyPresenceClass))
+
+/*! /typedef struct _TelepathyPresence typedefed to TelepathyPresence
+ */
+typedef struct _TelepathyPresence TelepathyPresence;
+
+/*! /typedef struct _TelepathyPresenceClass typedefed to TelepathyPresenceClass
+ */
+typedef struct _TelepathyPresenceClass TelepathyPresenceClass;
+
+/*! /struct _TelepathyPresence isopresence.h
+ * /var parent
+ */
+struct _TelepathyPresence {
+ GObject parent;
+};
+
+/*! /struct _TelepathyPresenceClass isopresence.h
+ * /var parent_class
+ */
+struct _TelepathyPresenceClass {
+ GObjectClass parent_class;
+};
+
+/*! /typedef struct _TelepathyPresenceClass typedefed to TelepathyPresenceClass
+ */
+
+/*! /enum presence states of the user
+ */
+typedef enum {
+ TELEPATHY_PRESENCE_STATE_AVAILABLE,
+ TELEPATHY_PRESENCE_STATE_BUSY,
+ TELEPATHY_PRESENCE_STATE_AWAY,
+ TELEPATHY_PRESENCE_STATE_EXT_AWAY,
+ TELEPATHY_PRESENCE_STATE_HIDDEN, /* When you appear offline to others */
+ TELEPATHY_PRESENCE_STATE_UNAVAILABLE,
+} TelepathyPresenceState;
+
+GType telepathy_presence_get_type (void) G_GNUC_CONST;
+
+/*! /brief create a presence object instance
+ * /return created presence object instance
+ */
+TelepathyPresence *
+telepathy_presence_new (void);
+
+/*! /brief get the presence state value
+ *
+ * /param presence : presence object
+ * /return state : state as set in presence object
+ */
+TelepathyPresenceState
+telepathy_presence_get_state (TelepathyPresence *presence);
+
+
+/*! /brief get the presence status value
+ *
+ * /param presence : presence object
+ * /return state : status as set in presence object
+ */
+const gchar *
+telepathy_presence_get_status (TelepathyPresence *presence);
+
+/*! /brief set the presence state value in presence gobject
+ *
+ * /param presence : presence object
+ * /param state : state
+ * /return : void
+ */
+void
+telepathy_presence_set_state (TelepathyPresence *presence,
+ TelepathyPresenceState state);
+
+/*! /brief set the presence status text value in presence gobject
+ *
+ * /param presence : presence object
+ * /param state : status
+ * /return : void
+ */
+void
+telepathy_presence_set_status (TelepathyPresence *presence,
+ const gchar *status);
+
+/*! /brief converts presence state value from enum to string
+ * /param presence_state : presence state enum value
+ * /return : presence state string value
+ */
+const gchar *
+telepathy_presence_state_to_str (TelepathyPresenceState presence_state);
+
+
+/*! /brief converts presence state value from string to enum
+ *
+ * /param str : presence state string value
+ * /return : presence state enum value
+ */
+TelepathyPresenceState
+telepathy_telepathy_presence_state_from_str (const gchar *str);
+
+/*! /brief Registered as a signal for presence updates of
+ * other users. This function will be called whenevr a contact
+ * to whom this user has subscribed for presence changes his
+ * presence state or status message.
+ *
+ * /param proxy : unused
+ * /param handle_hash : hash table containing presence information
+ * as hash value, contact handle as key
+ * /return : void
+ */
+void
+telepathy_presence_handler(DBusGProxy *proxy,
+ GHashTable *handle_hash);
+
+/*! /brief updates own presence to the n/w server. update_status_cb
+ * is registered for the callback
+ *
+ * /param pres_iface : presence interface
+ * /param presence : presence object
+ * /param msg_hdr : presence info list to send presence_msg_struct
+ * has state, status etc.,
+ * /return : void
+ */
+void
+telepathy_contacts_send_presence (DBusGProxy *pres_iface,
+ TelepathyPresence *presence,
+ presence_msg_struct* msg_hdr );
+
+/*! /brief This function will be called for presence of each contact
+ * key has got the state and value status
+ *
+ * /param key : hash table key ie presence state
+ * /param value : hash table value ie presence information
+ * /param presence : user data
+ * /remark presence object is logically unused ?
+ *
+ * /return : void
+ */
+static void
+telepathy_presences_foreach (gpointer *key,
+ gpointer *value,
+ TelepathyPresence **presence);
+
+
+/*! /brief This function will be called for each contact. Contact name is
+ * got from the contcat handle, telepathy_presences_foreach is called
+ * to get the presence from value of the hash table
+ *
+ * @param key : hash table key ie contact handle id
+ * @param value : hash table value ie presence
+ * @return : void
+ */
+static void
+telepathy_presence_handle_foreach (gpointer *key,
+ gpointer *value);
+
+
+/*! /brief callback for updating own presence. This function
+ * sends response to client
+ *
+ * /param proxy : unused
+ * /param error : error if any
+ * /param message : message header
+ * /return : void
+ */
+void
+update_status_cb(DBusGProxy *proxy,
+ GError* error,
+ gpointer message);
+
+
+/*! /brief Sends presence of conatct to the client. Forms
+ * the proper presence message format and sends that to client
+ *
+ * /param : availability user availability
+ * /param : text custom status message set by user
+ * /return : error code on failure, 0 on success
+ */
+int
+send_presence_to_client( const gchar *availability,
+ const gchar *text );
+
+/*! /brief sends presence of the client to n/w server thru' gabble
+ * calls telepathy_contacts_send_presence to send presence
+ *
+ * /param msghdr request header that will be passed back to client
+ * /param message_type_err unused
+ * /remark please remove this unused variable(why was this added?)
+ *
+ * /return : error code on failure, 0 on success
+ */
+void
+send_presence( presence_msg_struct* msg_hdr,
+ gint message_type_err ) ;
+
+
+/*! /brief parses the message buffer. aPresenceStatus and aStatustext
+ * pointers updated
+ *
+ * /param aMsgBuffer message buffer
+ * /param aPresenceStatus after call to this function it will
+ * have the presence status to be updated
+ * /param aStatustext after call to this function it will
+ * have the status text to be updated
+ *
+ * /param msg_len : msg_len no. of bytes in msg_buf
+ * /return returns error code on failure, or 0
+ */
+int
+parse_for_presence( gchar* aMsgBuffer,
+ gchar** aPresenceStatus,
+ gchar** aStatustext,
+ gint msg_len ) ;
+
+/*! /brief Parses the message from client and sends the presence
+ * to n/w server. A err is returned if there is any parse error
+ * or out of memory condition
+ *
+ * /param buf : buffer to be parsed
+ * /param buf_len : buffer length
+ * /return : error code if any, 0 on success
+ */
+int
+action_parse_presence( gchar* buf,
+ gint buf_len ) ;
+
+/*! /brief GObject finalize funtion
+*
+* /param object object to be finalized
+*/
+static void presence_finalize (GObject *object);
+
+/*! /brief GObject get property funtion
+*
+* /param object Gobject
+* /param param_id
+* /param value
+* /param pspec
+*/
+static void presence_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+/*! /brief GObject set property funtion
+*
+* /param object Gobject
+* /param param_id
+* /param value
+* /param pspec
+*/
+static void presence_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+G_END_DECLS
+
+
+#endif //__ISOPRESENCE_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isosearch.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,86 @@
+/*
+* ============================================================================
+* Name : isosearch.h
+* Part of : isolation server.
+* Version : %version: 8 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* /def To avoid multiple inclusion of header
+*/
+#ifndef __ISOSEARCH_H__
+#define __ISOSEARCH_H__
+
+/*! /file
+* Header file for search feature implimentation. The interfaces mentioned are
+* the only those which are used(extern) by functions in other files. Functions which
+* are locally used in isosearch.c are not added here. And those functions are forward
+* declared.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+
+/*
+! /This header has definitions for glib types
+*/
+#include <gtypes.h>
+
+/*
+! /This header has definitions for DBusGProxy
+*/
+#include <dbus/dbus-glib.h>
+
+
+/*
+! /brief This function is called by message_send_recv function in isoservermain.c if message type
+* is ESearch. This function parses the rmsg, validates the parameter passed, if parameters are
+* correct a search performed for them. else INVALID_PARAMETERES error is returned
+*
+* /param rmsg message buffer to be parsed
+* /param rmsg_len the length of the rmsg
+* /remark rmsg_len is not strlen(rmsg)
+* /return returns error code or 0 on success
+*/
+gint action_parse_search( gchar* rmsg, gint rmsg_len );
+
+
+
+/*
+! /brief This function is called as a callback when a search channel is closed
+* /remark This function should have been a static function in isosearch.c
+* A work around has been done to make multiple search requests.
+*
+* /param proxy unused variable
+* /param error Error if any
+* /param user_data callback data
+* /return void
+*/
+void search_chan_closed_cb ( DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data
+ );
+
+#endif //__ISOSEARCH_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isoservermain.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,195 @@
+/*
+* ============================================================================
+* Name : isoservermain.h
+* Part of : isolation server.
+* Version : %version: 18 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* /def To avoid multiple inclusion of header
+*/
+#ifndef __ISO_SERVER_H_
+#define __ISO_SERVER_H_
+
+#include <glib.h>
+#include <gtypes.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+
+#include "tp-chan-type-text-gen.h"
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-conn-gen.h"
+#include "tp-props-iface.h"
+#include "tp-interfaces.h"
+#include "tp-conn-iface-presence-gen.h"
+
+#include "msg_enums.h"
+
+/*! /file
+* Header file for the isolation server main. This file has implimentations
+* to recieve messages from client and delegate the requests to other
+* funtions based on the message type.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+
+enum connection_status
+ {
+ connecting = -1,
+ connected,
+ disconnected,
+ disconnecting,
+ not_connected
+ };
+/*! /typedef struct userConnection typedefed to userConnection
+*/
+typedef struct userConnection userConnection;
+
+/*! /struct userConnection isoservermain.h
+* /brief There is only one object of this struct. This struct represents
+* one login session. This strcut has all the necessary data members to
+* maintain a session.
+*
+* /var conn telepathy connection object
+* /var connmgr telepathy connection manager object
+* /var dbusCon D-Bus
+*
+* /var isConnected Boolean : If loged in
+*
+* /var current_members_names : 2D char array having the current members list
+* /var local_pending_names : 2D char array having the locally pending members list
+* /var remote_pending_names : 2D char array having the remotely pending members list
+*
+* /var group_iface_subscribe : Interface to subscribe list
+* /var group_iface_publish : Interface to publish list
+* /var group_iface_known : Interface to known list
+*
+* /var connmgr_bus : connection manager bus
+*
+* /var text_channels : open text(chat) channels
+*
+* /var pres_iface : Interface for presence
+*
+* /var search_chan : channel for search
+* /var search_hdr_req : request header for search
+*
+*/
+struct userConnection
+ {
+ TpConn* conn;
+ DBusGConnection* dbusConn;
+ TpConnMgr* connmgr;
+ enum connection_status conn_stat;
+
+ gchar** current_members_names;
+ gchar** local_pending_names;
+ gchar** remote_pending_names;
+
+
+ DBusGProxy *group_iface_subscribe;
+ DBusGProxy *group_iface_publish;
+ DBusGProxy *group_iface_known;
+
+ gchar* connmgr_bus;
+
+ GHashTable *text_channels;
+
+ TpPropsIface *pres_iface;
+
+ TpChan *search_chan;
+ message_hdr_req* search_hdr_req;
+
+ gboolean logout_flag;
+ };
+
+/*! /typedef struct globalMainloop to globalMainloop
+*/
+typedef struct globalMainloop globalMainloop;
+
+/*! /struct globalMainloop isoservermain.h
+* /brief Has a pointer to the mainloop. This mainloop runs in a
+* thread created by the main thread(isoserver.exe). This loop
+* listens to the event from telepathygabble
+*
+* /var mainloop pointer to the mainloop
+*/
+struct globalMainloop
+ {
+ GMainLoop* mainloop;
+ };
+
+/*! /var mainloop_struct global variable for mainloop
+* /brief This variable can not be put into userConnection as the life
+* time of a mainloop is not related to per login session
+*/
+extern globalMainloop mainloop_struct;
+
+/*! /var globalCon represents one login session
+*/
+extern userConnection globalCon;
+
+/*! /brief This message reads message type from the message buffer
+* passed as argument
+*
+* /var pc message buffer
+*
+* /return pointer to message header response which has the message type
+*/
+message_hdr_resp* read_message_type( gchar* pc ) ;
+
+/*! /brief This is an entry point to the thread. isoserver.exe
+* creates a thread which runs a mainloop. mainloop is passed as
+* argument to the thread entry function. This mainloop which is
+* run in the thread listens for the events from telepathygabble
+*
+* /var data unused param
+*/
+gpointer thread_entry( gpointer data ) ;
+
+/*! /brief If there are any parse error, this function is called to
+* dispatch the error to client.
+*
+* /param msg_struct The response header to be sent
+* /param err Error
+*/
+gint send_error( message_hdr_resp* msg_struct, gint err );
+
+/*! /brief This function waits for the requests from the client.
+* Requests are parsed, validated and appropriate actions taken.
+* A new thread is created when login happens. This function runs
+* a while loop which is only quit when a kill request is recieved
+* from the client.
+*
+* /remark should this thread be created before login?
+* /remark when is the mainloop quit ? (Should that be after logout or
+* after getting a kill request from the client)
+*/
+int message_send_recv() ;
+
+#endif //__ISO_SERVER_H_
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/inc/isoutils.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,114 @@
+
+/* ============================================================================
+* Name : isoutils.h
+* Part of : isolation server.
+* Version : %version: 8 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*!
+* /def To avoid multiple inclusion of header
+*/
+#ifndef __ISOUTILS_H__
+#define __ISOUTILS_H__
+
+/*
+*! /file
+* Header file for the isolation utilities.
+* client anywhere in the documentation refers to anyone
+* using the isoserver
+*/
+#include "msg_enums.h"
+
+
+/*
+ * ! /brief Function for to log the messages. Ultimately uses fprintf and putc to
+ * write to file. This function takes variable no of arguments.
+ *
+ * /param fmt format specifier.
+ * /return void
+ */
+void iso_logger ( gchar* fmt, ... );
+
+/*
+*! /brief parses a buffer into an array of strings. Message buffer
+* test.ximp@gmail.com/0ximp.telepathy@gmail.com/0/0
+* ^ ^
+* contact1------------|contact2-----------------|
+* str will have contact1 for 1st time, contact2 on 2nd call
+*
+* /param message buffer : Buffer to be parsed
+* /param str : str will have pointer to a string
+* /param len : Len returns the number of bytes read
+* /param msg_len : no. of bytes in msg_buf
+* /return gint : error if any on failure, else no. of strings read from buffer
+*/
+gint parse_a_string( gchar* msg_buf, gchar** str, gint* len, gint msg_len );
+
+/*
+*!
+* /brief parses a buffer into an array of strings
+*
+* /param message buffer : Buffer to be parsed
+* /param arr_str : Parsed strings are returned in this array of strings
+* /param len : Len returns the number of bytes read
+* /param len : msg_len no. of bytes in msg_buf
+* /param cntidscount : no. of contacts
+* /return gint : error if any on failure, else no. of strings read from buffer
+* example
+* test.ximp@gmail.com/0ximp.telepathy@gmail.com/0/0
+* ^ ^ ^ ^
+* contact1------------|contact2-----------------|-|
+* is parsed into
+* arr_str[0] = test.ximp@gmail.com/0
+* arr_str[1] = ximp.telepathy@gmail.com/0
+*/
+gint parse_into_array_of_strings( gchar* msg_buf,
+ gchar*** arr_str, gint* len, gint msg_len,
+ gint* cntidscount ) ;
+
+/*
+ *! /brief Frees the memory allocated to the array of string and to the message
+ *
+ * /param contactid : array of string to be freed.
+ * /param contacts_count : no of contacts
+ * /param sendmsg : msg to be freed
+ */
+void free_msg_args( gchar** contactid, gint contacts_count, gchar* sendmsg );
+
+
+/*
+ *! /brief Send the response for the porcessing of request to the client
+ *
+ * /param hdr_req : message request header
+ * /param error : error code
+ * /param response : whether the processing of request successful
+ *
+ */
+gint send_response_to_client( message_hdr_req* hdr_req, gint error,
+ gboolean response );
+
+#endif //__ISOUTILS_H__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isoavtar.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,308 @@
+/*
+* ============================================================================
+* Name : isoconnectionmanager.c
+* Part of : isolation server.
+* Version : %version: 6 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+#include "tp-conn.h"
+#include "isoavtar.h"
+#include "stdio.h"
+#include "isoservermain.h"
+#include "msgliterals.h"
+#include "msgqlib.h"
+#include "msg_enums.h"
+#include "isoutils.h"
+
+
+#include <string.h>
+#include <stdlib.h>
+
+/*
+ * ! \file
+ * Implements the functions in isoavtar.h
+ */
+
+
+/*! \brief callback for updating own avtar. This function
+ * sends response to client
+ *
+ * \param proxy : unused
+ * \param avatar_sha1: token string
+ * \param error : error if any
+ * \param message : message header
+ * \return : void
+ */
+void update_avtar_cb(DBusGProxy *proxy, char* avatar_sha1, GError* error, gpointer userdata)
+ {
+
+ int err = 0;
+ //user data is of type message_hdr_req
+ message_hdr_req* msg_hdr = ( message_hdr_req* ) userdata;
+ // create the msg queue
+
+ iso_logger( "%s", "In - update_avtar_cb\n" );
+ UNUSED_FORMAL_PARAM(proxy);
+
+ //msg_hdr should never be NULL
+
+ if ( NULL != error )
+ {
+ //There was some error
+ //send the response for the msg_hdr request to client
+
+ iso_logger( "%s", "error in update_avtar_cb" );
+ err = send_response_to_client( msg_hdr, error->code, 0 );
+ g_error_free(error);
+ }
+ else
+ {
+ //If the set avatar was successful then send the msg_hdr alongwith the avatar sha1 to client
+ //<todo> : sending the avatar sha1
+
+ iso_logger( "%s %s", "avatar sha1 is : ", avatar_sha1 );
+ err = send_response_to_client( msg_hdr, 0, 1 );
+ free ( avatar_sha1 );
+ }
+
+ if ( err < 0 )
+ {
+ // failed to deliver
+ iso_logger( "%s", "failed to deliver\n" );
+ }
+ free( msg_hdr );
+
+ iso_logger( "%s", "Out - update_avtar_cb\n" );
+
+ }
+
+/*! \brief sends avtar of the client to n/w server thru' gabble
+ * calls tp_conn_iface_avatars_set_avatar_async to set avatar
+ *
+ * \param avtarcontent : avatar image content
+ * \param mimetype : mime type
+ * \param msghdr request header that will be passed back to client
+ *
+ * \return : error code on failure, 0 on success
+ */
+gint send_avtar( GArray* avtarcontent , char * mimetype , message_hdr_req *msg_hdr )
+ {
+
+ gint error = 0;
+ DBusGProxy* avatar_face = NULL;
+ message_hdr_req *hdr_req = NULL;
+ iso_logger( "%s", "In - send_avtar\n" );
+
+ //Allocate the memory for header req and initialize that to 0
+ hdr_req = ( message_hdr_req* ) calloc ( sizeof( message_hdr_req ), 1 );
+ if ( NULL == hdr_req )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //msg_hdr can never be NULL.. handled in the case
+ memcpy( hdr_req, msg_hdr, sizeof( message_hdr_req ) );
+
+ //Registering for signal to be done at different loation
+ /*dbus_g_proxy_connect_signal (DBUS_G_PROXY(globalCon.conn), "AvatarUpdated",
+ G_CALLBACK (avatar_updated_signal),
+ NULL, NULL); */
+ //get the interface
+ avatar_face = tp_conn_get_interface (
+ globalCon.conn, TELEPATHY_CONN_IFACE_AVATAR_QUARK);
+
+ if ( avatar_face )
+ {
+ //make call to the lib telepathy to set the avatar. update_avtar_cb is registered as the callback
+ tp_conn_iface_avatars_set_avatar_async (avatar_face, avtarcontent, mimetype, update_avtar_cb, (gpointer)hdr_req);
+ }
+ else {
+ error = TP_AVATAR_IFACE_ERROR;
+ }
+
+ iso_logger( "%s", "Out - send_avtar\n" );
+ return error;
+ }
+
+/*! \brief callback for clearing own avtar. This function
+ * sends response to client
+ *
+ * \param proxy : unused
+ * \param error : error if any
+ * \param userdata : message header
+ * \return : void
+ */
+void clear_avtar_cb( DBusGProxy *proxy, GError* error, gpointer userdata )
+ {
+
+ int err = 0;
+ //user data is of type message_hdr_req
+ message_hdr_req* msg_hdr = ( message_hdr_req* ) userdata;
+
+ iso_logger( "%s", "In - clear_avtar_cb\n" );
+ UNUSED_FORMAL_PARAM(proxy);
+
+ //msg_hdr should never be NULL
+
+ if ( NULL != error )
+ {
+ //There was some error
+ //send the response for the msg_hdr request to client
+
+ iso_logger( "%s", "error in clear_avtar_cb" );
+ err = send_response_to_client( msg_hdr, error->code, 0 );
+ g_error_free(error);
+ }
+ else
+ {
+ err = send_response_to_client( msg_hdr, 0, 1 );
+ }
+
+ if ( err < 0 )
+ {
+ // failed to deliver
+ iso_logger( "%s", "failed to deliver\n" );
+ }
+ free( msg_hdr );
+ iso_logger( "%s", "Out - clear_avtar_cb\n" );
+
+ }
+/*! \brief clears the self avtar
+ *
+ * \param msghdr request header that will be passed back to client
+ *
+ * \return : error code on failure, 0 on success
+ */
+gint clear_avatar( message_hdr_req *msg_hdr )
+ {
+ gint error = 0;
+ DBusGProxy* avatar_face = NULL;
+ message_hdr_req *hdr_req = NULL;
+ iso_logger( "%s", "In - clear_avtar\n" );
+
+ //Allocate the memory for header req and initialize that to 0
+ hdr_req = ( message_hdr_req* ) calloc ( sizeof( message_hdr_req ), 1 );
+ if ( NULL == hdr_req )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //msg_hdr can never be NULL.. handled in the case
+ memcpy( hdr_req, msg_hdr, sizeof( message_hdr_req ) );
+
+ //get the interface
+ avatar_face = tp_conn_get_interface (
+ globalCon.conn, TELEPATHY_CONN_IFACE_AVATAR_QUARK);
+
+ if ( avatar_face )
+ {
+ tp_conn_iface_avatars_clear_avatar_async(avatar_face, clear_avtar_cb, (gpointer)hdr_req);
+ }
+ else {
+ error = TP_AVATAR_IFACE_ERROR;
+ }
+
+ iso_logger( "%s", "Out - clear_avtar\n" );
+
+ return error;
+
+ }
+/*! \brief clears the self avtar
+ * \param rmsg : message buffer to be parsed
+ * \param msg_struct : request header
+ * \param result : message buffer length
+ * \param avtarcontent : pointer to the avatar image data
+ *
+ * \return : error code on failure, 0 on success
+ */
+gint update_own_avatar(char* rmsg,message_hdr_resp* msg_struct,gint result, GArray** avtarcontent)
+ {
+ int len = 0;
+ int err = 0;
+ static gboolean fetch_avatar_data = 0;
+ static gchar *mimetype = NULL;
+
+
+ iso_logger( "%s", "In - EUpdateOwnAvtar\n" );
+
+ if(!fetch_avatar_data)
+ {
+ //parse mime type
+ //calculating len for request header
+ //skip the msg_hdr part
+
+ len += sizeof( message_hdr_req );
+
+ *avtarcontent = g_array_new ( FALSE, FALSE, sizeof ( gchar ) );
+ if ( NULL == *avtarcontent )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ // reading a mimetype from buffer
+ err = parse_a_string( rmsg, &mimetype, &len, result );
+
+ if ( err < 0 )
+ {
+ goto oom;
+ }
+
+ fetch_avatar_data = 1;
+ }
+ else
+ {
+ len = sizeof( message_hdr_req );
+ }
+
+
+ g_array_append_vals( *avtarcontent, rmsg + len, result - len );
+
+
+ if(! msg_struct->hdr_req.continue_flag )
+ {
+ err = send_avtar( *avtarcontent, mimetype, &(msg_struct->hdr_req) );
+
+ fetch_avatar_data = 0; //reset the value so that if set avatar requested for
+ //falling of to goto oom
+
+ }
+ else {
+ //Continue flag is set and read the data again return 0
+ return 0;
+ }
+
+ oom:
+ //Free the memory if err or operation complete ( sent to libeteleapthy)
+ if ( *avtarcontent )
+ {
+ g_array_free( *avtarcontent, (*avtarcontent)->len );
+ *avtarcontent = NULL;
+ }
+ if( mimetype )
+ {
+ free ( mimetype );
+ }
+ return err;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isoconnectionmanager.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,829 @@
+/*
+* ============================================================================
+* Name : isoconnectionmanager.c
+* Part of : isolation server.
+* Version : %version: 24 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+
+#include <glib.h>
+#include <gtypes.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "isoconnectionmanager.h"
+#include "isomodifycontactlist.h" //For roster_members_changed_cb
+#include "isoutils.h" //for loger and othr func
+#include "isofetchcontactlist.h" //For request_roster
+
+#include "msgliterals.h"
+#include "isoservermain.h"
+#include "isopresence.h"
+#include "isosearch.h"
+#include "msg_enums.h"
+
+enum disconnect_reason
+ {
+ EConnection_Status_Reason_None_Specified = 0,
+ EConnection_Status_Reason_Requested,
+ EConnection_Status_Reason_Network_Error,
+ EConnection_Status_Reason_Authentication_Failed,
+ };
+//userConnection globalCon;
+
+/*! \file
+* Impliments the functions in isoconnectionmanager.h
+*/
+
+/*! \brief Documented in the header file
+*/
+static void check_conn_properties(TpConn *conn)
+{
+ TpPropsIface *pres_iface;
+
+ pres_iface = TELEPATHY_PROPS_IFACE (tp_conn_get_interface (
+ conn, TELEPATHY_CONN_IFACE_PRESENCE_QUARK));
+ if (pres_iface != NULL)
+ {
+ globalCon.pres_iface = pres_iface;
+ dbus_g_proxy_connect_signal(DBUS_G_PROXY(pres_iface),
+ "PresenceUpdate",
+ G_CALLBACK(telepathy_presence_handler),
+ NULL, NULL);
+ }
+ else
+ {
+ g_warning ("The connection object does not support " TP_IFACE_PROPERTIES);
+ }
+}
+
+/*! \brief This function is registered in action_login for statuschanged signal.
+ * This function is called by telepathygabble when the status of the user changes
+ * Once user is connected this function registers for NewChannel signal with telepathygabble
+ * client is also informed of the status change..
+ *
+ * \param proxy
+ * \param status status of the user ( connected/connecting/disconnected )
+ * \param reason reason for status change(server disconnected/ user requested etc.,)
+ * \param user_data message header request
+ *
+ * \return : Boolean True on success, false on failure
+ */
+
+static gboolean status_changed_cb(DBusGProxy *proxy,
+ guint status, guint reason,
+ gpointer user_data)
+ {
+
+
+ int err = 0;
+
+ message_hdr_req* hdr_req = ( message_hdr_req* )user_data;
+ // create the msg queue
+ iso_logger( "%s", "In - status_changed_cb\n" );
+
+ //switch to the connection status
+ switch ( status )
+ {
+ case EConnected:
+ {
+ //Connected..
+ iso_logger( "%s", "connected\n" );
+ //Get connection interfaces
+ check_conn_properties(TELEPATHY_CONN(proxy));
+ //Connect to the signal for new channels
+ dbus_g_proxy_connect_signal( DBUS_G_PROXY( globalCon.conn ), "NewChannel",
+ G_CALLBACK( new_channel_handler ),
+ NULL, NULL );
+ //send response to client..
+ err = send_response_to_client( hdr_req, reason, 1 );
+ //hdr_req would be freed here
+ //Disconnect the previous signal for connected
+ //This is to pass the diff msg hdr as cb userdata for disconnect
+ /*dbus_g_proxy_disconnect_signal( DBUS_G_PROXY( globalCon.conn ), StatusChangedStr,
+ G_CALLBACK( status_changed_cb ),
+ hdr_req );*/
+
+ globalCon.conn_stat = connected;
+ break;
+ }
+ case EConnecting:
+ {//Connecting..
+ iso_logger( "%s", "connecting\n" );
+ //already done after creating the thread
+ //globalCon.conn_stat = connecting;
+ break;
+ }
+ case ENotConnected:
+ {
+ //DisConnected....
+ //Set the reason for disconnection
+ iso_logger( "%s : %d : %s : %d", "disconnected and reason is", reason, "state is ", globalCon.conn_stat );
+ //reset the flag to not connected
+
+ //should here be not_connected != globalCon.conn_stat && disconnected != globalCon.conn_stat
+ //and all login errors should set the conn_stat to disconnected
+ if ( not_connected != globalCon.conn_stat && disconnected != globalCon.conn_stat )
+ {
+ int success = 1;
+ int error = 0;
+
+ action_logedout();
+
+ //switch for the reason of logout
+ switch ( reason )
+ {
+ //set appropriate message types and error if any
+ case EConnection_Status_Reason_None_Specified:
+ if ( connecting == globalCon.conn_stat )
+ {
+ //not yet connected and user has cancelled the a/p
+ hdr_req->message_type = ELogin_Request;
+ error = ELOGIN_NONE_SPECIFIED;
+ success = 0;
+ }
+ else {
+ //connected and user has cancelled the a/p
+ //state is going to be not connected as fr these cases ossadaptation is
+ //going to send handle request terminated signal
+ hdr_req->message_type = EUserEndGprs;
+
+ }
+
+ break;
+ case EConnection_Status_Reason_Requested:
+ hdr_req->message_type = ELogout_Request;
+
+ break;
+ case EConnection_Status_Reason_Network_Error:
+ if ( connecting == globalCon.conn_stat )
+ {
+ //not yet connected and user has cancelled the a/p
+ hdr_req->message_type = ELogin_Request;
+ error = ELOGIN_NETWORK_ERROR;
+ success = 0;
+ }
+ else {
+ //state is going to be not connected as fr these cases ossadaptation is
+ //going to send handle request terminated signal
+ hdr_req->message_type = EServer_DisConnect_Request;
+
+ }
+
+ break;
+ case EConnection_Status_Reason_Authentication_Failed:
+ hdr_req->message_type = ELogin_Request;
+ error = ELOGIN_AUTHENTICATION;
+ success = 0;
+
+ break;
+ default:
+ hdr_req->message_type = ELogin_Request;
+ error = ELOGIN_AUTHORIZATION;
+ success = 0;
+
+ break;
+
+ }
+ //to set to no more requests allowed
+ globalCon.conn_stat = not_connected;
+
+ err = send_response_to_client( hdr_req, error, success );
+
+ }
+
+ break;
+ }
+ default:
+ {
+ break;
+ }
+
+ }
+
+ if ( 0 != err )
+ {
+ //failed
+ return ERROR;
+ }
+ iso_logger( "%s", "out - status_changed_cb\n" );
+ return TRUE;
+ }
+
+/*! \brief new_channel_handler is registered as a callback for any new
+ * channels craetion request, in function status_changed_cb after status is changed
+ * to log in. new_channel_handler creates channel and also registers for the signals
+ * MembersChanged for contact related channels and Recieved and SendError for IM
+ * related channels.
+ *
+ * \param proxy unused
+ * \param object_path object path of the channel
+ * \param channel_type used to get a new channel
+ * \param handle_type used to get a new channel, channel handle type
+ * \param handle used to get a new channel, channel handle
+ * \param suppress_handler unused
+ * \param user_data unused
+ *
+ * \return void
+ */
+static void new_channel_handler( DBusGProxy *proxy, const char *object_path,
+ const gchar *g_channel_type, guint handle_type,
+ guint handle, gboolean suppress_handler,
+ gpointer user_data )
+ {
+
+ TpChan *new_chan = NULL;
+ UNUSED_FORMAL_PARAM(proxy);
+ UNUSED_FORMAL_PARAM(suppress_handler);
+ UNUSED_FORMAL_PARAM(user_data);
+ iso_logger( "%s", "In - new_channel_handler\n" );
+
+ //create new channel
+ new_chan = tp_chan_new( globalCon.dbusConn,
+ globalCon.connmgr_bus, object_path,
+ g_channel_type, handle_type, handle );
+
+ if ( !new_chan )
+ {
+ return ;
+ }
+
+
+ if ( strcmp( g_channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && ( g_strrstr(object_path, "RosterChannel/known" ) ) )
+ {
+ //channel type is contact rosters..
+ //request for the roster
+
+ globalCon.group_iface_known =
+ tp_chan_get_interface( new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+ //register for the members changed signal
+ dbus_g_proxy_connect_signal (globalCon.group_iface_known, "MembersChanged",
+ G_CALLBACK (roster_members_changed_cb),
+ NULL, NULL);
+
+ }
+ else if ( strcmp( g_channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && ( g_strrstr(object_path, "RosterChannel/publish" ) ) )
+ {
+ //channel type is contact rosters..
+ //request for the roster
+
+ globalCon.group_iface_publish =
+ tp_chan_get_interface( new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+ //register for the members changed signal
+ dbus_g_proxy_connect_signal (globalCon.group_iface_publish, "MembersChanged",
+ G_CALLBACK (roster_members_changed_cb),
+ NULL, NULL);
+
+ request_roster( EPublish_Channel );
+ }
+ else if ( strcmp( g_channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && (g_strrstr(object_path, "RosterChannel/subscribe") ) )
+
+ {
+ //roster fetch should be done using subscribe, as it will give
+ //current and remote pending members in differnet arrays, that can be sued on ui side
+ //local pending members can be fetched only using "RosterChannel/publish",that can be fetched if required
+
+ globalCon.group_iface_subscribe =
+ tp_chan_get_interface( new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+
+
+ //register for the members changed signal
+ dbus_g_proxy_connect_signal (globalCon.group_iface_subscribe, "MembersChanged",
+ G_CALLBACK (roster_members_changed_cb),
+ NULL, NULL);
+ request_roster( ESubscribe_Channel );
+
+
+ }
+
+ //recieve message channel handlers
+ else if ( ( strcmp( g_channel_type, TP_IFACE_CHANNEL_TYPE_TEXT ) == 0 ) )
+ {
+ //recieve message
+ if ( globalCon.text_channels == NULL )
+ {
+ globalCon.text_channels = g_hash_table_new_full( g_str_hash,
+ g_str_equal,
+ ( GDestroyNotify ) g_free,
+ ( GDestroyNotify ) g_object_unref );
+ }
+ if ( globalCon.text_channels )
+ {
+ g_hash_table_insert( globalCon.text_channels,
+ g_strdup( object_path ), new_chan );
+ }
+
+ iso_logger( "b4 text_channel_init" );
+ //check for new_chan objects for text channel should be loaclly stored/freed
+ text_channel_init( new_chan );
+ }
+ iso_logger( "%s", "Out - new_channel_handler\n" );
+ }
+
+
+/*! \brief Is called after logout.. Any cleanup operations to
+ * be performed here. Setting isConnected to EFalse, cleaning up
+ * of resources is done
+ */
+void action_logedout()
+ {
+
+ iso_logger( "%s", "In - action_logedout\n" );
+ //not quiting the main loop
+ //release the connection manager
+ if ( globalCon.connmgr )
+ {
+ g_object_unref ( globalCon.connmgr );
+ globalCon.connmgr = NULL;
+ }
+ //release the dbus connection
+ if ( globalCon.dbusConn )
+ {
+ dbus_g_connection_unref ( globalCon.dbusConn );
+ globalCon.dbusConn = NULL;
+ }
+ //release the connection object
+ if ( globalCon.conn )
+ {
+ g_object_unref ( globalCon.conn );
+ globalCon.conn = NULL;
+ }
+ //release the text channels
+ if ( globalCon.text_channels )
+ {
+ g_hash_table_destroy( globalCon.text_channels );
+ globalCon.text_channels = NULL;
+ }
+ //release the subscribe interface
+ if ( globalCon.group_iface_subscribe )
+ {
+ g_object_unref ( globalCon.group_iface_subscribe );
+ globalCon.group_iface_subscribe = NULL;
+ }
+ //release the publish interface
+ if ( globalCon.group_iface_publish )
+ {
+ g_object_unref ( globalCon.group_iface_publish );
+ globalCon.group_iface_publish = NULL;
+ }
+ //release the known interface
+ if ( globalCon.group_iface_known )
+ {
+ g_object_unref ( globalCon.group_iface_known );
+ globalCon.group_iface_known = NULL;
+ }
+
+ iso_logger( "%s", "Out - action_logedout\n" );
+ }
+
+/*! \brief Callback for the logout
+ *
+ * \param proxy : unused
+ * \param error : unused
+ * \param userdata : unused
+ * \return : void
+ */
+void logout_cb( DBusGProxy *proxy, GError *error, gpointer userdata )
+ {
+
+ iso_logger( "%s", "In - logout_cb\n" );
+ UNUSED_FORMAL_PARAM(proxy);
+ UNUSED_FORMAL_PARAM(error);
+ UNUSED_FORMAL_PARAM(userdata);
+ iso_logger( "%s", "Out - logout_cb\n" );
+ }
+
+/*! \brief requests for closing of session. Also closes the search channel.
+ * \remark should not close the search channel
+ *
+ * Request for log - out
+ * \param pc - message which has the request header
+ * \return : MEM_ALLOCATION_ERROR or 0
+ */
+int action_logout( char* pc )
+ {
+
+ TpConn* conn = globalCon.conn;
+ message_hdr_req *msg_hdr = NULL;
+
+ iso_logger( "%s", "In - action_logout\n" );
+
+ if( globalCon.search_chan )
+ {
+ tp_chan_close_async( DBUS_G_PROXY( globalCon.search_chan ), search_chan_closed_cb, NULL );
+ }
+
+ //allocate memory and check for errors
+ msg_hdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ if ( NULL == msg_hdr )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //intialize the memory to 0s
+ memset( msg_hdr, '\0', sizeof( message_hdr_req ) );
+ //read message header from buffer
+ memcpy( msg_hdr, pc, sizeof( message_hdr_req ) );
+
+ //disconnect in async way as glib signal is not workin
+ tp_conn_disconnect_async( DBUS_G_PROXY( conn ), logout_cb, msg_hdr );
+ iso_logger( "%s", "Out - action_logout\n" );
+
+ return 0;
+ }
+
+/*! \brief validates params, gets a dbus, creates a connection manager,
+ * and connection. Registers for the statuschange
+ *
+ * \param ls_hdr login struct
+ * \return Errors if invalid param or getting dbus, conn mgr or conn fails else 0
+ */
+gint action_login( login_struct* ls_hdr )
+ {
+
+ DBusGConnection *connection = NULL;
+ TpConnMgr *connmgr = NULL;
+ TpConn *conn = NULL;
+ GError *error = NULL;
+
+ gchar* def1 = NULL;
+ char* def2 = NULL;
+ char* def3 = NULL;
+
+ gchar* def4 = NULL;
+ guint def5 = 0;
+ gboolean def6 = 0;
+
+ #ifdef __WINSCW__
+ gchar* def8 = NULL;
+ guint def9 = 0;
+ #endif
+
+ //Build hash table
+ GHashTable *connection_parameters = NULL;
+ //initalize the Gvalues
+ GValue *value1 = g_new0(GValue, 1);
+ GValue *value2 = g_new0(GValue, 1);
+ GValue *value3 = g_new0(GValue, 1);
+ GValue *value4 = g_new0(GValue, 1);
+ GValue *value5 = g_new0(GValue, 1);
+ GValue *value6 = g_new0(GValue, 1);
+
+ #ifdef __WINSCW__
+ GValue *value9 = g_new0(GValue, 1);
+ GValue *value10 = g_new0(GValue, 1);
+ #endif
+
+ //log message
+ iso_logger( "%s", "In - action_login\n" );
+
+ //Check if all the mandatory settings are there
+ if ( NULL == ls_hdr->strs[0] || NULL == ls_hdr->strs[1] || NULL == ls_hdr->strs[2]
+ || NULL == ls_hdr->strs[4] || NULL == ls_hdr->strs[5] ||
+ NULL == ls_hdr->strs[7] || NULL == ls_hdr->strs[8] || NULL == ls_hdr->strs[9] )
+ {
+ return INVALID_PARAMETERES;
+ }
+ //Only for winscw
+ #ifdef __WINSCW__
+ if ( NULL == ls_hdr->strs[10] || NULL == ls_hdr->strs[11] )
+ {
+ return INVALID_PARAMETERES;
+ }
+ #endif
+
+ //0 is username
+ def1 = g_strdup( ls_hdr->strs[0] );
+ //1 is passwd
+ def2 = g_strdup( ls_hdr->strs[1] ) ;
+ //2 is server addr
+ def3 = g_strdup( ls_hdr->strs[2] ) ;
+ if ( NULL != ls_hdr->strs[3] )
+ {
+ //3 is resource
+ def4 = g_strdup( ls_hdr->strs[3] ) ;
+ }
+ else
+ {
+ //Fix required from lalitha
+ //Is this manadatory? or Can this be NULL
+ def4 = g_strdup( TestId );
+ }
+ //4 is ssl
+ def5 = atoi( ls_hdr->strs[4] );
+ //5 is server port
+ def6 = atoi( ls_hdr->strs[5] );
+ //6 is IapId is not used
+ //def7 = g_strdup( ls_hdr->strs[6] ) ;
+
+ iso_logger( "username is %s", ls_hdr->strs[0] );
+ iso_logger( "server is %s", ls_hdr->strs[2] );
+ iso_logger( "resource is %s", ls_hdr->strs[3] );
+ iso_logger( "ssl is %s", ls_hdr->strs[4] );
+ iso_logger( "server port is %s", ls_hdr->strs[5] );
+ iso_logger( "connmgr bus is %s", ls_hdr->strs[7] );
+ iso_logger( "connmgr path is %s", ls_hdr->strs[8] );
+ iso_logger( "protocol is %s", ls_hdr->strs[9] );
+
+
+ globalCon.connmgr_bus = strdup( ls_hdr->strs[7]);
+
+ if ( NULL == globalCon.connmgr_bus )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ #ifdef __WINSCW__
+ //7 is ProxyServer
+ def8 = g_strdup( ls_hdr->strs[10] ) ;
+ //proxy port
+ def9 = atoi( ls_hdr->strs[11] );
+ #endif
+
+ //Get DBus - do not change the order of following calls to
+ //dbus, g_hash_table_new
+
+
+ connection = dbus_g_bus_get( DBUS_BUS_SESSION , &error);
+
+ //DBus Connection is NULL
+ //return with error
+ if ( connection == NULL )
+ {
+ if ( error )
+ {
+ g_error_free(error);
+ }
+ iso_logger( "failed in connection == NULL " );
+ return DBUS_CONNECTION_ERROR;
+ }
+ /* printf("connected to DBus with connection %p\n", connection);*/
+ globalCon.dbusConn = connection;
+
+ //Get connection manager
+ connmgr = tp_connmgr_new(connection, ls_hdr->strs[7], ls_hdr->strs[8],TP_IFACE_CONN_MGR_INTERFACE);
+ if ( connmgr == NULL )
+ {
+ iso_logger( "failed in tp_connmgr_new" );
+ //Free already allocated resources
+ //return with error
+ dbus_g_connection_unref ( globalCon.dbusConn );
+ globalCon.dbusConn = NULL;
+ return TP_CONNMGR_ERROR;
+ }
+
+ //Create values for hash table
+ connection_parameters = g_hash_table_new( g_str_hash, g_str_equal );
+ if ( NULL == connection_parameters )
+ {
+ //Free already allocated resources
+ //return with error
+ g_object_unref (connmgr);
+ connmgr = NULL;
+ dbus_g_connection_unref ( globalCon.dbusConn );
+ globalCon.dbusConn = NULL;
+ iso_logger( "failed in g_hash_table_new" );
+ return TP_HASHTABLE_ERROR;
+ }
+
+ //Add AccountStr values to hash table
+ g_value_init( value1, G_TYPE_STRING );
+ g_value_set_string ( value1, def1 );
+ g_hash_table_insert( connection_parameters, ( gpointer ) AccountStr, value1 );
+
+ //Add PasswdStr values to hash table
+ g_value_init( value2, G_TYPE_STRING );
+ g_value_set_string ( value2, def2 );
+ g_hash_table_insert( connection_parameters, ( gpointer ) PasswdStr, value2 );
+ //Add ServerStr values to hash table
+ g_value_init(value3, G_TYPE_STRING);
+ g_value_set_string (value3, def3);
+ g_hash_table_insert( connection_parameters, ( gpointer ) ServerStr, value3 );
+ //Add ResourceStr values to hash table
+ if ( NULL != def4 )
+ {
+ //This is not mandatory settings item
+ //so check for NULL value before useing it..
+ g_value_init( value4, G_TYPE_STRING );
+ g_value_set_string ( value4, def4 );
+ g_hash_table_insert( connection_parameters, ( gpointer ) ResourceStr, value4 );
+ }
+
+ //Add PortStr values to hash table
+ g_value_init(value5, G_TYPE_UINT);
+ g_value_set_uint (value5, def6);
+ g_hash_table_insert(connection_parameters, ( gpointer ) PortStr, value5);
+ //Add OldsslStr values to hash table
+ g_value_init(value6, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value6, def5);
+ g_hash_table_insert(connection_parameters, ( gpointer ) OldsslStr, value6 );
+ //Settings Only for emulator
+ #ifdef __WINSCW__
+ //Add proxy server values to hash table
+ g_value_init(value9, G_TYPE_STRING);
+ g_value_set_string (value9, def8);
+ g_hash_table_insert(connection_parameters, "https-proxy-server", value9);
+
+ //Add proxy port values to hash table
+ g_value_init(value10, G_TYPE_UINT);
+ g_value_set_uint (value10, def9);
+ g_hash_table_insert(connection_parameters, "https-proxy-port", value10);
+ #endif
+
+
+ //Get connection from connection manager - i.e., Login
+ conn = tp_connmgr_new_connection( connmgr,connection_parameters, ls_hdr->strs[9] );
+
+ if ( !conn )
+ {
+ iso_logger( "failed in tp_connmgr_new_connection" );
+ //Free already allocated resources
+ //return with error
+ g_object_unref (connmgr);
+ connmgr = NULL;
+ dbus_g_connection_unref ( globalCon.dbusConn );
+ globalCon.dbusConn = NULL;
+
+ g_hash_table_destroy( connection_parameters );
+ return TP_CONNECTION_ERROR;
+ }
+
+
+ //register for StatusChanged callback - login / logout
+ dbus_g_proxy_connect_signal( DBUS_G_PROXY( conn ), StatusChangedStr,
+ G_CALLBACK( status_changed_cb ),
+ ls_hdr->hdr_req, NULL );
+ //Assign to global variable struct
+ globalCon.conn = conn;
+ globalCon.connmgr = connmgr;
+ globalCon.dbusConn = connection;
+ //Free
+ g_hash_table_destroy( connection_parameters );
+ iso_logger( "%s", "Out - action_login\n" );
+
+ return 0;
+ }
+
+/*! \brief parses the message buffer and validates the parameters. The values are written
+ * to ls_hdr
+ *
+ * \param aMsgBuffer - buf to be parsed
+ * \param ls_hdr - login_struct struct to which values are written
+ * \param msg_len - no. of bytes in the message buffer aMsgBuffer
+ *
+ */
+
+gint parse_for_login( gchar* msg_buffer, login_struct** msg_struct, int msg_len )
+ {
+
+ char* bufPtr = NULL;
+ gint index = 0;
+ gint arg_count = 0;
+ gint str_len = 0;
+ char *str1 = NULL;
+
+ message_hdr_req *msg_hdr = NULL;
+
+ iso_logger( "%s","In - parse_for_login\n" );
+ //Reading of the message_hdr_req is done twice..
+ //should be changed to read once..
+ //Allocate memory and check for the error
+ msg_hdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ if ( NULL == msg_hdr )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //initalize memory to zero
+ memset( msg_hdr, '\0', sizeof( message_hdr_req ) );
+ memcpy( msg_hdr, msg_buffer, sizeof( message_hdr_req ) );
+ //ownership of msg_hdr is transefred to msg_struct
+ ( *msg_struct )->hdr_req = msg_hdr;
+
+ bufPtr = msg_buffer + sizeof( message_hdr_req );
+
+ //validating each arg and copying it..
+
+ while ( arg_count < LOGIN_ARG_COUNT )
+ {
+ //Get one string
+ while( index + str_len < msg_len && '\0' != *( bufPtr + index + str_len ) )
+ {
+ str_len++;
+ //Check if max param len no. of chars already read..
+ //if so return with error
+ if ( MAX_PARAM_LEN == index + str_len )
+ {
+ return INVALID_PARAMETERES;
+ }
+ }
+ //str_len == 0, means one setting attrib missing..
+ //Assign that to NULL..and continue
+ if ( 0 == str_len )
+ {
+ ( *msg_struct )->strs[arg_count] = NULL;
+ //Increment the no of args read by one
+ arg_count++;
+ index++;
+ continue;
+ }
+ //ownership of these strs is transfered to msg_struct
+ //Allocate memory and check for the error
+ str1 = ( char* ) malloc ( str_len + 1 );
+ if ( NULL == str1 )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //Copy the string from buffer
+ //copy '\0' as well
+ memcpy( str1, bufPtr + index, str_len + 1 );
+ //Assign to the array
+ ( *msg_struct )->strs[arg_count] = str1;
+ //Skip the '\0' already read..
+ index += str_len + 1;
+ //reset the str_len to read next char
+ str_len = 0;
+ //Increment the no of args read by one
+ arg_count++;
+
+ }
+ iso_logger( "%s", "Out - parse_for_login\n" );
+ return 0;
+ }
+/*! \brief Calls parse_for_login to parse and validate the arguments
+ * And then calls action_login for to do actual login
+ *
+ * \param aMsgBuf message buffer
+ * \param msg_len - len of the message
+ */
+gint action_parse_login( char* aMsgBuf, int msg_len )
+ {
+
+ gint message_type_err = 0;
+ login_struct* message_struct;
+ gint arg_count = 0;
+
+ iso_logger( "%s", "In - action_parse_login\n" );
+ //Allocate memory and check for errors
+ message_struct = ( login_struct* ) malloc( sizeof ( login_struct ) );
+ if ( NULL == message_struct )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //intialize memory to 0s
+ memset ( message_struct, '\0', sizeof ( login_struct ) );
+
+ //Parse the message into login parameters
+ message_type_err = parse_for_login( aMsgBuf, &message_struct, msg_len );
+ //If no error in parsing do a login
+ if ( !message_type_err )
+ {
+ //parse passed
+ message_type_err = action_login( message_struct );
+
+ }
+ //check if the pointer is not pointing to NULL
+ //And free the memory
+ for( arg_count = 0; arg_count < LOGIN_ARG_COUNT; arg_count++ )
+ {
+ if ( NULL != message_struct->strs[arg_count] )
+ {
+ free ( message_struct->strs[arg_count] );
+ }
+ }
+ free ( message_struct );
+ iso_logger( "%s", "Out - action_parse_login\n" );
+ return message_type_err;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isofetchcontactlist.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,644 @@
+/*
+* ============================================================================
+* Name : isofetchcontactlist.h
+* Part of : isolation server.
+* Version : %version: 17 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include "isofetchcontactlist.h"
+#include "isoutils.h"
+#include "msg_enums.h"
+#include "msgliterals.h"
+
+const guint KMaxContactFetchCount = 500;
+
+static guint cur_mem_len;
+static guint local_mem_len;
+static guint remote_mem_len;
+
+static gint cur_last_index = 0;
+static gint local_last_index = 0;
+static gint remote_last_index = 0;
+
+
+/*! \brief This function is called as a callback to get the contact names from
+ * contact handles. Contact names are sent to client in multiple packets of
+ * size MAX_MSG_SIZE
+ *
+ * \param proxy unused
+ * \param handles_names 2D array of contact names
+ * \param error error if any
+ * \param userdata msg_type
+ */
+static void inspect_handles_cb( DBusGProxy *proxy,char **handles_names,
+ GError *error, gpointer userdata )
+ {
+ guint i;
+ gint err = 0;
+ gint* msg_type = ( gint* ) userdata;
+
+ gchar** members = NULL;
+ guint* mem_count = 0;
+ gint* last_index = NULL;
+
+
+ iso_logger( "%s", "in -- inspect_handles_cb" );
+
+ if ( !handles_names || error )
+ {
+ //Handles error
+ iso_logger( "%s", "handle names error" );
+ free ( msg_type );
+ g_error_free(error);
+ return;
+ }
+ UNUSED_FORMAL_PARAM(proxy);
+ //Switch to the type of the message
+ //and get corresponding pointers to members and pointer to last index
+ switch ( *msg_type )
+ {
+ case ECurrent_Member_Contacts:
+ members = globalCon.current_members_names;
+ mem_count = &cur_mem_len;
+ last_index = &cur_last_index;
+ iso_logger( "%s count %d", "current members", mem_count );
+ break;
+ case ELocal_Pending_Contacts:
+ members = globalCon.local_pending_names;
+ mem_count = &local_mem_len;
+ last_index = &local_last_index;
+ iso_logger( "%s count %d", "local members", mem_count );
+ break;
+ case ERemote_Pending_Contacts:
+ members = globalCon.remote_pending_names;
+ mem_count = &remote_mem_len;
+ last_index = &remote_last_index;
+ iso_logger( "%s count %d", "remote members", mem_count );
+ break;
+
+ default :
+ //Error in msg_type
+ //Wrong message type
+ //quit from here
+ free ( msg_type );
+ return;
+ }
+
+
+ //Add the contacts to the global member
+ for( i=0; handles_names[i]; i++ )
+ {
+ iso_logger( "members %s ",handles_names[i] );
+ members[*last_index] = handles_names[i];
+ (*last_index)++;
+ }
+
+ iso_logger( "last index is %d", *last_index );
+ //If all the contacts are fetched send them to client
+ if ( *mem_count == *last_index )
+ {
+ //send all contacts to client
+ err = send_contacts_to_client( members, *mem_count, *msg_type );
+ *last_index = 0;
+ if ( err )
+ {
+ //How to handle the error?
+ for ( i = 0; i < *mem_count; i++ )
+ {
+ free ( members[i] );
+ }
+ iso_logger( "%s", "There was error in send_contacts_to_client" );
+ free ( msg_type );
+ *mem_count = 0;
+ return;
+ }
+ *mem_count = 0;
+
+ }
+ free ( msg_type );
+ iso_logger( "%s", "out -- inspect_handles_cb" );
+ }
+
+/*! \brief This function is called if there are 0 contacts or there was an error
+ *
+ * \param contact_type : Type of the contacts
+ * \param err : err if any, 0 otherwise
+ */
+static gint send_fetch_contacts_error( gint contact_type , gint err )
+ {
+
+ int result = 0;
+ int pri = MSG_PRI_NORMAL;
+ int timeout1 = TIME_OUT;
+ message_hdr_resp* msg_struct = NULL;
+ //control is here coz.. there are no contacts in list
+
+ msg_struct = ( message_hdr_resp* ) malloc ( sizeof( message_hdr_resp ) );
+ if ( NULL == msg_struct )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //initalize memory to zero
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ //create the header response
+ msg_struct->hdr_req.message_type = contact_type;
+ msg_struct->hdr_req.protocol_id = 0;
+ msg_struct->hdr_req.session_id = 0;
+ msg_struct->hdr_req.request_id = 0;
+ //Set error types and continue flag
+ if ( err < 0 )
+ {
+ //There was some error, pass on the mapped error
+ //to client
+ msg_struct->error_type = err;
+ msg_struct->response = 0;
+ }
+ else
+ {
+ msg_struct->error_type = 0;
+ msg_struct->response = 1;
+ }
+ msg_struct->continue_flag = 0;
+ //send the message to client that there are no contacts in the list
+ result = MsgQSend( RESPONSE_QUEUE, ( char* )msg_struct, sizeof( message_hdr_resp ),
+ pri, timeout1, &err );
+
+ free ( msg_struct );
+
+ if ( result < 0 )
+ {
+ // failed to deliever
+ return MSG_Q_SEND_FAILED;
+ }
+ return 0;
+ }
+
+/*! \brief This function is a callback for request for the contacts
+ * in local pending contatct list from server. This is
+ * only called for publish channel members. fetch_contacts is called
+ * to get the contact names from the handles. If there are no conatcts in
+ * the list it calls send_fetch_contacts_error else requests for the contact names
+ * from the contact handles
+ *
+ * \param proxy unused
+ * \param current_members array of handles of current contatcs
+ * \param local_pending_members unused
+ * \param remote_pending_members array of handles of remote pending contatcs
+ * \param error error if any
+ * \param userdata unused
+ */
+static void get_roster_local_member_cb( DBusGProxy *proxy,GArray* current_members,
+ GArray* local_pending_members, GArray* remote_pending_members,
+ GError *error, gpointer userdata )
+ {
+
+ gint err = 0;
+ gint* msg_type = ( gint* ) malloc ( sizeof ( gint ) );
+
+ iso_logger( "%s", "in -- get_roster_member_cb_local" );
+ UNUSED_FORMAL_PARAM(proxy);
+ UNUSED_FORMAL_PARAM(remote_pending_members);
+ UNUSED_FORMAL_PARAM(userdata);
+ UNUSED_FORMAL_PARAM(current_members);
+ if ( NULL != error )
+ {
+ //err in fetching contacts, send failed
+ //map the error code to isoserver
+ err = error->code;
+ //Send that there are no contacts in the local pending
+ send_fetch_contacts_error( EFetch_Contacts_Error, err );
+ return;
+ }
+ //store the no. of lccal pending contacts
+ local_mem_len = local_pending_members->len;
+
+ if ( !local_last_index && local_mem_len )
+ {
+ //Is this the first time to be here..
+ //allocate memory
+ globalCon.local_pending_names = g_new0 ( char *, local_mem_len + 1);
+ if ( NULL == globalCon.local_pending_names )
+ {
+ return ;
+ //err?
+ }
+ }
+ //ownership of this pointer is trnasfered to fetch_contacts
+ *msg_type = ELocal_Pending_Contacts;
+ //Fetch the contacts given the handles
+ err = fetch_contacts( local_pending_members, msg_type );
+ if ( err < 0 )
+ {
+ return;
+ }
+
+ iso_logger( "%s", "out -- get_roster_member_cb_local" );
+ }
+
+/*! \brief Requests the server to get contact names from the handles
+ * The contact names are returned in inspect_handles_cb. From there
+ * contacts are sent to client
+ *
+ * \param contact_mem : handles to contact members
+ * \param msg_type : type of the message, which wil be passed to cb
+ * \return Errors if any, else 0
+ */
+static gint fetch_contacts( GArray* contact_mem, gint* msg_type )
+ {
+
+ guint fetch_count=0;
+ guint fetch_loop_count=0;
+ GArray* fetch_members = NULL;
+
+ DBusGProxyCall* call_id = NULL;
+ TpConn* conn = globalCon.conn;
+
+ gint i = 0;
+
+ //allocate memory for the contacts to be fetched
+ fetch_members = g_array_new (FALSE, FALSE, sizeof (guint32));
+ if ( NULL == fetch_members )
+ {
+ free ( msg_type );
+ return MEM_ALLOCATION_ERROR;
+ //err?
+ }
+
+ //check if there are contacts to be retrived
+ if ( contact_mem && contact_mem->len > 0 )
+ {
+
+ fetch_count = 0;
+
+ //Divide contacts into a 'n' no. of groups .. n is calculated as below..
+ fetch_loop_count = ( contact_mem->len ) / KMaxContactFetchCount + (
+ ( contact_mem->len % KMaxContactFetchCount ) ? 1 : 0 );
+
+ //Get the contacts in terms of fetch_count
+ for ( i=0; i<fetch_loop_count; i++ )
+ {
+ g_array_remove_range( fetch_members,0,fetch_count);
+
+ fetch_count = ( contact_mem->len <= KMaxContactFetchCount )
+ ? contact_mem->len : KMaxContactFetchCount;
+ //Fetch the contacts
+ g_array_append_vals (fetch_members,contact_mem->data,fetch_count);
+ g_array_remove_range(contact_mem,0,fetch_count);
+ //For the given handles contacts will be fetched in inspect_handles_cb
+ call_id = tp_conn_inspect_handles_async( DBUS_G_PROXY(conn),
+ TP_CONN_HANDLE_TYPE_CONTACT ,fetch_members,
+ inspect_handles_cb, msg_type );
+ //If call_id is null return from here..
+ if ( NULL == call_id )
+ {
+ free ( msg_type );
+ g_array_free( fetch_members, TRUE );
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ }
+ }
+ else if ( contact_mem && contact_mem->len == 0 )
+ {
+ gint err = 0;
+ //There are no contacts for this type(cur or local or remote) of contacts
+ //Send that to client
+ err = send_fetch_contacts_error( *msg_type, 0 );
+ free ( msg_type );
+ if ( err < 0 )
+ {
+ //Free the msg_type.. Ownership was transfered to this function
+
+ g_array_free( fetch_members, TRUE );
+ return err;
+ }
+
+ }
+ //msg_type is either freed in else part or is freed in inspect_handles_cb
+ //no need to free here
+ g_array_free( fetch_members, TRUE );
+ //Should the fetch_contacts be deleted?
+ return 0;
+ }
+
+/*! \brief This function is a callback for request for the contacts
+ * in msg_type(subscribe or publish) contatct list from server. This is
+ * only called for subscribe channel members. fetch_contacts is called
+ * to get the contact names from the handles. If there are no conatcts in
+ * the list it calls send_fetch_contacts_error else requests for the contacts
+ * from the handles
+ *
+ * \param proxy unused
+ * \param current_members array of handles of current contatcs
+ * \param local_pending_members unused
+ * \param remote_pending_members array of handles of remote pending contatcs
+ * \param error error if any
+ * \param userdata unused
+ */
+static void get_roster_member_cb( DBusGProxy *proxy,GArray* current_members,
+ GArray* local_pending_members, GArray* remote_pending_members,
+ GError *error, gpointer userdata )
+ {
+
+ int err = 0;
+
+ guint j = 0;
+
+ iso_logger( "%s", "in -- get_roster_member_cb" );
+ UNUSED_FORMAL_PARAM(proxy);
+ UNUSED_FORMAL_PARAM(userdata);
+ UNUSED_FORMAL_PARAM(local_pending_members);
+ if ( NULL != error )
+ {
+ //err in fetching contacts, send failed
+ //map the error code to isoserver
+ err = error->code;
+ send_fetch_contacts_error( EFetch_Contacts_Error, err );
+ return;
+ }
+ //store the no. of current members
+ cur_mem_len = current_members->len;
+ //store the no. of remote members
+ remote_mem_len = remote_pending_members->len;
+
+
+ if ( !cur_last_index && cur_mem_len )
+ {
+ //Is this the first time to be here..
+ //allocate memory
+ globalCon.current_members_names = g_new0 ( char *, cur_mem_len + 1);
+ if ( NULL == globalCon.current_members_names )
+ {
+ return ;
+ //err?
+ }
+ }
+
+ if ( !remote_last_index && remote_mem_len )
+ {
+ //Is this the first time to be here..
+ //allocate memory
+ globalCon.remote_pending_names = g_new0 ( char *, remote_mem_len + 1);
+ if ( NULL == globalCon.remote_pending_names )
+ {
+ return ;
+ //err?
+ }
+ }
+
+
+ //loop thru : 2 for current and remote
+ for ( j = 0; j < 2; j++ )
+ {
+ //This msg_type is sent to inspect_handles_cb
+ //Where it wil be deleeted
+ gint* msg_type = ( gint* ) malloc ( sizeof ( gint ) );
+ GArray* contact_mem = NULL;
+ switch ( j )
+ {
+
+ case 0 :
+ //ask for the current members first
+ *msg_type = ECurrent_Member_Contacts;
+ contact_mem = current_members;
+ break;
+
+ case 1 :
+ //ask for remote pending contacts
+ *msg_type = ERemote_Pending_Contacts;
+ contact_mem = remote_pending_members;
+ break;
+
+ default:
+ break;
+ }
+ //Fetch the contacts given the handles
+ //ownership of msg_type is transfered to fetch_contacts
+ err = fetch_contacts( contact_mem, msg_type );
+ if ( err < 0 )
+ {
+ //There was some error
+ //return from here
+ return;
+ }
+
+ }
+
+ iso_logger( "%s","out -- get_roster_member_cb" );
+ }
+
+
+/*! \brief this function requests for the contacts in its contatct list from server
+ *
+ * \param type of the contacts channel( publish, subscribe )
+ */
+void request_roster( enum channel_type type )
+ {
+
+ DBusGProxyCall* call_id = NULL;
+
+
+ iso_logger( "%s", "in -- request_roster" );
+
+ //With the interface get the contacts
+ //Request for all of the contacts in subscribe channel( remote and current
+ //members )
+ if ( ESubscribe_Channel == type )
+ {
+ call_id = tp_chan_iface_group_get_all_members_async( globalCon.group_iface_subscribe,
+ get_roster_member_cb, NULL );
+ //If call_id is NULL return from here..
+ if ( NULL == call_id )
+ {
+ return ;
+ }
+ }
+ else if ( EPublish_Channel == type )
+ {
+ //Request for all of the contacts in publish channel
+ call_id = tp_chan_iface_group_get_all_members_async( globalCon.group_iface_publish,
+ get_roster_local_member_cb, NULL );
+ //If call_id is NULL return from here..
+ if ( NULL == call_id )
+ {
+ return ;
+ }
+ }
+
+ iso_logger( "%s", "out -- request_roster" );
+ }
+
+/*! \brief Sends contacts to the client. Contact names are sent to client in multiple
+ * packets of size less than or equal to MAX_MSG_SIZE. Contact will be sent as a whole.
+ * A single contact will not be sent in two consecutive packets
+ *
+ * \param members : Contacts to be sent to client
+ * \param mem_count : no. of contacts
+ * \param contact_type : type of the contact
+ * \return error code..
+ */
+gint send_contacts_to_client( gchar** members, gint mem_count,
+ gint contact_type )
+ {
+ int result = 0;
+ int pri = MSG_PRI_NORMAL;
+ int timeout1 = TIME_OUT;
+ int err = 0;
+
+ char* memBuf = NULL;
+ int i = 0;
+ int one_msg_size = sizeof ( message_hdr_resp );
+ int mem_len = 0;
+ message_hdr_resp* msg_struct = NULL;
+
+ iso_logger( "%s", "in -- send_contacts_to_client" );
+
+ //allocate memory and check for the returned value
+ msg_struct = ( message_hdr_resp* ) malloc ( sizeof( message_hdr_resp ) );
+ if ( NULL == msg_struct )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ memBuf = ( gchar* ) malloc( MAX_MSG_SIZE );
+ if ( NULL == memBuf )
+ {
+ // ?
+ free ( msg_struct );
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ //create the response header with type contact fetch
+ msg_struct->hdr_req.message_type = contact_type;
+ msg_struct->hdr_req.protocol_id = 0;
+ msg_struct->hdr_req.session_id = 0;
+ msg_struct->hdr_req.request_id = 0;
+
+ memset( memBuf, '\0', MAX_MSG_SIZE );
+ //sending the req to server
+
+ //assuming that one contact size will not be
+ //greater than max_msg_size
+ for ( i = 0; i <= mem_count - 1; i++ )
+ {
+ mem_len = strlen ( members[i] ) + 1;
+ //check if this contact fits in the current message
+ //to be sent to client
+ //one_msg_size is used to navigate thru' the buffer
+ if ( one_msg_size + mem_len < MAX_MSG_SIZE )
+ {
+ strcpy( memBuf + one_msg_size, members[i] );
+ one_msg_size += mem_len;
+ //if i == mem_count - 1 no need to continue
+ //Control should fall off(i.e., contacts fit in
+ //this message )
+ if ( i < mem_count - 1 )
+ {
+ continue;
+ }
+ //If falling off mem_len should be reset because
+ //it has been already added to one_msg_size
+ mem_len = 0;
+ }
+ msg_struct->error_type = 0;
+ msg_struct->response = 1;
+ //if i == mem_count - 1 and all contacts fits in this message
+ //to be sent to server
+ if ( i == mem_count - 1 && one_msg_size + mem_len < MAX_MSG_SIZE )
+ {
+ msg_struct->continue_flag = 0;
+ }
+ else
+ {
+ msg_struct->continue_flag = 1;
+ }
+ if ( i == mem_count - 1 && one_msg_size + mem_len > MAX_MSG_SIZE )
+ {
+ //One more contact is there (in which case i == mem_count - 1))
+ //And that can't be sent because of limitation of
+ //message size..
+ //so iterate one more time
+ i--;
+ }
+ //Append '\0' to mark the end..
+ one_msg_size++;
+ *( memBuf + one_msg_size ) = '\0';
+ memcpy( memBuf, msg_struct, sizeof( message_hdr_resp ) );
+ //send to the client
+ result = MsgQSend( RESPONSE_QUEUE, memBuf, one_msg_size, pri,
+ timeout1, &err );
+
+
+ if ( result < 0 )
+ {
+ free ( memBuf );
+ iso_logger( "%s", "in -- send_contacts_to_client MSG_Q_SEND_FAILED" );
+ // failed to deliever
+ //free the allocated memory
+ free ( msg_struct );
+
+ return MSG_Q_SEND_FAILED;
+ }
+
+ memset( memBuf , '\0', MAX_MSG_SIZE );
+ //reset the one_msg_size for new message to be sent
+ one_msg_size = sizeof ( message_hdr_resp );
+
+ }
+ //free the buffer
+ free ( memBuf );
+
+ free ( msg_struct );
+ //Should the members be freed here?
+ for ( i = 0; i < mem_count; i++ )
+ {
+ iso_logger( "freeing contact %s", members[i] );
+ free ( members[i] );
+ }
+ iso_logger( "%s", "out -- send_contacts_to_client" );
+
+ return 0;
+ }
+
+/*! \brief Documented in the header file
+*/
+void fetch_cached_contacts()
+ {
+
+ request_roster( EPublish_Channel );
+ request_roster( ESubscribe_Channel );
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isogetsearchkeys.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,318 @@
+/*
+* ============================================================================
+* Name : isogetsearchkeys.c
+* Part of : isolation server.
+* Version : %version: 7 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*! \file
+* Impliments the functions in isosearch.h
+*/
+
+/*! \def For malloc
+*/
+#include <stdlib.h>
+
+/*! \def For string operations
+*/
+#include <string.h>
+
+
+/*! \def For search related declarations
+*/
+#include "isosearch.h"
+
+/*! \def For globalCon
+*/
+#include "isoservermain.h"
+
+/*! \def For tp_chan_type_search_async
+*/
+#include "tp-chan-type-search-gen.h"
+
+/*! \def For MSG_PRI_NORMAL
+*/
+#include "msgqlib.h"
+
+/*! \def For message_hdr_req
+*/
+#include "isoutils.h"
+
+/*! \def For RESPONSE_QUEUE
+*/
+#include "msgliterals.h"
+
+#include "isogetsearchkeys.h"
+
+/*! \struct key_value_struct isoserach.h
+* \brief This struct is used for to form the msg buffer that will be sent to client
+* \var msg As the key/value pairs are read those will be appended to msg
+* \var len is the no. of bytes appended to msg
+*/
+struct key_value_struct
+ {
+ gchar* msg;
+ gint len;
+ };
+
+/*! \typedef struct key_value_struct to key_value_struct
+*/
+typedef struct key_value_struct key_value_struct;
+
+/*! \struct get_search_keys_cb_struct isosearch.h
+* \brief This struct bundles multiple(two ?) pointers to be passed
+* to getsearch keys callback
+* \var search_chan which should be closed when search keys are recieved
+* \var hdr_req message header request
+*/
+struct get_search_keys_cb_struct
+ {
+ TpChan* search_chan;
+ message_hdr_req* hdr_req;
+ };
+
+/*! \typedef struct get_search_keys_cb_struct to get_search_keys_cb_struct
+*/
+typedef struct get_search_keys_cb_struct get_search_keys_cb_struct;
+
+
+static void getsearchkeys_cb( DBusGProxy *proxy, gchar *instr,
+ gchar **keys, GError *error, gpointer userdata );
+
+/*! \brief get_search_keys_reply is called as a callback to get_search_keys
+* This function creates a new channel and requests telepathy for the
+* search keys
+*
+* \param userdata message header request
+*
+* \remark calling tp_conn_new_channel results into esock_client 8 panic
+* Instead of calling function tp_conn_new_channel which makes a
+* a call to tp_conn_request_channel, tp_conn_request_channel_async is
+* called directly.
+*/
+
+static void get_search_keys_reply( DBusGProxy *proxy, char *chan_object_path,
+ GError *error, gpointer user_data )
+ {
+
+
+ TpChan *search_chan = NULL;
+ DBusGProxy *search_iface = NULL;
+ get_search_keys_cb_struct* chan_struct = NULL;
+ message_hdr_resp* hdr_req = ( message_hdr_resp* )user_data;
+
+ UNUSED_FORMAL_PARAM( proxy );
+ iso_logger( "in get_search_keys" );
+
+ if ( error )
+ {
+ send_response_to_client( (message_hdr_req*)hdr_req, error->code, 0 );
+ free ( hdr_req );
+ return;
+ }
+
+ //Create new channel for the search
+ search_chan = tp_chan_new( globalCon.dbusConn, globalCon.connmgr_bus, chan_object_path,
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH, TP_CONN_HANDLE_TYPE_NONE, 0 );
+
+
+ if ( NULL == search_chan )
+ {
+ free ( hdr_req );
+ return ;
+ }
+ //Get chan interface
+ search_iface = tp_chan_get_interface( search_chan,
+ TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK );
+
+ if ( NULL == search_iface )
+ {
+ tp_chan_close_async( DBUS_G_PROXY( search_chan ),
+ search_chan_closed_cb, NULL );
+ free ( hdr_req );
+ return ;
+ }
+
+ chan_struct = ( get_search_keys_cb_struct* ) malloc (
+ sizeof ( get_search_keys_cb_struct ) );
+
+ chan_struct->search_chan = search_chan;
+ chan_struct->hdr_req = ( message_hdr_req* ) malloc (
+ sizeof( message_hdr_req ) );
+ if ( NULL == chan_struct->hdr_req )
+ {
+ tp_chan_close_async( DBUS_G_PROXY( search_chan ),
+ search_chan_closed_cb, NULL );
+ free ( hdr_req );
+ return ;
+ }
+ //memset( chan_struct->hdr_req, )
+ memcpy( chan_struct->hdr_req, hdr_req, sizeof( message_hdr_req ) );
+
+
+ //Ownership of search_chan and chan_struct->hdr_req,
+ //chan_struct is passed to getsearchkeys_cb
+ free ( hdr_req );
+
+ tp_chan_type_search_get_search_keys_async( search_iface,
+ getsearchkeys_cb, chan_struct );
+
+ iso_logger( "out get_search_keys" );
+
+
+ }
+
+/*! \brief Function to get the search keys(fields on which to
+* search ) supported by server
+*
+* \param hdr_req message header request
+*
+* \return gint MEM_ALLOCATION_ERROR
+*/
+gint get_search_keys( message_hdr_resp* hdr_req )
+ {
+
+ message_hdr_resp* hdr_resp = ( message_hdr_resp* )
+ malloc ( sizeof ( message_hdr_resp ) );
+
+ if ( NULL == hdr_resp )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ memcpy( hdr_resp, hdr_req, sizeof ( message_hdr_resp ) );
+ //ownership hdr_resp transfered
+ tp_conn_request_channel_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH,
+ TP_CONN_HANDLE_TYPE_NONE, 0, TRUE,
+ get_search_keys_reply, (gpointer)hdr_resp ) ;
+
+ return 0;
+ }
+
+
+/*! \brief This is a callback to get_search_keys. The search keys
+* are sent to the requested client
+*
+* \param proxy unused
+* \param instr instruction on search keys
+* \param keys 2D string array of search keys supported by server
+* \param error Error from server, if any
+* \param userdata get_search_keys_cb_struct
+*/
+
+static void getsearchkeys_cb( DBusGProxy *proxy, gchar *instr,
+ gchar **keys, GError *error, gpointer userdata )
+ {
+
+ get_search_keys_cb_struct * search_struct = (
+ get_search_keys_cb_struct* )userdata;
+
+ message_hdr_resp hdr_resp;
+ gchar* msg = NULL;
+ gint i = 0;
+ gint len = 0;
+
+ gint pri = MSG_PRI_NORMAL;
+ gint result = 0;
+ gint timeout = NO_WAIT;
+ gint err = 0;
+
+
+ UNUSED_FORMAL_PARAM( proxy );
+ UNUSED_FORMAL_PARAM( instr );
+ iso_logger( "in getsearchkeys_cb" );
+
+
+ tp_chan_close_async( DBUS_G_PROXY( search_struct->search_chan ),
+ search_chan_closed_cb, NULL );
+
+ if ( error )
+ {
+ send_response_to_client( search_struct->hdr_req, error->code, 0 );
+
+ free ( search_struct->hdr_req );
+ free ( search_struct );
+
+ return;
+ }
+
+ //Create the response header to be sent to client
+ //Copy the message header request
+ hdr_resp.hdr_req.message_type = ESearch_Get_Keys;
+ hdr_resp.hdr_req.protocol_id = search_struct->hdr_req->protocol_id;
+ hdr_resp.hdr_req.request_id = search_struct->hdr_req->request_id;
+ hdr_resp.hdr_req.session_id = search_struct->hdr_req->session_id;
+ //set continue flag
+ hdr_resp.continue_flag = 0;
+ hdr_resp.error_type = 0;
+ hdr_resp.response = 1;
+
+ free ( search_struct->hdr_req );
+ free ( search_struct );
+
+ //Allocate memory for the message and set memory to '\0'
+ msg = ( gchar* ) malloc ( MAX_PARAM_LEN );
+ if ( NULL == msg )
+ {
+ iso_logger( "malloc error @ pairs.msg" );
+ return ;
+ }
+ memset( msg, '\0', MAX_PARAM_LEN );
+ len = 0;
+ //Copy the response
+ memcpy( msg, &hdr_resp, sizeof ( message_hdr_resp ) );
+ len += sizeof( message_hdr_resp );
+
+
+ iso_logger( "Get search keys : Keys are" );
+
+ while ( keys[i] )
+ {
+ strcpy( msg + len, keys[i] );
+ iso_logger( "Key %d : %s", i, keys[i] );
+ len += strlen( keys[i] ) + 1;
+ i++;
+ }
+
+ iso_logger( "Get search keys : Keys End" );
+
+ //End the message with a '\0'
+ len++;
+ msg[len] = '\0';
+ //Send the message to client
+ result = MsgQSend( RESPONSE_QUEUE, msg, len,
+ pri, timeout, &err );
+
+
+
+ if ( result )
+ {
+
+ }
+
+ iso_logger( "out getsearchkeys_cb" );
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isoim.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,874 @@
+/*
+* ============================================================================
+* Name : isoim.c
+* Part of : isolation server instant messaing componenet.
+* Version : %version: bh1cfmsg#28 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#include "tp-conn-gen.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "isoim.h"
+#include "isoutils.h"
+
+#include "msgliterals.h"
+#include "msg_enums.h"
+
+/*! \file
+* Impliments the functions in isoim.h
+*/
+
+/*! /brief requests the handles for the contacts to which message should be sent.
+ * request_handles_cb is registered as a callback. necessary data to be sent is
+ * passed as userdata
+ *
+ * /param msghdr request header that will be passed back to client
+ * /param contact_id all contacts
+ * /param message
+ * /param no_cntcts no. of contacts the msg shld be sent to
+ * /return : error code on failure, 0 on success
+ */
+void send_message( send_msg_struct* msg_hdr,
+ const gchar **contact_id )
+ {
+
+ //request for the handles to contact
+ tp_conn_request_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT,
+ contact_id,request_handles_cb, ( gpointer ) msg_hdr );
+ }
+
+
+/*! /brief handles for contacts are recieved and text channel created (if already
+ * there same is used) message is sent to those contacts.
+ *
+ *
+ * /param proxy unused
+ * /param handles contact handles
+ * /param error error if any in getting the handles for contact
+ * /param userdata Has request header and message to be sent to reciever
+ * The request header is used for mapping of response to correct request
+ *
+ */
+void request_handles_cb(DBusGProxy *proxy, GArray *handles, GError* error, gpointer message)
+ {
+ TpChan* text_chan = NULL; //for send msg
+ guint contact_handle;
+ DBusGProxy *text_iface = NULL;
+ send_msg_struct* msg_hdr = ( send_msg_struct* ) message;
+
+ UNUSED_FORMAL_PARAM(proxy);
+ //There was error in requesting handles to the contacts
+ if ( error )
+ {
+ iso_logger( "%s", error->message);
+
+ iso_logger( "err code: %d ", error->code );
+ //Send error to client
+ //What happens if
+ send_response_to_client( msg_hdr->hdr_req, error->code, 0 );
+ g_error_free(error);
+ return;
+ }
+
+ contact_handle = g_array_index( handles, guint, 0 );
+ //get the text channel for the contact handle
+ text_chan = g_hash_table_find( globalCon.text_channels,
+ (GHRFunc) text_channels_find_func,
+ &contact_handle);
+
+ iso_logger( "text_chan : %d ", text_chan );
+
+ //create a text channel
+ if ( text_chan == NULL )
+ {
+
+ text_chan = tp_conn_new_channel( globalCon.dbusConn,globalCon.conn,globalCon.connmgr_bus,TP_IFACE_CHANNEL_TYPE_TEXT,
+ TP_CONN_HANDLE_TYPE_CONTACT,contact_handle, TRUE );
+
+ if(!text_chan)
+ {
+ send_response_to_client( msg_hdr->hdr_req, NOT_CONNECTED , 0 );
+ g_error_free(error);
+ return;
+ }
+
+ iso_logger( "%s", dbus_g_proxy_get_path(DBUS_G_PROXY(text_chan)));
+ g_hash_table_insert( globalCon.text_channels,g_strdup(dbus_g_proxy_get_path(DBUS_G_PROXY(text_chan))),text_chan);
+ }
+
+ //get interface..
+ text_iface = tp_chan_get_interface( text_chan,TELEPATHY_CHAN_IFACE_TEXT_QUARK );
+
+
+
+ if ( NULL == text_iface )
+ {
+ free( msg_hdr->msg );
+ free( msg_hdr->hdr_req );
+ free( msg_hdr );
+
+ //Free proxy ?
+ return ;
+ }
+
+ //send async
+ tp_chan_type_text_send_async( text_iface, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ ( const char * )msg_hdr->msg,sendreply_cb, msg_hdr->hdr_req ); // see if any user date should be passed
+
+
+ iso_logger( "Message being sent is %s", msg_hdr->msg );
+
+ free( msg_hdr->msg );
+ free( msg_hdr );
+
+ iso_logger( "%s", "tp_chan_type_text_send_async after\n");
+ }
+
+/*! /brief parse the params for send and validates them
+ *
+ * /param aMsgBuffer message buffer to be parsed
+ * /param aContactId pointer to an array of strings, After this function this
+ * arg wil have the contacts to which message should be sent to
+ * /param aSendMsg message to be sent
+ * /param len : msg_len no. of bytes in aMsgBuffer
+ * /param contact_count : no. of contacts
+ * /return returns error code on failure, or 0
+ */
+gint parse_for_send( gchar* msg_buf, gchar*** contact_ids,
+ gchar** send_msg, gint msg_len, gint* contact_count )
+ {
+ gchar* users = NULL;
+
+ gint len = 0;
+ gint err = 0;
+
+ iso_logger( "%s", "In - parse_for_send\n" );
+ //skip the msg_hdr part
+ len += sizeof( message_hdr_req );
+ //example send message - message header omitted..
+ //test.ximp@gmail.com\0ximp.telepathy@gmail.com\0\0hi, how r u?\0
+ // ^ ^ ^ ^
+ //contact1------------|contact2-----------------|-|message------|
+
+ //gets the contacts, returns no. of contacts on success
+ //error code on error
+ err = parse_into_array_of_strings( msg_buf, contact_ids, &len, msg_len,
+ contact_count );
+ if ( err < 0 )
+ {
+ //An error has occured, so propagate to next level
+ return err;
+ }
+
+
+ /*
+ Will never come here.. coz it has been already handled in
+ parse_into_array_of_strings
+ if ( *contact_count > MAX_MSG_RECEIPIENTS )
+ {
+ return INVALID_PARAMETERES;
+ }*/
+ //reset the userlen
+
+ //parse for the message..
+ err = parse_a_string( msg_buf, &users, &len, msg_len );
+
+ if ( err < 0 )
+ {
+ return err;
+ }
+ //set the pointer to send message
+ *send_msg = users;
+
+ iso_logger( "%s", "Out - parse_for_send\n" );
+ //return the no. of contacts to be sent to
+ return 0;
+ }
+/*! /brief calls parse_for_send to parse the parameters, and calls
+ * send_message for sending the message
+ *
+ * /param buf : message buffer to be parsed
+ * /param len : msg_len no. of bytes in msg_buf
+ *
+ * /return gint : parse error code if any
+ */
+int action_parse_send( gchar* buf, gint msg_len )
+ {
+ gchar** contactid = NULL;
+ gchar* sendmsg = NULL;
+ message_hdr_req *msg_hdr = NULL;
+ gint meesage_type_err = 0;
+ //It is very imp to initailize the contact_count to 0 here
+ gint contact_count = 0;
+ send_msg_struct* msg_struct = NULL;
+ //parse contacts, message..
+ iso_logger( "%s", "In - action_parse_send\n" );
+ meesage_type_err = parse_for_send( buf,
+ &contactid,&sendmsg, msg_len, &contact_count );
+
+ //if <= 0 there is some error in the message formation
+ if ( contact_count > 0 && meesage_type_err == 0 )
+ {
+
+ //send message
+ msg_hdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ if ( NULL == msg_hdr )
+ {
+ //free resources allocated for this operation
+ free_msg_args( contactid, contact_count, sendmsg );
+ return MEM_ALLOCATION_ERROR;
+ }
+ memset( msg_hdr, '\0', sizeof( message_hdr_req ) );
+ //read message header from buffer
+ memcpy( msg_hdr, buf, sizeof( message_hdr_req ) );
+
+ //fill the contacts and message into a struct
+ msg_struct = ( send_msg_struct* ) malloc ( sizeof ( send_msg_struct ) );
+ if ( NULL == msg_struct )
+ {
+ free ( msg_hdr );
+ free_msg_args( contactid, contact_count, sendmsg );
+ return MEM_ALLOCATION_ERROR;
+ }
+ msg_struct->hdr_req = msg_hdr;
+ msg_struct->msg = sendmsg;
+ //msg_struct is sent callback... which should be feed there..
+ send_message( msg_struct,
+ ( const gchar** ) contactid );
+ }
+ else
+ {
+ //there was some error, free resources allocated for this operation
+ free_msg_args( contactid, contact_count, sendmsg );
+ }
+
+ iso_logger( "%s", "Out - action_parse_send\n" );
+ //return error on failure, or no. of contacts message sent to on success
+ return meesage_type_err;
+
+ }
+
+/*! /brief Function to check if the channel is already present in the maintained hash
+ * text_channels_find_func.
+ *
+ * /param key unused
+ * /param text_channel hash table element
+ * /param contact_handle to be searched item
+ * /return boolean
+ */
+gboolean text_channels_find_func( gchar *key,
+ TpChan *text_channel,
+ guint *contact_handle )
+ {
+ iso_logger( "%s", "In - text_channels_find_func\n" );
+ //Check for the handles
+ UNUSED_FORMAL_PARAM(key);
+ if ( ( text_channel->handle == *contact_handle ) )
+ return TRUE;
+
+ return FALSE;
+ }
+
+/*! /brief Once the send request is sent to n/w server this callback is called
+ *
+ * /param proxy unused
+ * /param error n/w error if any
+ * /param userdata message header from which a response is formed
+ * /return void
+ */
+void sendreply_cb( DBusGProxy *proxy, GError *error, gpointer userdata )
+ {
+ int err = 0;
+
+ message_hdr_req* msg_hdr = ( message_hdr_req* ) userdata;
+ // create the msg queue
+ //user data is of type message_hdr_req
+ iso_logger( "%s", "In - sendreply_cb\n" );
+ UNUSED_FORMAL_PARAM(proxy);
+ if ( NULL != error )
+ {
+ //There was some error
+ //send the response for the msg_hdr request to client
+ err = send_response_to_client( msg_hdr, error->code, 0 );
+ //free the message
+ g_error_free(error);
+
+ }
+ else
+ {
+ //send the response for the msg_hdr request to client
+ err = send_response_to_client( msg_hdr, 0, 1 );
+ }
+ //Free the header recved as callback userdata
+ free( msg_hdr );
+
+ if ( err < 0 )
+ {
+ // failed to delievered
+ return ;
+ }
+ iso_logger( "%s", "Out - sendreply_cb\n" );
+ }
+
+/*! /brief This function is called by tg to as a response to request for the
+ * handles from the text channel. If there is no error, sent message(
+ * which has failed ) with its deatils is then sent to client
+ *
+ * /param proxy unused
+ * /param handles_names contac names (sender name)
+ * /param error error if any
+ * /param userdata send_error_struct
+ * /return void
+ */
+static void inspect_handles_for_error_cb( DBusGProxy *proxy,char **handles_names,
+ GError *error, gpointer userdata )
+ {
+
+ gint pri = MSG_PRI_NORMAL;
+ gint result = 0;
+ gint timeout = NO_WAIT;
+ gint err = 0;
+
+ send_error_struct* msg_struct = ( send_error_struct* ) userdata;
+ gchar* rmsg = NULL;
+ gint index = 0;
+ gint len = 0;
+ UNUSED_FORMAL_PARAM(proxy);
+ iso_logger( "%s", "In - inspect_handles_for_error_cb" );
+ if ( !handles_names || error || NULL == handles_names[0] )
+ {
+ if ( error )
+ {
+ g_error_free( error );
+ }
+ //Free the userdata passed to the callback
+ if ( NULL != msg_struct )
+ {
+ if ( msg_struct->msg_body )
+ {
+ g_free( msg_struct->msg_body );
+ }
+ g_free( msg_struct );
+ }
+ return;
+ }
+ //Allocate the memory and check for NULL
+ rmsg = ( gchar* ) malloc ( MAX_MSG_SIZE );
+ if ( NULL == rmsg )
+ {
+ goto mem_clean;
+ }
+ //set memory to 0
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //copy the header
+ //the response header, message type(from libtp), timestamp
+ memcpy( rmsg + index, msg_struct, sizeof( message_hdr_resp )
+ + 2 * sizeof( guint ) );
+
+ index += sizeof( message_hdr_resp ) + 2 * sizeof( guint );
+
+ //Copy the name to whom message was sent
+ len = strlen( handles_names[0] );
+ strcpy( rmsg + index, handles_names[0] );
+ index += len + 1;
+
+ //Copy the message body
+ if ( msg_struct->msg_body )
+ {
+ len = strlen( msg_struct->msg_body );
+ strcpy( rmsg + index, msg_struct->msg_body );
+ index += len + 1;
+ }
+ rmsg[index++] = '\0';
+ //Header format
+ //msgHdr|msg_type|timestamp|reciepient_name\0sent_msg\0
+ // ^ ^ ^
+ // | | |
+ //no dilimeter here nul nul
+ //send to the client
+ result = MsgQSend( RESPONSE_QUEUE, rmsg, index,
+ pri, timeout, &err );
+ iso_logger( "%s", "After MsgQSend" );
+//If memory allocation for rmsg has failed control comes
+//here
+mem_clean:
+
+ for ( len = 0; handles_names[len]; len++ )
+ {
+ free ( handles_names[len] );
+ }
+
+ if ( msg_struct->msg_body )
+ {
+ g_free( msg_struct->msg_body );
+ }
+ g_free( msg_struct );
+
+ if ( result < 0 )
+ {
+ //Failed to deliver the message
+ iso_logger( "%s", "Failed to deliver the message to client" );
+ return;
+ }
+ iso_logger( "%s", "Out - inspect_handles_for_error_cb" );
+
+ }
+
+/*! /brief This function on registered for "senderror" signal is called when the message
+ * sending is failed. Calls tp_conn_inspect_handles_async to get the contact name
+ * from text channel
+ *
+ * /param proxy : unused
+ * /param error : error code
+ * /param timestamp : sent to inspect_handles_for_error_cb thru' send_error_struct
+ * /param message_type : sent to inspect_handles_for_error_cb thru' send_error_struct
+ * /param message_body : sent to inspect_handles_for_error_cb thru' send_error_struct
+ * /param user_data text_chan from where to get the contatc name of reciepien
+ * /return void
+ */
+static void senderror_cb ( DBusGProxy *proxy,
+ guint error,
+ guint timestamp,
+ guint message_type,
+ gchar *message_body,
+ gpointer user_data )
+ {
+
+ TpChan *text_chan = ( TpChan * ) user_data;
+ send_error_struct* msg_struct = NULL;
+ GArray* fetch_members = NULL;
+ DBusGProxyCall* call_id = NULL;
+
+ //Logs
+ iso_logger( "%s", "In - SendError_cb\n" );
+ iso_logger( "error is %d", error );
+ iso_logger( "error is %d", message_type );
+ iso_logger( "error is %d", timestamp );
+ iso_logger( "error is %s", message_body );
+ UNUSED_FORMAL_PARAM(proxy);
+ //Allocate memory and check for NULL
+ //This msg_struct is passed to callback..
+ //So not deleting here.. ownership is transfered
+ msg_struct = ( send_error_struct* ) malloc ( sizeof( send_error_struct ) );
+
+ if ( NULL == text_chan || NULL == msg_struct )
+ {
+ return;
+ }
+ //Set the values to NULL
+ memset( msg_struct, '\0', sizeof( send_error_struct ) );
+ //Message type is send error
+ msg_struct->hdr_resp.hdr_req.message_type = ESend_Error;
+ //other values are set to 0
+ msg_struct->hdr_resp.hdr_req.protocol_id = 0;
+ msg_struct->hdr_resp.hdr_req.session_id = 0;
+ msg_struct->hdr_resp.hdr_req.request_id = 0;
+
+ //Message is sent as single entity..
+ //Message is not long enough to be broken into
+ msg_struct->hdr_resp.continue_flag = 0;
+ msg_struct->hdr_resp.response = 0;
+
+ //Set the error type
+ msg_struct->hdr_resp.error_type = error;
+ //Set the values from libtelepathy
+ msg_struct->msg_type = message_type;
+ msg_struct->timestamp = timestamp;
+ //Not checking for NULL here..
+ //I feel it is ok to send without the message
+ //Taken care of this in inspect_handles_for_error_cb
+ msg_struct->msg_body = strdup( message_body );
+
+ //Create an array of handles to get the handle name
+ fetch_members = g_array_new ( FALSE, FALSE, sizeof ( guint32 ) );
+ g_array_append_val( fetch_members, text_chan->handle );
+ //Call libtp function to get the contact name for the handle
+ //msg_struct is passed to inspect handles call back to be passed to
+ //client as error
+ call_id = tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,fetch_members,
+ inspect_handles_for_error_cb, msg_struct );
+
+ g_array_free( fetch_members, TRUE );
+ if ( NULL == call_id )
+ {
+ return ;
+ }
+
+ iso_logger( "%s", "Out - SendError_cb" );
+
+ }
+
+
+
+
+/*! /brief called as a callback to acknowledge the msg ack.
+ *
+ * /param proxy unused
+ * /param error error if any
+ * /param userdata unused
+ * /return void
+ */
+static void msg_ack_pending_cb( DBusGProxy *proxy, GError *error, gpointer userdata )
+
+ {
+ gchar *str = "Inside msg_ack_pending_cb";
+ UNUSED_FORMAL_PARAM(proxy);
+ UNUSED_FORMAL_PARAM(userdata);
+ if ( error )
+ {
+ //If there was error, ignore it and free the memory
+ g_error_free(error);
+ }
+
+ iso_logger( str );
+ }
+
+
+
+/*! /brief This function is a callback for to get the contact name from handles.
+ * This function acknowledges the recieved message and send that to client(adap)
+ *
+ * /param proxy unused
+ * /param handles_names 2D array of message sender(one contact ended with a NULL string)
+ * /param error error if any
+ * /param userdata Received_UserData that has message body, response header etc.,
+ * /return void
+ */
+static void getting_sender_cb( DBusGProxy *proxy,char **handles_names, GError *error, gpointer userdata )
+ {
+
+ gchar *str = "Inside getting_sender_cb";
+ GArray *message_ids;
+ gint result = 0;
+ Received_UserData *user_data = ( Received_UserData* )userdata;
+ iso_logger( "%s", str );
+ UNUSED_FORMAL_PARAM(proxy);
+ if ( !handles_names || error )
+ {
+ if ( error )
+ {
+ //If there was error, ignore it and free the memory
+ g_error_free(error);
+ }
+ //Free the userdata passed to the callback
+ g_free( user_data->message_body );
+ g_free( user_data );
+ iso_logger( "%s", "handle names error" );
+ return;
+ }
+
+ message_ids = g_array_new ( FALSE, FALSE, sizeof ( guint ) );
+ if ( NULL == message_ids )
+ {
+ //Free the userdata passed to the callback
+ g_free( user_data->message_body );
+ g_free( user_data );
+ return ;
+ }
+ g_array_append_val ( message_ids, user_data->message_id );
+ //Acknowledge that message has been recieved
+ tp_chan_type_text_acknowledge_pending_messages_async( user_data->proxy, message_ids,
+ msg_ack_pending_cb, NULL );
+ //Send to the client the messgae and the sender name
+ result = send_message_to_client( user_data->message_body , *handles_names );
+
+ if ( 0 > result )
+ {
+ return;
+ }
+
+ iso_logger( "%s", "getting_sender_cb" );
+ iso_logger( "%s", user_data->message_body );
+
+ //Free the messgae ids array
+ g_array_free ( message_ids, TRUE );
+ //free the recieved data
+ g_free( user_data->message_body );
+ g_free( user_data );
+
+
+ }
+
+
+
+
+/*! /brief when a message is recieved this function is called by
+ * telepathygabble(by emitting signal). This function then requests tg
+ * to get the contact names corresponding to handles.
+ *
+ * /param proxy sent to getting_sender_cb as param in userdata
+ * /param timestamp unused
+ * /param handles_names
+ * /param message_type unused
+ * /param message_flags unused
+ * /param message_body recieved message
+ * /param userdata unused
+ */
+void receivedMessage_cb ( DBusGProxy *proxy,
+ guint message_id,
+ guint timestamp,
+ guint from_handle,
+ guint message_type,
+ guint message_flags,
+ gchar *message_body,
+ gpointer user_data )
+ {
+ GArray *handles = NULL;
+ Received_UserData *recv_userdata = NULL;
+
+ iso_logger( "%s", "receivedMessage_cb:" );
+ UNUSED_FORMAL_PARAM(timestamp);
+ UNUSED_FORMAL_PARAM(message_type);
+ UNUSED_FORMAL_PARAM(message_flags);
+ UNUSED_FORMAL_PARAM(user_data);
+ //Allocate memory and initalize the structure
+ recv_userdata = g_new ( Received_UserData, 1 );
+ if ( NULL == recv_userdata )
+ {
+
+ free ( message_body );
+ return ;
+ }
+ //TBD : Check if this assignment works..
+ //previously it was strdup of message_body
+ recv_userdata->message_body = strdup( message_body );
+ recv_userdata->message_id = message_id;
+ recv_userdata->proxy = proxy;
+
+ //logs
+ iso_logger( "%s", message_body );
+ //allocate memory for the handles
+ handles = g_array_new ( FALSE, FALSE, sizeof ( guint32 ) );
+ if ( NULL == handles )
+ {
+ //free previously allocated struct
+ g_free( recv_userdata->message_body );
+ g_free( recv_userdata );
+ return ;
+ }
+
+ g_array_append_val ( handles, from_handle );
+ //get the sender name corresponding to the handles
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,handles,
+ getting_sender_cb,recv_userdata );
+ //free handles
+ g_array_free ( handles, TRUE );
+
+ }
+
+
+/*! /brief whenevr a new channel handler for text is created, this function is called. This
+ * function also registers that channel for Received and SendError signals. Also the pending
+ * messages are also retrieved in this function
+ *
+ * /param tp_chan new channel created
+ */
+ void text_channel_init( TpChan *text_chan )
+ {
+
+ GPtrArray *messages_list ;
+ guint i = 0;
+ GArray *message_ids;
+ DBusGProxy *text_iface;
+ GArray *handles = NULL;
+ Received_UserData *recv_userdata = NULL;
+
+
+ iso_logger( "%s", "inside text_channel_init" );
+ //text_chan has been checked for NULL in the callee function
+ text_iface = tp_chan_get_interface( text_chan ,
+ TELEPATHY_CHAN_IFACE_TEXT_QUARK );
+
+ message_ids = g_array_new ( FALSE, TRUE, sizeof ( guint ) );
+
+ handles = g_array_new ( FALSE, FALSE, sizeof ( guint32 ) );
+ //If memory allocation fialure, return from here
+ if ( !text_iface || !message_ids || !handles )
+ {
+ return ;
+ }
+
+ tp_chan_type_text_list_pending_messages( text_iface,
+ FALSE,
+ &messages_list,
+ NULL );
+ //For all the pending messages get the sender name
+ //and send to client the sender name and recv msg
+ for ( i = 0; i < messages_list->len ; i++ )
+ {
+ guint message_id;
+ guint from_handle;
+ const gchar *message_body;
+ GValueArray *message_struct;
+
+ message_struct = ( GValueArray * ) g_ptr_array_index ( messages_list, i );
+
+ //Not all the fields used currently
+ //Ignoring the unused fields
+ message_id = g_value_get_uint( g_value_array_get_nth( message_struct, 0 ) );
+ //get the handle to sender
+ from_handle = g_value_get_uint(g_value_array_get_nth( message_struct, 2 ) );
+ //Get the message body
+ message_body = g_value_get_string( g_value_array_get_nth( message_struct, 5 ) );
+
+ iso_logger ( "%s", message_body );
+
+ g_array_append_val( handles, from_handle );
+ //Allocate memory for the recv data
+ recv_userdata = g_new( Received_UserData, 1 );
+ if ( !recv_userdata )
+ {
+ break; //Break from the loop
+ }
+ //Set all the necessary fields
+ recv_userdata->message_body = g_strdup( message_body );
+ recv_userdata->message_id = message_id;
+ recv_userdata->proxy = text_iface;
+ //get the name for the sender handle
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,handles,
+ getting_sender_cb, recv_userdata );
+
+ g_array_append_val ( message_ids, message_id );
+
+ //To reuse the array, remove the 1 that was inserted
+ g_array_remove_range( handles, 0, handles->len );
+
+ }
+ iso_logger ( "%s", "before ack pending msg");
+ //acknowledge the recved messages
+ tp_chan_type_text_acknowledge_pending_messages( text_iface, message_ids,
+ NULL );
+
+ iso_logger ( "%s", "after ack pending msg" );
+
+ //Listen to Received signal
+ dbus_g_proxy_connect_signal( text_iface, "Received",
+ G_CALLBACK( receivedMessage_cb ),
+ NULL, NULL );
+
+ //Register for the senderror signal
+ dbus_g_proxy_connect_signal( text_iface, "SendError",
+ G_CALLBACK( senderror_cb ),
+ text_chan, NULL );
+
+ //Should the messages_list be freed?
+ g_array_free( message_ids, TRUE );
+ g_array_free( handles, TRUE );
+
+
+ }
+
+
+
+
+ /*! /brief called by getting_sender_cb to send the recieved message to client
+ *
+ * /param msg message recieved
+ * /param sender message from whom recieved
+ */
+gint send_message_to_client( const gchar *msg , const gchar *sender )
+
+ {
+ gint len=0;
+ gint pri = MSG_PRI_NORMAL;
+ gchar *rmsg = NULL;
+ gint index = 0;
+ gint err;
+ message_hdr_resp* msg_resp = NULL;
+ gint result;
+ gint timeout = NO_WAIT;
+
+ msg_resp = ( message_hdr_resp* ) malloc ( sizeof( message_hdr_resp ) );
+ if ( NULL == msg_resp )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //Allocate memory and initialze to 0
+ rmsg = ( gchar* ) malloc ( MAX_MSG_SIZE );
+ if ( NULL == rmsg )
+ {
+ free ( msg_resp );
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ //Initialze the memory to 0
+ memset( msg_resp, '\0', sizeof( message_hdr_resp ) );
+ //Set the message type to EText_Message_Receive and set other fields
+ //to default values
+ msg_resp->hdr_req.message_type = EText_Message_Receive;
+ msg_resp->hdr_req.protocol_id = 1;
+ msg_resp->hdr_req.session_id = 1;
+ msg_resp->hdr_req.request_id =1;
+ //Set the respone as success and error is 0
+ msg_resp->response = 1;
+ msg_resp->error_type = 0;
+
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //copy the header
+ memcpy( rmsg, msg_resp, sizeof( message_hdr_resp ) );
+ index += sizeof( message_hdr_resp );
+
+ //copy the sender
+ //putting sender in message queue
+ len = strlen(sender);
+ strcpy( rmsg + index, sender );
+ index += len + 1;
+
+ //putting message body
+ len = strlen(msg);
+ strcpy( rmsg + index, msg );
+ index += len + 1;
+
+ //Header format
+ //msgHdr|sender_name\0recved_msg\0
+ // ^ ^ ^
+ // | | |
+ //no dilimeter here nul nul
+ //send to the client
+ result = MsgQSend( RESPONSE_QUEUE, rmsg, index,
+ pri, timeout, &err );
+ free ( rmsg );
+
+ free ( msg_resp );
+
+ if ( result < 0 )
+ {
+ return MSG_Q_SEND_FAILED;
+ }
+
+ iso_logger( "%s", "message is:\n" );
+ return TRUE;
+ }
+
+// end of files
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isomodifycontactlist.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,497 @@
+/*
+* ============================================================================
+* Name : isomodifycontacts.h
+* Part of : isolation server.
+* Version : %version: 16 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include "msgliterals.h"
+#include "isomodifycontactlist.h"
+#include "isoutils.h"
+#include "isofetchcontactlist.h" //For send_contact_to_client func
+
+/*! \file
+* Impliments the functions in isomodifycontactlist.h
+*/
+
+/*!
+ * /brief This function is called by message_send_recv function in isoservermain.c if message type
+ * is EReject_Contact_Request, EAccept_Contact_Request, EAdd_Contact_Request and EDelete_Contact_Request.
+ * Contacts added/removed to/from list. This function parses the message buffer,
+ * validates for the arguments and calls modify_contact_list to add/remove contacts
+ *
+ * /param buf : buffer to be parsed
+ * /param buf_len : buffer length
+ * /return : error code if any, 0 on success
+ */
+gint action_parse_modify_contact_list( gchar* buf, gint buf_len )
+ {
+ gchar** contactid = NULL;
+ gchar* msg = NULL;
+ gint meesage_type_err = 0;
+ gint len = 0;
+ gint contact_count = 0;
+
+ //parse contacts, message..
+ iso_logger( "%s", "In - action_parse_modify_contact_list" );
+ len += sizeof( message_hdr_req );
+ //example send message - message header omitted..
+ //test.ximp@gmail.com\0ximp.telepathy@gmail.com\0\0I would like to add u!\0
+ // ^ ^ ^ ^
+ //contact1------------|contact2-----------------|-|message----------------|
+ //Till Message part is parsed by the following function
+ meesage_type_err = parse_into_array_of_strings( buf, &contactid, &len, buf_len, &contact_count );
+ if ( meesage_type_err < 0 )
+ {
+ gchar* msg = NULL;
+ //An error has occured, so propagate to next level
+ free_msg_args( contactid, contact_count, msg );
+ //got error, print to file
+ return meesage_type_err;
+ }
+
+ //Parse the message
+ //message is optional.. so check if message has been sent
+ if ( len < buf_len )
+ {
+
+ gint err = 0;
+
+ // iso_logger( "%x", len );
+ // iso_logger( "%f", len );
+
+ //parse for the message..
+ err = parse_a_string( buf, &msg, &len, buf_len );
+
+ if ( err < 0 )
+ {
+ //return err;
+ //ignoring the error..
+ //as message is not that important
+ msg = NULL;
+ }
+ }
+ //If there is atleast one contact to add
+ if ( contact_count > 0 )
+ {
+ //Add the header and message to the msg struct
+ //this struct will be used in the callbacks
+ send_msg_struct* msg_struct = NULL;
+ msg_struct = ( send_msg_struct* ) malloc( sizeof( send_msg_struct ) );
+ if ( NULL == msg_struct )
+ {
+ //An error has occured, so propagate to next level
+ free_msg_args( contactid, contact_count, msg );
+ return MEM_ALLOCATION_ERROR;
+ }
+ //allocate memory and check for the returned value
+ msg_struct->hdr_req = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ if ( NULL == msg_struct->hdr_req )
+ {
+ //An error has occured, so propagate to next level
+ free_msg_args( contactid, contact_count, msg );
+ free ( msg_struct );
+ return MEM_ALLOCATION_ERROR;
+ }
+ //initalize to 0...
+ memset( msg_struct->hdr_req, '\0', sizeof( message_hdr_req ) );
+ //read message header from buffer
+ memcpy( msg_struct->hdr_req, buf, sizeof( message_hdr_req ) );
+ //message, msg can be NULL as well
+ msg_struct->msg = msg;
+
+ meesage_type_err = modify_contact_list( msg_struct,
+ ( const char** )contactid, meesage_type_err );
+ if ( meesage_type_err < 0 )
+ {
+ //Do cleanup here
+ //delete contact_ids and message
+ //An error has occured, so propagate to next level
+ free_msg_args( contactid, contact_count, msg );
+ free ( msg_struct->hdr_req );
+ free ( msg_struct );
+ return meesage_type_err;
+ }
+ }
+
+ iso_logger( "%s", "In - action_parse_modify_contact_list" );
+
+ return meesage_type_err;
+ }
+
+
+/*!
+ * /brief gets the handles for contacts. Handles are returned in request_modify_contact_list_handles_cb
+ * callback which is an arg for the async request to get handles.
+ *
+ * /param msg_hdr : The header and message passed to callbacks
+ * /param contact_id : contact ids whose handles to be returned
+ * /param no_cntcts : total no. of contacts to be added
+ * /return : error code if any, handle on success
+ */
+guint get_handles_for_contacts ( send_msg_struct* msg_hdr, const gchar **contact_id,
+ gint no_cntcts )
+ {
+
+ iso_logger( "%s", "in -- get_handles_for_contacts" );
+
+ //check for the return value if 0 is ok or should some negative value to be passed
+ g_return_val_if_fail (contact_id != NULL, 0);
+
+ //Send request to get the handles for the contacts..
+ //handles will be returned in request_addcontacts_handles_cb
+ tp_conn_request_handles_async( DBUS_G_PROXY(globalCon.conn),
+ TP_CONN_HANDLE_TYPE_CONTACT, contact_id,
+ request_modify_contact_list_handles_cb, ( gpointer )msg_hdr );
+
+ iso_logger( "%s", "in -- get_handles_for_contacts" );
+ //no of contacts is returned on successful completion of getting handles
+ return no_cntcts;
+ }
+
+
+/*!
+ * /brief Handles are returned in this callback. Which will then actually do modify
+ * the contact list based on the request type(add/remove/accept/reject)
+ * modify_contact_list_cb is registered as the callback.
+ *
+ * /param proxy : unused
+ * /param handles : handles of the contacts
+ * /param error : error if any
+ * /param message : userdata(send_msg_struct) passed back
+ * /return : error code if any, handle on success
+ */
+void request_modify_contact_list_handles_cb( DBusGProxy *proxy, GArray *handles,
+ GError* error, gpointer message )
+ {
+ send_msg_struct* msg_hdr = ( send_msg_struct* ) message;
+ UNUSED_FORMAL_PARAM(proxy);
+ iso_logger( "%s", "in -- request_modify_contact_list_handles_cb" );
+
+ if ( !handles || error )
+ {
+ send_response_to_client( msg_hdr->hdr_req, error->code, 0 );
+
+ if ( error )
+ {
+ g_error_free(error);
+ }
+ free ( msg_hdr->msg );
+ free ( msg_hdr->hdr_req );
+ free ( msg_hdr );
+ iso_logger( "%s", "handle got is invalid" );
+ return;
+ }
+
+ //Check if the request is to add contact or delete contact
+ if ( EAdd_Contact_Request == msg_hdr->hdr_req->message_type )
+ {
+ //got the handles for contacts now send request to add those contacts
+ tp_chan_iface_group_add_members_async ( globalCon.group_iface_subscribe, handles,
+ msg_hdr->msg, modify_contact_list_cb, msg_hdr->hdr_req );
+ }
+ else if ( EDelete_Contact_Request == msg_hdr->hdr_req->message_type )
+ {
+ //got the handles for contacts now send request to delete those contacts
+ tp_chan_iface_group_remove_members_async ( globalCon.group_iface_known, handles,
+ msg_hdr->msg, modify_contact_list_cb, msg_hdr->hdr_req );
+ }
+ else if ( EAccept_Contact_Request == msg_hdr->hdr_req->message_type )
+ {
+ //got the handles for contacts now send request to add those contacts
+ tp_chan_iface_group_add_members_async ( globalCon.group_iface_publish, handles,
+ msg_hdr->msg, modify_contact_list_cb, msg_hdr->hdr_req );
+ }
+ else if ( EReject_Contact_Request == msg_hdr->hdr_req->message_type )
+ {
+ //got the handles for contacts now send request to delete those contacts
+ tp_chan_iface_group_remove_members_async ( globalCon.group_iface_publish, handles,
+ msg_hdr->msg, modify_contact_list_cb, msg_hdr->hdr_req );
+ }
+
+ //free handles
+ g_array_free ( handles, TRUE );
+ //free header
+ //hdr_req not to be freed, it is freed by modify_contact_list_cb
+ free ( msg_hdr->msg );
+ free ( msg_hdr );
+ iso_logger( "%s", "out -- request_modify_contact_list_handles_cb" );
+ }
+
+/*!
+ * /brief Calls get_handles_for_contacts to get the handles for contact.
+ *
+ * /param msg_hdr : message request header passed to callbacks
+ * /param contact_id : contact ids to be added
+ * /param message : messgae if any
+ * /param no_cntcts : no of contacts to be added
+ * /return void
+ */
+gint modify_contact_list ( send_msg_struct* msg_hdr, const gchar **contact_ids,
+ gint no_cntcts )
+ {
+
+ guint err = 0;
+
+ iso_logger( "%s", "in -- modify_contact_list" );
+
+ //g_array_append_val ( handles, handle );
+ //gets the handles for contacts
+ //Handles are returned in request_addcontacts_handles_cb callback
+ err = get_handles_for_contacts( msg_hdr, contact_ids, no_cntcts );
+
+ iso_logger( "%s", "Out -- -- modify_contact_list" );
+
+ return err;
+
+
+ }
+
+/*!
+ * /brief called as callback for request for modify contact list
+ * This function then sends the result to client
+ *
+ * /param proxy unused
+ * /param error Error if any
+ * /param userdata request message header
+ * /return void
+ */
+void modify_contact_list_cb( DBusGProxy *proxy, GError *error, gpointer userdata )
+ {
+
+ int err = 0;
+ //user data is of type message_hdr_req
+ message_hdr_req *msg_hdr = ( message_hdr_req * )userdata;
+ UNUSED_FORMAL_PARAM(proxy);
+ iso_logger( "%s", "In - modify_contact_list_cb\n" );
+ //Check if there is any error
+ if ( NULL != error )
+ {
+ //Failed to add contact:
+ iso_logger ( "%s", "Failed to modify contact: \n" );
+
+ err = send_response_to_client( msg_hdr, error->code, 0 );
+ g_error_free(error);
+ }
+ else
+ {
+ //Contact added successfully:
+ iso_logger ( "%s", "Contact modify successfully:" );
+ err = send_response_to_client( msg_hdr, 0, 1 );
+ }
+ //free the msg hdr
+ free( msg_hdr );
+
+ if ( err < 0 )
+ {
+ // failed to delievered
+ return ;
+ }
+ iso_logger( "%s", "out -- modify_contact_list_cb" );
+ }
+
+
+/*!
+ * /brief The contact names corresponding to the contact handles that are changed
+ * are passed to the client
+ * /param proxy
+ * /param handles_name
+ * /param error
+ * /param userdata
+ * /return void
+ */
+static void rosters_changed_contacts_cb( DBusGProxy *proxy,
+ gchar **handles_names, GError *error, gpointer userdata )
+ {
+ gint i = 0;
+ gchar* member = NULL;
+ gint mem_count = 0;
+
+ gint* msg_type = ( gint* ) userdata;
+
+ iso_logger( "%s", "In -- rosters_changed_contacts_cb" );
+ UNUSED_FORMAL_PARAM(proxy);
+ if ( !handles_names || error )
+ {
+ if ( error )
+ {
+ g_error_free(error);
+ }
+ free ( msg_type );
+ iso_logger( "%s", "handle names error" );
+ return;
+ }
+
+ //read all the contacts
+ //The handles_names will have NULL as it last elemnt in the array
+ for ( i = 0; handles_names[i]; i++ )
+ {
+ member = handles_names[i];
+ iso_logger( "This member : %s is trying to add you",
+ member );
+ mem_count++;
+ }
+ //code to send the added contact to client
+ if ( mem_count )
+ {
+ gint err = 0;
+ err = send_contacts_to_client( handles_names, mem_count, *msg_type );
+ if ( err )
+ {
+ //How to handle the error?
+ for ( i = 0; i < mem_count; i++ )
+ {
+ free ( handles_names[i] );
+ }
+ iso_logger( "%s", "There was error in send_contacts_to_client" );
+ free ( msg_type );
+ return;
+ }
+ }
+
+ free ( msg_type );
+
+ iso_logger( "%s", "Out -- rosters_changed_contacts_cb" );
+
+ }
+
+/*! /brief Whenever contact list is changed by others( someone trying to add this user
+ * or someone rejecting the add request etc., ) this callback registered as a signal
+ * is called with the handles of the changed contacts. rosters_changed_contacts_cb is
+ * passed as callback to get the contact name of the changed handles
+ *
+ * /param group_iface unused
+ * /param message unused
+ * /param added List of contacts that are recently added
+ * /param removed List of contacts that were recently removed
+ * /param local_pending List of contacts that are locally pending for approval
+ * /param remote_pending List of contacts that are remotely pending for approval
+ * /param actor unused
+ * /param reason unused
+ * /param userdata unused
+ * /return void
+ */
+void roster_members_changed_cb ( DBusGProxy *group_iface,
+ gchar *message,
+ GArray *added,
+ GArray *removed,
+ GArray *local_pending,
+ GArray *remote_pending,
+ guint actor,
+ guint reason,
+ gpointer userdata )
+ {
+
+ gint* msg_type = ( gint* ) malloc ( sizeof( gint* ) );
+
+ iso_logger( "%s", "In - roster_members_changed_cb\n" );
+
+ //members in the contact list have changed
+ //Get the contact name of the handles thru rosters_changed_contacts_cb
+ UNUSED_FORMAL_PARAM(message);
+ UNUSED_FORMAL_PARAM(actor);
+ UNUSED_FORMAL_PARAM(reason);
+ UNUSED_FORMAL_PARAM(userdata);
+ if ( group_iface == globalCon.group_iface_subscribe && remote_pending
+ && 0 < remote_pending->len )
+ {
+ *msg_type = ESubscribe_Remote_Pending;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,remote_pending,
+ rosters_changed_contacts_cb, msg_type );
+ }
+ if ( group_iface == globalCon.group_iface_subscribe && removed
+ && 0 < removed->len )
+ {
+ //User is trying to remove the contact from list
+ //
+ *msg_type = ESubscribe_Removed_Or_Rejected;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,removed,
+ rosters_changed_contacts_cb, msg_type );
+ }
+ if ( group_iface == globalCon.group_iface_subscribe && added
+ && 0 < added->len )
+ {
+ //
+ *msg_type = ESubscribe_RP_Accepted;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,added,
+ rosters_changed_contacts_cb, msg_type );
+ }
+ if ( group_iface == globalCon.group_iface_publish && added
+ && 0 < added->len )
+ {
+ *msg_type = EPublish_RP_Accepted;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,added,
+ rosters_changed_contacts_cb, msg_type );
+ }
+
+ if ( group_iface == globalCon.group_iface_publish && local_pending
+ && 0 < local_pending->len )
+ {
+ *msg_type = ETrying_To_Add_Contact_Publish;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,local_pending,
+ rosters_changed_contacts_cb, msg_type );
+ }
+ if ( group_iface == globalCon.group_iface_publish && removed
+ && 0 < removed->len )
+ {
+ *msg_type = EPublish_Removed_Or_Rejected;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,removed,
+ rosters_changed_contacts_cb, msg_type );
+ }
+ if ( group_iface == globalCon.group_iface_known && removed
+ && 0 < removed->len )
+ {
+ //User is trying to remove the contact from list
+ //
+ *msg_type = ESubscribe_Removed_Or_Rejected;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,removed,
+ rosters_changed_contacts_cb, msg_type );
+ }
+ if ( group_iface == globalCon.group_iface_known && added
+ && 0 < added->len )
+ {
+ //User is trying to remove the contact from list
+ //
+ *msg_type = ETrying_To_Add_Contact_Known;
+ tp_conn_inspect_handles_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_CONN_HANDLE_TYPE_CONTACT ,added,
+ rosters_changed_contacts_cb, msg_type );
+ }
+
+ //log message
+ iso_logger( "%s", "out - roster_members_changed_cb\n" );
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isopresence.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,830 @@
+/*
+* ============================================================================
+* Name : isopresence.c
+* Part of : isolation server.
+* Version : %version: 18 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#include "isopresence.h"
+#include "stdio.h"
+#include "isoservermain.h"
+#include "msgliterals.h"
+#include "msgqlib.h"
+#include "msg_enums.h"
+#include "isoutils.h"
+
+//#include "config.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef SYMBIAN
+#include <glib/gi18n.h>
+#include <libintl.h>
+#define _(x) dgettext (GETTEXT_PACKAGE, x)
+#define N_(x) x
+#else
+#define _(x) x
+#define N_(x) x
+#endif
+
+/*! \file
+* Impliments the functions in isomodifycontactlist.h
+*/
+
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TELEPATHY_TYPE_PRESENCE, TelepathyPresencePriv))
+
+/*! \var glob_handle_name accessed in multiple functions. Stores the
+* contact name
+* \remark This global variable can be avoided
+*/
+gchar * glob_handle_name;
+
+/*! \typedef long typedefed to TelepathyTime
+*/
+typedef long TelepathyTime; /* Note: Always in UTC. */
+
+
+/*! \typedef long struct _TelepathyPresencePriv to TelepathyPresencePriv
+*/
+typedef struct _TelepathyPresencePriv TelepathyPresencePriv;
+
+/*! \struct _TelepathyPresencePriv
+* \brief telepathy presence object
+*
+* \var state presence state
+* \var status status text
+* \var resource GObject resource
+* \var priority GObject priority
+* \var timestamp set with current time
+*/
+struct _TelepathyPresencePriv {
+ TelepathyPresenceState state;
+
+ gchar *status;
+ gchar *resource;
+
+ gint priority;
+ TelepathyTime timestamp;
+};
+
+/*! \enum
+* \brief _TelepathyPresencePriv member variables
+*/
+enum {
+ PROP_0,
+ PROP_STATE,
+ PROP_STATUS,
+ PROP_RESOURCE,
+ PROP_PRIORITY
+};
+
+G_DEFINE_TYPE (TelepathyPresence, telepathy_presence, G_TYPE_OBJECT);
+
+/*! \brief Documented in the header file
+*/
+TelepathyTime
+telepathy_time_get_current (void)
+{
+ return time (NULL);
+}
+
+/*! \brief Documented in the header file
+*/
+static void
+telepathy_presence_class_init (TelepathyPresenceClass *presclass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (presclass);
+
+ object_class->finalize = presence_finalize;
+ object_class->get_property = presence_get_property;
+ object_class->set_property = presence_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_STATE,
+ g_param_spec_int ("state",
+ "Presence State",
+ "The current state of the presence",
+ TELEPATHY_PRESENCE_STATE_AVAILABLE,
+ TELEPATHY_PRESENCE_STATE_EXT_AWAY,
+ TELEPATHY_PRESENCE_STATE_AVAILABLE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_STATUS,
+ g_param_spec_string ("status",
+ "Presence Status",
+ "Status string set on presence",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_RESOURCE,
+ g_param_spec_string ("resource",
+ "Presence Resource",
+ "Resource that this presence is for",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_PRIORITY,
+ g_param_spec_int ("priority",
+ "Presence Priority",
+ "Priority value of presence",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof (TelepathyPresencePriv));
+}
+
+/*! \brief Documented in the header file
+*/
+static void
+telepathy_presence_init (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (presence);
+
+ priv->state = TELEPATHY_PRESENCE_STATE_AVAILABLE;
+
+ priv->status = NULL;
+ priv->resource = NULL;
+
+ priv->priority = 0;
+
+ priv->timestamp = telepathy_time_get_current ();
+}
+
+/*! /brief GObject finalize funtion
+*
+* /param object object to be finalized
+*/
+static void
+presence_finalize (GObject *object)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ g_free (priv->status);
+ g_free (priv->resource);
+
+ (G_OBJECT_CLASS (telepathy_presence_parent_class)->finalize) (object);
+}
+
+/*! /brief GObject get property funtion
+*
+* /param object Gobject
+* /param param_id
+* /param value
+* /param pspec
+*/
+static void
+presence_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_STATE:
+ g_value_set_int (value, priv->state);
+ break;
+ case PROP_STATUS:
+ g_value_set_string (value,
+ telepathy_presence_get_status (TELEPATHY_PRESENCE (object)));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+/*! /brief GObject set property funtion
+*
+* /param object Gobject
+* /param param_id
+* /param value
+* /param pspec
+*/
+static void
+presence_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_STATE:
+ priv->state = g_value_get_int (value);
+ break;
+ case PROP_STATUS:
+ telepathy_presence_set_status (TELEPATHY_PRESENCE (object),
+ g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+/*! /brief create a presence object instance
+ * /return created presence object instance
+ */
+
+TelepathyPresence *
+telepathy_presence_new (void)
+{
+ return g_object_new (TELEPATHY_TYPE_PRESENCE, NULL);
+}
+
+/*! /brief get the presence status value
+ *
+ * /param presence : presence object
+ * /return state : status as set in presence object
+ */
+const gchar *
+telepathy_presence_get_status (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (presence), NULL);
+
+ priv = GET_PRIV (presence);
+
+ return priv->status;
+}
+
+/*! /brief get the presence state value
+ *
+ * /param presence : presence object
+ * /return state : state as set in presence object
+ */
+TelepathyPresenceState
+telepathy_presence_get_state (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (presence),
+ TELEPATHY_PRESENCE_STATE_AVAILABLE);
+
+ priv = GET_PRIV (presence);
+
+ return priv->state;
+}
+
+/*! /brief set the presence state value in presence gobject
+ *
+ * /param presence : presence object
+ * /param state : state
+ * /return : void
+ */
+void
+telepathy_presence_set_state (TelepathyPresence *presence,
+ TelepathyPresenceState state)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_if_fail (TELEPATHY_IS_PRESENCE (presence));
+
+ priv = GET_PRIV (presence);
+
+ priv->state = state;
+
+ g_object_notify (G_OBJECT (presence), "state");
+}
+
+/*! /brief set the presence status text value in presence gobject
+ *
+ * /param presence : presence object
+ * /param state : status
+ * /return : void
+ */
+void
+telepathy_presence_set_status (TelepathyPresence *presence,
+ const gchar *status)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_if_fail (TELEPATHY_IS_PRESENCE (presence));
+
+ priv = GET_PRIV (presence);
+
+ g_free (priv->status);
+
+ if (status) {
+ priv->status = g_strdup (status);
+ } else {
+ priv->status = NULL;
+ }
+
+ g_object_notify (G_OBJECT (presence), "status");
+
+}
+
+/*! /brief converts presence state value from enum to string
+ * /param presence_state : presence state enum value
+ * /return : presence state string value
+ */
+const gchar *
+telepathy_presence_state_to_str (TelepathyPresenceState presence_state)
+{
+
+ switch (presence_state) {
+ case TELEPATHY_PRESENCE_STATE_AVAILABLE:
+ return "available";
+ case TELEPATHY_PRESENCE_STATE_BUSY:
+ return "dnd";
+ case TELEPATHY_PRESENCE_STATE_AWAY:
+ return "away";
+ case TELEPATHY_PRESENCE_STATE_EXT_AWAY:
+ return "xa";
+ case TELEPATHY_PRESENCE_STATE_HIDDEN:
+ return "hidden";
+ case TELEPATHY_PRESENCE_STATE_UNAVAILABLE:
+ return "offline";
+ default:
+ return NULL;
+ }
+}
+
+/*! /brief converts presence state value from string to enum
+ *
+ * /param str : presence state string value
+ * /return : presence state enum value
+ */
+TelepathyPresenceState
+telepathy_telepathy_presence_state_from_str (const gchar *str)
+{
+
+ if (strcmp (str, "available") == 0) {
+ return TELEPATHY_PRESENCE_STATE_AVAILABLE;
+ } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
+ return TELEPATHY_PRESENCE_STATE_BUSY;
+ } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
+ return TELEPATHY_PRESENCE_STATE_AWAY;
+ } else if (strcmp (str, "xa") == 0) {
+ return TELEPATHY_PRESENCE_STATE_EXT_AWAY;
+ } else if (strcmp (str, "hidden") == 0) {
+ return TELEPATHY_PRESENCE_STATE_HIDDEN;
+ } else if (strcmp (str, "offline") == 0) {
+ return TELEPATHY_PRESENCE_STATE_UNAVAILABLE;
+ }
+
+ return TELEPATHY_PRESENCE_STATE_AVAILABLE;
+}
+
+/*! /brief updates own presence to the n/w server. update_status_cb
+ * is registered for the callback
+ *
+ * /param pres_iface : presence interface
+ * /param presence : presence object
+ * /param msg_hdr : presence info list to send presence_msg_struct
+ * has state, status etc.,
+ * /return : void
+ */
+void
+telepathy_contacts_send_presence (DBusGProxy *pres_iface,
+ TelepathyPresence *presence,
+ presence_msg_struct* msg_hdr)
+{
+ GHashTable *status_ids;
+ GHashTable *status_options;
+ const gchar *status_id;
+ const gchar *message;
+ TelepathyPresenceState presence_state;
+ GValue value_message = {0, };
+
+ if (!pres_iface) {
+ return;
+ }
+ iso_logger( "%s", "In - telepathy_contacts_send_presence\n" );
+
+ status_ids = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) g_hash_table_destroy);
+ status_options = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL,
+ (GDestroyNotify) g_value_unset); //ToDo: get clarity on freeing this resource
+
+ presence_state = telepathy_presence_get_state (presence);
+ status_id = telepathy_presence_state_to_str (presence_state);
+ message = telepathy_presence_get_status (presence);
+
+ if (message) {
+ g_value_init (&value_message, G_TYPE_STRING);
+ g_value_set_string (&value_message, message);
+ g_hash_table_insert (status_options, "message", &value_message);
+ }
+
+ g_hash_table_insert (status_ids,
+ g_strdup (status_id),
+ status_options);
+
+ tp_conn_iface_presence_set_status_async(DBUS_G_PROXY(pres_iface),
+ status_ids,
+ update_status_cb,
+ (gpointer)msg_hdr->hdr_req );
+
+ g_hash_table_destroy (status_options); //ToDo: get clarity on freeing this resource
+ g_hash_table_destroy (status_ids);
+ iso_logger( "%s", "Out - telepathy_contacts_send_presence\n" );
+
+}
+
+/*! /brief This function will be called for presence of each contact
+ * key has got the state and value status
+ *
+ * /param key : hash table key ie presence state
+ * /param value : hash table value ie presence information
+ * /param presence : user data
+ * /remark presence object is logically unused ?
+ *
+ * /return : void
+ */
+static void
+telepathy_presences_foreach (gpointer *key,
+ gpointer *value,
+ TelepathyPresence **presence)
+{
+
+ TelepathyPresenceState state;
+ const gchar *message = NULL;
+
+ *presence = telepathy_presence_new();
+ iso_logger( "%s", "In - telepathy_presences_foreach\n" );
+
+ iso_logger( "%s%s", "state : ", (gchar *)key );
+
+ state = telepathy_telepathy_presence_state_from_str((const gchar *)
+ key);
+ telepathy_presence_set_state(*presence, state);
+
+ message = g_value_get_string((GValue *)
+ g_hash_table_lookup((GHashTable *)
+ value, "message"));
+ iso_logger( "%s%s", "message : ", (const gchar *)message );
+
+ send_presence_to_client((const gchar *)key, message );
+
+ if (*presence) {
+ g_object_unref (*presence);
+ }
+
+ iso_logger( "%s", "Out - telepathy_presences_foreach\n" );
+
+}
+
+/*! /brief This function will be called for each contact. Contact name is
+ * got from the contcat handle, telepathy_presences_foreach is called
+ * to get the presence from value of the hash table
+ *
+ * @param key : hash table key ie contact handle id
+ * @param value : hash table value ie presence
+ * @return : void
+ */
+static void
+telepathy_presence_handle_foreach (gpointer *key,
+ gpointer *value)
+{
+ gint handle_id;
+ GHashTable *presences_hash;
+ GValue *gvalue;
+ GObject *presence;
+ gchar **handle_name = NULL;
+ GArray *handles;
+ GError *error = NULL;
+
+ handle_id = GPOINTER_TO_INT(key);
+
+ iso_logger( "%s", "In - telepathy_presence_handle_foreach\n" );
+
+ handles = g_array_new (FALSE, FALSE, sizeof (gint));
+ g_array_append_val (handles, handle_id);
+ if(!tp_conn_inspect_handles(DBUS_G_PROXY(globalCon.conn),
+ TP_CONN_HANDLE_TYPE_CONTACT, handles,
+ &handle_name, &error))
+ {
+ iso_logger( "%s%s", "InspectHandle Error: ", error->message );
+ g_clear_error (&error);
+ g_array_free (handles, TRUE);
+ if( handle_name )
+ {
+ g_strfreev (handle_name);
+ }
+ return;
+ }
+
+ if (handle_name)
+ {
+ iso_logger( "%s%s", "handle_name : ", *handle_name );
+ glob_handle_name = *handle_name;
+ }
+
+ gvalue = g_value_array_get_nth((GValueArray *) value, 1);
+
+ presences_hash = (GHashTable *) g_value_get_boxed(gvalue);
+
+ g_hash_table_foreach(presences_hash,
+ (GHFunc) telepathy_presences_foreach, &presence );
+
+ g_clear_error (&error);
+ g_array_free (handles, TRUE);
+ g_strfreev (handle_name);
+
+ iso_logger( "%s", "Out - telepathy_presence_handle_foreach\n" );
+
+}
+
+/*! /brief Registered as a signal for presence updates of
+ * other users. This function will be called whenevr a contact
+ * to whom this user has subscribed for presence changes his
+ * presence state or status message.
+ *
+ * /param proxy : unused
+ * /param handle_hash : hash table containing presence information
+ * as hash value, contact handle as key
+ * /return : void
+ */
+void
+telepathy_presence_handler(DBusGProxy *proxy,
+ GHashTable *handle_hash)
+{
+ GSList *data = NULL;
+ UNUSED_FORMAL_PARAM(proxy);
+ iso_logger( "%s", "In - telepathy_presence_handler\n" );
+ g_hash_table_foreach(handle_hash, (GHFunc) telepathy_presence_handle_foreach, data);
+ iso_logger( "%s", "Out - telepathy_presence_handler\n" );
+
+}
+
+
+/*! /brief sends presence of the client to n/w server thru' gabble
+ * calls telepathy_contacts_send_presence to send presence
+ *
+ * /param msghdr request header that will be passed back to client
+ * /param message_type_err unused
+ * /remark please remove this unused variable(why was this added?)
+ *
+ * /return : error code on failure, 0 on success
+ */
+void send_presence( presence_msg_struct* msg_hdr , gint message_type_err )
+ {
+ TelepathyPresence *presence;
+ TelepathyPresenceState state;
+ UNUSED_FORMAL_PARAM(message_type_err);
+
+ iso_logger( "%s", "In - send_presence\n" );
+
+ //changing own presence status
+ presence = telepathy_presence_new();
+ state = telepathy_telepathy_presence_state_from_str(msg_hdr->useravailability);
+ telepathy_presence_set_state(presence, state);
+
+ //if (msg_hdr->statustext != NULL)
+ telepathy_presence_set_status (presence, msg_hdr->statustext);
+
+ telepathy_contacts_send_presence(DBUS_G_PROXY(globalCon.pres_iface), presence, msg_hdr);
+
+ g_object_unref (presence);
+ iso_logger( "%s", "Out - send_presence\n" );
+ }
+
+/*! /brief parses the message buffer. aPresenceStatus and aStatustext
+ * pointers updated
+ *
+ * /param aMsgBuffer message buffer
+ * /param aPresenceStatus after call to this function it will
+ * have the presence status to be updated
+ * /param aStatustext after call to this function it will
+ * have the status text to be updated
+ *
+ * /param msg_len : msg_len no. of bytes in msg_buf
+ * /return returns error code on failure, or 0
+ */
+int parse_for_presence( gchar* msgbuffer, gchar** presencestatus,
+ gchar** statustext, gint msg_len )
+{
+
+ gint len = 0;
+ gint err=0;
+ gchar *user_availability =NULL;
+ gchar *status_text =NULL;
+
+ iso_logger( "%s", "In - parse_for_presence\n" );
+ //calculating len for request header
+ //skip the msg_hdr part
+ len += sizeof( message_hdr_req );
+
+ // reading a availability from buffer
+ err = parse_a_string( msgbuffer, &user_availability, &len, msg_len );
+ *presencestatus=user_availability;
+ if ( err < 0 )
+ {
+ return err;
+ }
+ // reading a status text
+ err = parse_a_string( msgbuffer, &status_text, &len, msg_len );
+ *statustext=status_text;
+
+iso_logger( "%s", "Out - parse_for_presence\n" );
+// need to check.....
+return 1;
+}
+
+/*! /brief Parses the message from client and sends the presence
+ * to n/w server. A err is returned if there is any parse error
+ * or out of memory condition
+ *
+ * /param buf : buffer to be parsed
+ * /param buf_len : buffer length
+ * /return : error code if any, 0 on success
+ */
+int action_parse_presence( gchar* buf, gint buf_len )
+
+{
+ gchar* presencestatus = NULL;
+ gchar* statustext = NULL;
+ message_hdr_req *msg_hdr = NULL;
+ gint message_type_err = 0;
+ presence_msg_struct* msg_struct = NULL;
+ //parse user availability and status text ..
+ iso_logger( "%s", "In - action_parse_presence\n" );
+ message_type_err = parse_for_presence( buf,
+ &presencestatus,&statustext, buf_len );
+ //if <= 0 there is some error in the message formation
+ if ( message_type_err > 0 )
+ {
+
+ //send message
+ msg_hdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ if ( NULL == msg_hdr )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ memset( msg_hdr, '\0', sizeof( message_hdr_req ) );
+ //read message header from buffer
+ memcpy( msg_hdr, buf, sizeof( message_hdr_req ) );
+
+ //fill the contacts and message into a struct
+ msg_struct = ( presence_msg_struct* ) malloc ( sizeof ( presence_msg_struct ) );
+ if ( NULL == msg_struct )
+ {
+ free ( msg_hdr );
+ return MEM_ALLOCATION_ERROR;
+ }
+ msg_struct->hdr_req = msg_hdr;
+ msg_struct->useravailability = presencestatus;
+ msg_struct->statustext = statustext;
+ //send presence should be called
+ send_presence( msg_struct, message_type_err );
+ }
+
+ //free ( msg_hdr );
+ iso_logger( "%s", "Out - action_parse_send\n" );
+ //return error on failure, or no. of contacts message sent to on success
+ return message_type_err;
+
+
+
+}
+
+
+/*! /brief callback for updating own presence. This function
+ * sends response to client
+ *
+ * /param proxy : unused
+ * /param error : error if any
+ * /param message : message header
+ * /return : void
+ */
+void update_status_cb(DBusGProxy *proxy, GError* error, gpointer userdata)
+{
+
+ int err = 0;
+
+ message_hdr_req* msg_hdr = ( message_hdr_req* ) userdata;
+ // create the msg queue
+ //user data is of type message_hdr_req
+ iso_logger( "%s", "In - update_status_cb\n" );
+ UNUSED_FORMAL_PARAM(proxy);
+ if ( NULL != error )
+ {
+ //There was some error
+ //send the response for the msg_hdr request to client
+ err = send_response_to_client( msg_hdr, error->code, 0 );
+ }
+ else
+ {
+ //send the response for the msg_hdr request to client
+ err = send_response_to_client( msg_hdr, 0, 1 );
+ }
+
+ //free( msg_hdr );
+
+ if ( err < 0 )
+ {
+ // failed to deliver
+ iso_logger( "%s", "failed to deliver\n" );
+ }
+ iso_logger( "%s", "Out - update_status_cb\n" );
+
+}
+
+
+/*! /brief Sends presence of conatct to the client. Forms
+ * the proper presence message format and sends that to client
+ *
+ * /param : availability user availability
+ * /param : text custom status message set by user
+ * /return : error code on failure, 0 on success
+ */
+int send_presence_to_client( const gchar *availability , const gchar *text )
+ {
+ int len=0;
+ int pri = MSG_PRI_NORMAL;
+ char rmsg[MAX_MSG_SIZE];
+ int index = 0;
+ int err;
+ message_hdr_resp* msg_resp = NULL;
+ int result = 0;
+ int timeout = NO_WAIT;
+
+ iso_logger( "%s", "In - send_presence_to_client\n" );
+
+ msg_resp = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ if ( NULL == msg_resp )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ memset( msg_resp, '\0', sizeof( message_hdr_resp ) );
+ memset( msg_resp, '\0', sizeof( message_hdr_resp ) );
+ msg_resp->hdr_req.message_type = EPresenceNotification;
+ msg_resp->hdr_req.protocol_id = 1;
+ msg_resp->hdr_req.session_id = 1;
+ msg_resp->hdr_req.request_id =1;
+ msg_resp->response = 1;
+ msg_resp->error_type = 0;
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memcpy( rmsg, msg_resp, sizeof( message_hdr_resp ) );
+ index += sizeof( message_hdr_resp );
+ //putting sender in message queue
+ len = strlen(glob_handle_name);
+ strcpy( rmsg + index, glob_handle_name );
+ index += len + 1;
+ //putting user availability
+ len = strlen(availability);
+ strcpy( rmsg + index, availability );
+ index += len + 1;
+ // puttin status text
+ len = strlen(text);
+ strcpy( rmsg + index, text );
+ index += len + 1;
+ result = MsgQSend( RESPONSE_QUEUE, rmsg, index,
+ pri, timeout, &err);
+
+ free ( msg_resp );
+ if(result<0)
+ {
+ return FALSE;
+ }
+
+
+ iso_logger( "%s", "message is:\n");
+ iso_logger( "%s", "Out - send_presence_to_client\n" );
+
+ return TRUE;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isosearch.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,634 @@
+/*
+* ============================================================================
+* Name : isosearch.c
+* Part of : isolation server.
+* Version : %version: 17 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+/*! \file
+* Impliments the functions in isosearch.h
+*/
+
+/*! \def For malloc
+*/
+#include <stdlib.h>
+
+/*! \def For string operations
+*/
+#include <string.h>
+
+/*! \def For GHashTable
+*/
+#include <glib/ghash.h>
+
+/*! \def For search related declarations
+*/
+#include "isosearch.h"
+
+/*! \def For globalCon
+*/
+#include "isoservermain.h"
+
+/*! \def For tp_chan_type_search_async
+*/
+#include "tp-chan-type-search-gen.h"
+
+/*! \def For MSG_PRI_NORMAL
+*/
+#include "msgqlib.h"
+
+/*! \def For message_hdr_req
+*/
+#include "isoutils.h"
+
+/*! \def For RESPONSE_QUEUE
+*/
+#include "msgliterals.h"
+
+/*! \struct key_value_struct isoserach.h
+* \brief This struct is used for to form the msg buffer that will be sent to client
+* \var msg As the key/value pairs are read those will be appended to msg
+* \var len is the no. of bytes appended to msg
+*/
+struct key_value_struct
+ {
+ gchar* msg;
+ gint len;
+ };
+
+/*! \typedef struct key_value_struct to key_value_struct
+*
+*/
+typedef struct key_value_struct key_value_struct;
+
+
+static void search_result_received_cb ( DBusGProxy *proxy,
+ guint contact_handle,
+ GHashTable *values,
+ gpointer user_data
+ );
+
+static void search_state_changed_cb ( DBusGProxy *proxy,
+ guint search_state,
+ gpointer user_data
+ );
+
+static void searchreply_cb( DBusGProxy *proxy, GError *error, gpointer userdata );
+
+
+static void do_search_again( GHashTable* search_hash );
+
+
+
+/*! \brief This function called by action_parse_search parses rmsg and
+* validates the arguments(key/value pairs). If value for any key found missing
+* returns INVALID_PARAMETERES
+*
+* \param rmsg Message which is parsed
+* \param rmsg_len message len
+* \param search_hash parsed key/value pairs are filled into this hash table
+*
+* \return error if any else 0
+*/
+gint parse_for_search( gchar* rmsg, gint rmsg_len, GHashTable* search_hash )
+ {
+ gint pointer_nav = 0;
+ gchar* value_str = NULL;
+ gchar* key_str = NULL;
+ gint err = 0;
+ GValue *value = NULL;
+
+ iso_logger( "in parse_for_search");
+ //Skip the header field
+ pointer_nav += sizeof( message_hdr_req );
+
+ while ( '\0' != *( rmsg + pointer_nav ) && pointer_nav < rmsg_len )
+ {
+ //Copy the key
+ err = parse_a_string( rmsg, &key_str, &pointer_nav, rmsg_len );
+ if ( err < 0 )
+ {
+ //if error, return error
+ return err;
+ }
+ //End of message reached and no value found for
+ //corresponding key
+ if ( '\0' == *( rmsg + pointer_nav ) )
+ {
+ return INVALID_PARAMETERES;
+ }
+ //Copy the value
+ err = parse_a_string( rmsg, &value_str, &pointer_nav, rmsg_len );
+ if ( err < 0 )
+ {
+ //if error, return error
+ return err;
+ }
+
+ value = g_new0( GValue, 1 );
+ g_value_init( value, G_TYPE_STRING );
+ g_value_set_string ( value, value_str );
+
+
+ //insert the key value pair into the hash table
+ g_hash_table_insert ( search_hash, key_str, value );
+ }
+ iso_logger( "out parse_for_search");
+ return 0;
+ }
+
+/*! \brief This function is called as a callback to search chan request
+* This function creates a search channel and interface which are
+* used for subsequent search requests. Logically this function is called
+* only once per login session.
+* \remark Not creating a search channel each time is a workaround
+*
+* \param proxy unused
+* \param chan_object_path channel object path to create a new channel
+* \param error if any
+* \param user_data hash table entry(key/value pair)
+*
+* \return void
+*/
+
+ void do_search_reply( DBusGProxy *proxy, char *chan_object_path,
+ GError *error, gpointer user_data )
+ {
+ GHashTable *search_hash = ( GHashTable* ) user_data;
+ TpChan *search_chan = NULL;
+ DBusGProxy *search_iface = NULL;
+
+
+ UNUSED_FORMAL_PARAM( proxy );
+
+ iso_logger( "in do_search_reply");
+ /* Create the object to represent the channel */
+ if ( error )
+ {
+ iso_logger( "Error in do_search_reply");
+ //There was an error.. send it to client
+ send_response_to_client( globalCon.search_hdr_req, error->code, 0 );
+ //Should error be returned to the client ?
+ return;
+ }
+ search_chan = tp_chan_new( globalCon.dbusConn, globalCon.connmgr_bus, chan_object_path,
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH, TP_CONN_HANDLE_TYPE_NONE, 0 );
+
+ globalCon.search_chan = search_chan;
+
+ g_free(chan_object_path);
+
+
+ if ( NULL == search_chan )
+ {
+ iso_logger( "returning because of search_chan");
+ //search chan not created
+ //sending to client
+ send_response_to_client( globalCon.search_hdr_req, TP_SEARCH_CHAN_ERROR, 0 );
+ return ;
+ }
+ //Get chan interface
+ search_iface = tp_chan_get_interface( search_chan,
+ TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK );
+
+ if ( NULL == search_iface )
+ {
+ iso_logger( "returning because of search_iface");
+ //interface for search chan not created
+ //send that to client
+ send_response_to_client( globalCon.search_hdr_req, TP_SEARCH_IFACE_ERROR, 0 );
+ return ;
+ }
+
+ //Register for the SearchResultReceived signal
+ //ownership of the srch_result->user_data is transfered
+ dbus_g_proxy_connect_signal( search_iface, "SearchResultReceived",
+ G_CALLBACK( search_result_received_cb ),
+ NULL, NULL );
+
+
+ //Register for the SearchStateChanged signal
+ dbus_g_proxy_connect_signal( search_iface, "SearchStateChanged",
+ G_CALLBACK( search_state_changed_cb ),
+ NULL , NULL );
+ //Call the search on tp
+ tp_chan_type_search_async( search_iface, search_hash , searchreply_cb,
+ NULL );
+
+ iso_logger( "out do_search_reply");
+
+
+ }
+
+
+/*! \brief This function is called by action_parse_search to search for fields
+* \remark This function routes the searches to do_search_again if searched more
+* than once. This is a workaround because we are getting the signal callbacks
+* 'n'ths( where n is nth search ) time if search channel is created each time.
+*
+* \param search_hash Hash table having the search key and value pairs to be searched
+*
+* \return void
+*/
+
+gint do_search( GHashTable* search_hash )
+ {
+
+ iso_logger( "in do_search");
+
+ if(globalCon.search_chan == NULL)
+ {
+ tp_conn_request_channel_async( DBUS_G_PROXY( globalCon.conn ),
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH,
+ TP_CONN_HANDLE_TYPE_NONE, 0, TRUE,
+ do_search_reply, (gpointer)search_hash ) ;
+ }
+
+ else
+ {
+ iso_logger( "calling do_search_again");
+ do_search_again(search_hash);
+ }
+ iso_logger( "out do_search");
+
+ return 0;
+ }
+
+/*! \brief This function is called if search is done more than once in same login session.
+* \remark This is a workaround because we are getting the signal callbacks
+* 'n'ths( where n is nth search ) time.
+*
+* \param search_hash Hash table having the search key and value pairs to be searched
+*
+* \return void
+*/
+void do_search_again( GHashTable* search_hash )
+ {
+
+ DBusGProxy *search_iface = NULL;
+
+ iso_logger( "in do_search_again");
+
+ if ( NULL == globalCon.search_chan )
+ {
+ iso_logger( "returning because of search_chan");
+ //search chan not created
+ //sending to client
+ send_response_to_client( globalCon.search_hdr_req, TP_SEARCH_CHAN_ERROR, 0 );
+ return ;
+ }
+ //Get chan interface
+ search_iface = tp_chan_get_interface( globalCon.search_chan,
+ TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK );
+
+ if ( NULL == search_iface )
+ {
+ iso_logger( "returning because of search_iface");
+ //interface for search chan not created
+ //send that to client
+ send_response_to_client( globalCon.search_hdr_req, TP_SEARCH_IFACE_ERROR, 0 );
+ return ;
+ }
+
+
+ //Call the search on tp
+ tp_chan_type_search_async( search_iface, search_hash, searchreply_cb,
+ NULL );
+
+ iso_logger( "out do_search_again");
+
+
+ }
+
+
+/*
+! /brief This function is called by message_send_recv function in isoservermain.c if message type
+* is ESearch. This function parses the rmsg, validates the parameter passed, if parameters are
+* correct a search performed for them. else INVALID_PARAMETERES error is returned
+*
+* /param rmsg message buffer to be parsed
+* /param rmsg_len the length of the rmsg
+* /remark rmsg_len is not strlen(rmsg)
+* /return returns error code or 0 on success
+*/
+gint action_parse_search( gchar* rmsg, gint rmsg_len )
+ {
+
+ gint err = 0;
+ GHashTable* search_hash = NULL;
+ message_hdr_req* hdr_req = NULL;
+ //Allocate memory and set the memory to '\0'
+ iso_logger( "in action_parse_search");
+ hdr_req = ( message_hdr_req* ) malloc ( sizeof ( message_hdr_req ) );
+
+ if ( NULL == hdr_req )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ memset( hdr_req, '\0', sizeof( message_hdr_req ) );
+ //Copy the header into message struct
+ memcpy( hdr_req, rmsg, sizeof( message_hdr_req ) );
+ //Create the hash table
+ search_hash = g_hash_table_new( g_str_hash, g_str_equal );
+ if ( NULL == search_hash )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ //Parse the key value pairs to be searched into the hash
+ err = parse_for_search( rmsg, rmsg_len, search_hash );
+ if ( !err )
+ {
+ //Do the search on the fields
+ globalCon.search_hdr_req = hdr_req;
+ err = do_search( search_hash );
+ }
+ iso_logger( "out action_parse_search");
+
+ return err;
+ }
+
+/*! \brief This function is called by search_results_recieved for each key/value
+* pair of search result(one entry). This function appends the key/value pair
+* to the message buffer in the key_value_struct(.msg) and increments
+* the no. of bytes written to(key_value_struct.len)
+*
+* Format of response header(msg buffer)
+* key1\0value1\0key2\0value2\0(key3\0value3\0) (3rd round append)
+*
+* \param key one field of the search entry
+* \param value value for the above field
+* \param user_data unused
+*
+* \return void
+*/
+
+void key_value_store( gpointer key, gpointer value, gpointer user_data )
+ {
+
+ key_value_struct* pairs = ( key_value_struct * ) user_data;
+ GValue* value1 = ( GValue* ) value;
+ const gchar *value_str = NULL;
+ const gchar *key_str = ( gchar* ) key;
+
+ iso_logger( "in key_value_store");
+
+ value_str = g_value_get_string ( value1 );
+
+ if ( '\0' == *value_str )
+ {
+ iso_logger( "No value");
+ return;
+ }
+
+ iso_logger( "key is %s", key_str );
+ //copy The results key part
+ strcpy( pairs->msg + pairs->len, key_str );
+ pairs->len += strlen( key_str ) + 1;
+
+ iso_logger( "value is %s", value_str );
+ //copy The results value part
+ strcpy( pairs->msg + pairs->len, value_str );
+ pairs->len += strlen( value_str ) + 1;
+ iso_logger( "out key_value_store");
+ }
+
+
+/*!
+* \brief This function is called when the search results are recieved
+* This function is called for each contact found matching the
+* search criteria.
+*
+* \param proxy unused
+* \param contact_handle unused
+* \param results Key value pair of one search result entry
+* \param user_data unused
+*
+* \return void
+*/
+static void search_result_received_cb ( DBusGProxy *proxy,
+ guint contact_handle,
+ GHashTable *results,
+ gpointer user_data
+ )
+ {
+ message_hdr_resp hdr_resp;
+ //Get the header request
+
+ message_hdr_req* hdr_request = globalCon.search_hdr_req;
+ key_value_struct pairs;
+
+ gint pri = MSG_PRI_NORMAL;
+ gint result = 0;
+ gint timeout = NO_WAIT;
+ gint err = 0;
+
+ //Create the handle
+ iso_logger( "in search_result_received_cb");
+
+ UNUSED_FORMAL_PARAM( proxy );
+ UNUSED_FORMAL_PARAM( contact_handle );
+ UNUSED_FORMAL_PARAM( user_data );
+
+ if ( g_hash_table_size( results ) <= 0 )
+ {
+ iso_logger( "No results recieved");
+ return;
+ }
+
+ iso_logger("search result count for hash table %d",
+ g_hash_table_size( results ) );
+ iso_logger("contact handle is %d",
+ contact_handle );
+
+ //Create the response header to be sent to client
+ //Copy the message header request
+ //Not copying from hdr req because it could have been modified
+ //in search_state_changed_cb
+ hdr_resp.hdr_req.message_type = ESearch;
+ hdr_resp.hdr_req.protocol_id = hdr_request->protocol_id;
+ hdr_resp.hdr_req.request_id = hdr_request->request_id;
+ hdr_resp.hdr_req.session_id = hdr_request->session_id;
+ //set continue flag
+ hdr_resp.continue_flag = 0;
+ hdr_resp.error_type = 0;
+ hdr_resp.response = 1;
+ //Allocate memory for the message and set memory to '\0'
+ pairs.msg = ( gchar* ) malloc ( MAX_PARAM_LEN );
+ if ( NULL == pairs.msg )
+ {
+ iso_logger( "malloc error @ pairs.msg" );
+ return ;
+ }
+ memset( pairs.msg, '\0', MAX_PARAM_LEN );
+ pairs.len = 0;
+ //Copy the response
+ memcpy( pairs.msg, &hdr_resp, sizeof ( message_hdr_resp ) );
+ pairs.len += sizeof( message_hdr_resp );
+ //Copy the contact name
+ iso_logger( "%s%d", "message type in search_result_received_cb", hdr_request->message_type );
+
+
+ iso_logger( "%s", "start -------------------------------------------------" );
+
+ iso_logger( "%s", "contacts key value pair start" );
+
+ //Copy all the key/value pairs :
+ //no need to check for size here as it is already done at top
+ g_hash_table_foreach ( results, key_value_store, &pairs );
+
+ iso_logger( "%s", "end -------------------------------------------------" );
+
+ //End the message with a '\0'
+ pairs.len += 1;
+ pairs.msg[pairs.len] = '\0';
+ //Send the message to client
+ result = MsgQSend( RESPONSE_QUEUE, pairs.msg, pairs.len,
+ pri, timeout, &err );
+
+ if ( result < 0 )
+ {
+
+ }
+
+ //Free the hash table itself
+ g_hash_table_destroy ( results );
+
+ iso_logger( "in search_result_received_cb");
+ }
+
+/*! \brief This function is a callback registered to searchstatechanged signal.
+* This function is called by telepathygabble when status of the search is changed.
+*
+* \param proxy unused
+* \param search_state state of the search
+* \param user_data unused
+*
+* \return void
+*/
+static void search_state_changed_cb ( DBusGProxy *proxy,
+ guint search_state,
+ gpointer user_data
+ )
+ {
+
+ gint err = 0;
+ //Get the header request
+
+ iso_logger( "in search_state_changed_cb");
+
+ UNUSED_FORMAL_PARAM( proxy );
+ UNUSED_FORMAL_PARAM( user_data );
+
+
+ if ( 1 == search_state && globalCon.search_hdr_req )
+ {
+ globalCon.search_hdr_req->message_type = ESearch_State_During;
+ err = send_response_to_client( globalCon.search_hdr_req, 0, 1 );
+ if ( err )
+ {
+ iso_logger( " 1 == search_state Error sending to client");
+ //?
+ }
+ }
+ else if ( TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER == search_state
+ && globalCon.search_hdr_req )
+ {
+ globalCon.search_hdr_req->message_type = ESearch_State_Finished;
+ err = send_response_to_client( globalCon.search_hdr_req, 0, 1 );
+ if ( err )
+ {
+ iso_logger( "Error sending to client");
+ //?
+ }
+ //Since the search is finished delete the hdr request
+ free ( globalCon.search_hdr_req );
+ globalCon.search_hdr_req = NULL;
+ }
+
+
+ iso_logger( "out search_state_changed_cb");
+ }
+
+/*! \brief Function called by telepathygabble when search channel is closed
+* This function is regisered when calling the async function to close channel
+*
+* \param proxy unused
+* \param error Error if any
+* \param user_data unused
+*
+* \return void
+*/
+void search_chan_closed_cb ( DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data
+ )
+ {
+ iso_logger( "in search_chan_closed_cb");
+ UNUSED_FORMAL_PARAM( proxy );
+ UNUSED_FORMAL_PARAM( error );
+ UNUSED_FORMAL_PARAM( user_data );
+ g_object_unref(globalCon.search_chan);
+ globalCon.search_chan = NULL;
+ iso_logger( "out search_chan_closed_cb");
+ }
+
+/*! \brief Function called by telepathygabble when search request is sent to server.
+* This function is can be thought of as an ack for search request from server.
+*
+* \param proxy unused
+* \param error Network error if any
+* \param user_data unused
+*
+* \return void
+*/
+static void searchreply_cb( DBusGProxy *proxy, GError *error, gpointer userdata )
+ {
+
+
+ iso_logger( "in searchreply_cb" );
+ UNUSED_FORMAL_PARAM( proxy );
+ UNUSED_FORMAL_PARAM( userdata );
+
+ if ( error )
+ {
+
+ iso_logger( "Error!!!!!" );
+ //err cant be handled as of now/this is a special case
+ //where mem alloc is not possible when sending to client..
+ send_response_to_client( globalCon.search_hdr_req, error->code, 0 );
+
+ tp_chan_close_async( DBUS_G_PROXY( globalCon.search_chan ),
+ search_chan_closed_cb, NULL );
+ //Header request is deleted only in case of error
+ //Because the search_state_finished_cb will not be called
+ //In othr cases ownership of user_data is with search_state_finished_cb
+
+ free ( globalCon.search_hdr_req );
+ globalCon.search_hdr_req = NULL;
+ }
+
+ iso_logger( "out searchreply_cb");
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isoservermain.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,496 @@
+/*
+* ============================================================================
+* Name : isoservermain.c
+* Part of : isolation server.
+* Version : %version: 33 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+#include <glib.h>
+
+#include <gtypes.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <errno.h>
+#include "msgqlib.h"
+#include "msg_enums.h"
+#include "msgliterals.h"
+#include "isoservermain.h"
+#include "isoim.h"
+#include "isoconnectionmanager.h"
+#include "isomodifycontactlist.h"
+#include "isoutils.h"
+#include "isopresence.h"
+#include "isoutils.h"
+#include "isoavtar.h"
+#include "isosearch.h"
+#include "isogetsearchkeys.h"
+#include "isofetchcontactlist.h"
+
+/*! \file
+* Impliments the functions in isoservermain.h
+*/
+
+/*! \def Thread stack size
+*/
+#define THREAD_STACK_SIZE 26000
+
+/*! \var mainloop_struct global variable having a pointer to mainloop
+*/
+globalMainloop mainloop_struct;
+
+/*! \var globalCon one object per login session
+*/
+userConnection globalCon;
+
+
+/*! /brief This message reads message type from the message buffer
+* passed as argument
+*
+* /var pc message buffer
+*
+* /return pointer to message header response which has the message type
+*/
+message_hdr_resp* read_message_type( gchar* buf )
+ {
+
+ message_hdr_resp *msg_hdr = NULL;
+ iso_logger( "%s", "In - read_message_type\n" );
+ //allocate memory and check for error
+ msg_hdr = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ if ( NULL == msg_hdr )
+ {
+ return NULL;
+ }
+ //initialze memory to 0
+ memset( msg_hdr, '\0', sizeof( message_hdr_resp ) );
+ //read message request header from buffer
+ memcpy( msg_hdr, buf, sizeof( message_hdr_req ) );
+ iso_logger( "%s", "Out - read_message_type\n" );
+ //return message header read from buffer
+ return msg_hdr;
+ }
+
+/*! /brief This is an entry point to the thread. isoserver.exe
+* creates a thread which runs a mainloop. mainloop is passed as
+* argument to the thread entry function. This mainloop which is
+* run in the thread listens for the events from telepathygabble
+*
+* /var data unused param
+*/
+gpointer thread_entry( gpointer data )
+ {
+ UNUSED_FORMAL_PARAM(data);
+ //wait till status_changed_cb to happen
+ //The only main loop is run in a thread..
+ iso_logger( "%s", "In - thread_entry\n" );
+ //run the mainloop in thread..
+ g_main_loop_run( mainloop_struct.mainloop );
+ iso_logger( "%s", "Out - thread_entry\n" );
+ return NULL;
+ }
+
+/*! /brief If there are any parse error, this function is called to
+* dispatch the error to client.
+*
+* /param msg_struct The response header to be sent
+* /param err Error
+*/
+gint send_error( message_hdr_resp* msg_struct, gint err )
+ {
+ int result = 0;
+ int pri = MSG_PRI_NORMAL;
+ int timeout = NO_WAIT;
+ int error = 0;
+
+ //set the error and reason
+ msg_struct->error_type = err;
+ //Since this is method to send error
+ //response is always 0
+ msg_struct->response = 0;
+
+ //request has fialed send appr. response
+ result = MsgQCreate( RESPONSE_QUEUE, MAX_MSG_Q_SIZE, MSG_Q_FIFO, &error );
+ if ( ERROR == result )
+ {
+ //graceful exit?
+ return ERROR;
+ }
+
+ //send message created to client
+ result = MsgQSend( RESPONSE_QUEUE, (void*)msg_struct, sizeof( message_hdr_resp ),
+ pri, timeout, &error );
+
+ if( result != 0 )
+ {
+ // msg deliver falied
+ return MSG_Q_SEND_FAILED;
+ }
+ return 0;
+ }
+
+/*! /brief This function waits for the requests from the client.
+* Requests are parsed, validated and appropriate actions taken.
+* A new thread is created when login happens. This function runs
+* a while loop which is only quit when a kill request is recieved
+* from the client.
+*
+* /remark should this thread be created before login?
+* /remark when is the mainloop quit ? (Should that be after logout or
+* after getting a kill request from the client)
+*/
+int message_send_recv()
+ {
+
+ int err = 0;
+ int result = 0;
+ int timeout1 = TIME_OUT; // block for 100 ms
+ char rmsg[MAX_MSG_SIZE]; // 1024 bytes
+ GMainLoop* mainloop = NULL;
+ GThread* join1 = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ GArray* avtarcontent = NULL;
+
+ globalCon.conn_stat = disconnected;
+ globalCon.logout_flag = 0;
+
+ /* Try to Create queueOne again, this will create the queue again,
+ this will just return as its already created by main thread */
+ iso_logger( "%s", "In - message_send_recv\n" );
+
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE, MSG_Q_FIFO, &err);
+
+ //logic here to accept multiple clients
+ mainloop = g_main_loop_new ( NULL, FALSE ); //global mainloop
+
+
+ if ( ERROR == result || NULL == mainloop )
+ {
+ return ERROR;
+ }
+
+ mainloop_struct.mainloop = mainloop;
+
+ while( 1 )
+ {
+
+ //initalize memory to 0
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ // Receive Message from queueTwo
+ result = MsgQReceive(REQUEST_QUEUE, rmsg, MAX_MSG_SIZE, timeout1, &err);
+
+ //MRT bug - 4 more bytes recieved than sent..
+ result -= 4;
+
+
+ //The message should be atleast of size msg_hdr_req
+ //sizeof should be type casted to gint
+ //coz when comparing gint and guint(sizeof return value)
+ //gint is converted to guint
+ if( result >= ( gint )sizeof( message_hdr_req ) )
+ {
+ gboolean stat_err = FALSE;
+ // read message header and get type..
+ msg_struct = read_message_type( rmsg );
+ if ( NULL == msg_struct )
+ {
+ //needs to be discussed what can be done..
+ //should exit from here?
+ return MEM_ALLOCATION_ERROR;
+ }
+ switch( globalCon.conn_stat )
+ {
+ case connected:
+ {
+ //switch to the message type, where action to be performed
+ //is decided dpending on the message type
+ switch ( msg_struct->hdr_req.message_type )
+ {
+
+ case ESend_Request:
+ {
+ iso_logger( "%s", "In - ESend_Request\n" );
+ //parse the request and
+ // send the request to telepathy
+ err = action_parse_send( rmsg, result );
+ if ( err < 0 )
+ {
+ //Send request has failed..
+ //send the error code to the client
+ send_error( msg_struct, err );
+ }
+
+ break;
+ }
+ case EUpdateOwnPresence:
+ {
+ iso_logger( "%s", "In - EUpdateOwnPresence\n" );
+ //parse the request and
+ // send the request to telepathy
+ err = action_parse_presence( rmsg, result );
+ if ( err < 0 )
+ {
+ //Send request has failed..
+ //send the error code to the client
+ send_error( msg_struct, err );
+ }
+
+ break;
+ }
+ //For accept, add and delete same function does the job
+ //depending on the message type that is passed with rmsg
+ case EReject_Contact_Request:
+
+ case EAccept_Contact_Request:
+
+ case EAdd_Contact_Request:
+
+ case EDelete_Contact_Request:
+ {
+ iso_logger( "%s", "In - modify Contact \n" );
+ //Parse the request for to add contact and
+ //request telepathy to add contact
+ err = action_parse_modify_contact_list( rmsg, result );
+ if ( err < 0 )
+ {
+ //addcontacts has fialed send appr. response
+ send_error( msg_struct, err );
+ }
+
+ break;
+ }
+
+ case ESearch:
+ {
+ iso_logger( "%s", "In - ESearch\n" );
+ //parse the request and
+ // send the request to telepathy
+ err = action_parse_search( rmsg, result );
+ if ( err < 0 )
+ {
+ //Send request has failed..
+ //send the error code to the client
+ iso_logger( "%s %d", "error in - ESearch error code:", err );
+ send_error( msg_struct, err );
+ }
+ break;
+ }
+
+ case ESearch_Get_Keys:
+ {
+ iso_logger( "%s", "In - ESearch_Get_Keys\n" );
+ err = get_search_keys( msg_struct );
+
+ if ( err < 0 )
+ {
+ //Send request has failed..
+ //send the error code to the client
+ iso_logger( "%s %d", "error in - ESearch_Get_Keys error code:", err );
+ send_error( msg_struct, err );
+ }
+
+ break;
+ }
+ case ELogout_Request:
+ {
+ //Message type is to logout
+ iso_logger( "%s", "In - logout\n" );
+ globalCon.conn_stat = disconnecting;
+ action_logout( rmsg );
+ //globalCon.logout_flag = 1;
+ break;
+ }
+ case EUpdateOwnAvtar:
+ {
+ err = update_own_avatar( rmsg,msg_struct,result, &avtarcontent);
+ if ( err < 0 )
+ {
+ //Send request has failed..
+ //send the error code to the client
+ iso_logger( "%s %d", "error in - ESearch_Get_Keys error code:", err );
+ send_error( msg_struct, err );
+ }
+ break;
+ }
+ case EClearOwnAvatar:
+ {
+ err = clear_avatar( &(msg_struct->hdr_req) );
+ if ( err < 0 )
+ {
+ //Send request has failed..
+ //send the error code to the client
+ send_error( msg_struct, err );
+ }
+ break;
+ }
+ case EFetchCachedContacts:
+ fetch_cached_contacts();
+ break;
+
+ default:
+ {
+ iso_logger( "%s", "In - default state is connected\n" );
+ stat_err = TRUE;
+ break;
+ }
+
+ }
+ }
+ break;
+ case disconnected:
+ switch( msg_struct->hdr_req.message_type )
+ {
+ case ELogin_Request:
+ {
+ //parse the message buffer and login
+ iso_logger( "%s", "In - login\n" );
+ //parses the request message and does a login
+ //if all the parameters are correct
+ globalCon.conn_stat = connecting;
+ err = action_parse_login( rmsg, result );
+ //If there is no error in login create a new thread
+ //where mainloop will be run..
+ if ( !err )
+ {
+ //Create a thread for the mainloop to run..
+ //Thread entry does a run on mainloop
+ join1 = g_thread_create_full( thread_entry, mainloop,
+ THREAD_STACK_SIZE, TRUE, FALSE,
+ G_THREAD_PRIORITY_NORMAL , NULL );
+
+
+ }
+ else
+ {
+ //There was some error while loging in.. send the error
+ //to client
+ globalCon.conn_stat = disconnected;
+ send_error( msg_struct, err );
+ }
+ break;
+ }
+
+ default:
+ {
+ iso_logger( "%s", "In - default state is disconnected\n" );
+ stat_err = TRUE;
+ }
+ }
+ break;
+ case not_connected:
+ switch( msg_struct->hdr_req.message_type )
+ {
+ case EKill_Process :
+ {
+ //no need to change the state as anyways it is going to be killed
+ //globalCon.conn_stat = not_connected;
+ globalCon.logout_flag = 1;
+ break;
+ }
+ default:
+ {
+ iso_logger( "%s", "In - default state is not_connected\n" );
+ stat_err = TRUE;
+ }
+ }
+ break;
+ default:
+ {
+ iso_logger( "%s", "In - default state connecting or disconnecting \n" );
+ stat_err = TRUE;
+ break;
+ }
+ }
+ if ( stat_err )
+ {
+ stat_err = FALSE;
+ iso_logger( "%s", "In - stat_err true \n" );
+ send_error( msg_struct, CONNECTION_STATUS_ERROR );
+ }
+ if ( globalCon.logout_flag )
+ {
+ //quit mainloop before exiting the thread and then server
+ //quiting mainloop will inturn make the thread to fall off
+ g_main_loop_quit( mainloop_struct.mainloop );
+ iso_logger( "%s", "logout flag break \n" );
+ break;
+ }
+ free ( msg_struct );
+
+ }
+ else
+ {
+ break;
+ }
+ }
+ iso_logger( "%s", "In - g_thread_join\n" );
+
+
+
+ //join the thread created for to run mainloop before exiting
+ g_thread_join( join1 );
+ iso_logger( "%s", "After this should be after mainloop quit - g_thread_join\n" );
+
+ /* delete message queueOne */
+ result=MsgQDelete( REQUEST_QUEUE, &err );
+
+ iso_logger( "%s", "Out - MsgQDelete\n" );
+ return 0;
+ }
+
+/*! \brief server main process which listens to requests from client
+* and processes those requests. A new thread is created to listen to
+* the events from the telepathygabble.
+*/
+int main()
+ {
+ int err = 0;
+ //FILE *fp = NULL;
+
+ g_type_init();
+
+ g_thread_init( NULL );/*
+ _dbus_setenv("DBUS_VERBOSE","1");
+ fp= freopen("c:\\iso-dbus.txt", "a",stderr);*/
+ iso_logger( "%s", "In - main\n" );
+ //wait in a loop to accept requests from the client
+ //Can mainloop be used instead of waiting in a loop?
+ err = message_send_recv();
+ if ( err != 0 )
+ {
+ printf("exit err code is %d\n", err );
+ }
+ iso_logger( "%s", "Out - main\n" );
+
+ //fclose(fp);
+ return 0;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/isoserver/src/isoutils.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,305 @@
+/*
+* ============================================================================
+* Name : isoutils.c
+* Part of : isolation server.
+* Version : %version: 15 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "isoutils.h"
+#include "msgliterals.h"
+#include "isoservermain.h"
+
+/*! \file
+* Impliments the functions in isoutils.h
+*/
+
+/*! \def Thread stack size
+*/
+#define LOG_FILENAME "c:\\isoserver.txt"
+
+/*! \brief Documented in the header file
+*/
+void iso_logger ( gchar* fmt, ... )
+ {
+ #ifdef _DEBUG
+
+ FILE* fp;
+ //open file to read..
+ fp = fopen( LOG_FILENAME,"a" );
+ if ( fp )
+ {
+ int ival;
+ double dval;
+ char* sval;
+ char* p;
+ va_list list;
+ //initalize the variable arg to fmt..
+ va_start( list, fmt );
+ //Go char by char thru' format string
+ //example format string ("Hi, by %s", str)
+ for ( p = fmt; *p; p++ )
+ {
+ if ( *p != '%' )
+ {
+ //Not format specifiers just print them to file
+ //In example above printe "Hi, by " to file
+ putc( *p, fp );
+ continue;
+ }
+ switch( *++p )
+ {
+ case 'd' :
+ //Next arg got is int
+ //read integer and print to file
+ ival = va_arg( list, int );
+ fprintf( fp, "%d", ival );
+ break;
+
+ case 'f' :
+ //Next arg got is float
+ //read float and print to file
+ dval = va_arg( list, double );
+ fprintf( fp, "%f", dval, fp );
+ break;
+
+ case 's' :
+ //Next arg got is string
+ //read string and go char by char and print to file
+ for ( sval = va_arg( list, char * ); *sval; sval++ )
+ {
+ putc( *sval, fp );
+ }
+ break;
+ case 'u' :
+ //Next arg got is int
+ //read integer and print to file
+ ival = va_arg( list, uint );
+ fprintf( fp, "%u", ival );
+ break;
+ default:
+ break;
+ }
+ }
+ //print a new line
+ fprintf(fp,"\n");
+ //close file
+ fclose(fp);
+ //close the variable arg list
+ va_end( list );
+ }
+ #endif //_DEBUG
+ }
+
+/*! \brief Documented in the header file
+*/
+gint parse_a_string( gchar* msg_buf, gchar** str, gint* len, gint msg_len )
+ {
+ //parsing the buffer into an array of strings(contacts)
+ gint userlen = 0;
+ gchar* users = NULL;
+
+ while( '\0' != *( msg_buf + *len ) && *len < msg_len )
+ {
+ //len is different from userlen
+ //len is total no. of characters read in msg
+ //where as userlen is no. of char read for this contact
+ userlen++;
+ (*len)++;
+ }
+
+ //the string is not present
+ //or,Reached the last byte of parse string and it is not '\0'
+ if ( 0 == userlen ||
+ ( '\0' != *( msg_buf + *len ) && *len == msg_len ) )
+ {
+ //Got parse error..
+ //Invalid message format..
+ return INVALID_PARAMETERES;
+ }
+ //Allocate memory and check for error
+ users = ( gchar* ) malloc ( userlen + 1 );
+ if ( NULL == users )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ memset( users, '\0', userlen + 1 );
+ //copy one contact...
+ memcpy( users, ( msg_buf + *len - userlen ), userlen + 1 );
+ *str = users;
+ (*len)++;
+ //On success return 0
+ return 0;
+ }
+
+/*! \brief Documented in the header file
+*/
+gint parse_into_array_of_strings( gchar* msg_buf, gchar*** contact_ids,
+ gint* len, gint msg_len, gint* cntidscount )
+ {
+ gchar** cntids = NULL;
+ gchar* users = NULL;
+ gint err = 0;
+
+ //to calc MAX_MSG_RECEIPIENTS dynamically one more loop needs to be done
+ //for this
+ //Allocate memory and check for error returns
+ cntids = ( gchar** ) malloc( MAX_MSG_RECEIPIENTS * sizeof( gchar* ) );
+ if ( NULL == cntids )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+ do
+ {
+ //get one string at a time..
+ err = parse_a_string( msg_buf, &users, len, msg_len );
+
+ if ( err < 0 )
+ {
+ return err;
+ }
+ //check if max no of contacts are read..
+ //if not, copy contact into 2D array of strings...
+ //else ignore the extra contacts
+ //do not over run the cntids , incase of
+ //no. of contacts more than max msg recp. @ line 197
+ //cntids[*cntidscount] = NULL;
+ if ( *cntidscount < MAX_MSG_RECEIPIENTS - 1 )
+ {
+ cntids[*cntidscount] = users;
+ ( *cntidscount )++;
+ }
+ else
+ {
+ //users to be freed..ignoring extra no. of recipients
+ free ( users );
+ }
+
+ //increment the no. of contacts..
+
+ //all contacts read break the loop
+ //
+ if ( '\0' == *( msg_buf + *len ) )
+ {
+ break;
+ }
+ //If maximum no. of receipients is reached break
+ //so here of total no. of contacts, message is only sent to
+ //first MAX_MSG_RECEIPIENTS - 1
+ } while( *len < msg_len );
+ cntids[*cntidscount] = NULL;
+
+ /*
+ //Did not find any use of this as of now..
+ //But in case of any mem issues can be looked into
+ if ( *cntidscount < MAX_MSG_RECEIPIENTS )
+ {
+ //realloc is debatable ...
+ cntids = ( char** ) realloc( cntids, ( *cntidscount + 1 ) * sizeof( char* ) );
+ }*/
+ //Assign to contact ids
+ *contact_ids = cntids;
+ (*len)++; //skip the last '\0' ... 2D arrays end with '\0'
+ return 0;
+ }
+
+/*! \brief Documented in the header file
+*/
+void free_msg_args( gchar** contactid, gint contacts_count, gchar* sendmsg )
+ {
+ gint i = 0;
+ //free all the contacts
+ if ( NULL != contactid )
+ {
+ for ( i = 0; i < contacts_count; i++ )
+ {
+ if ( NULL != (contactid)[i] )
+ {
+ free ( (contactid)[i] );
+ }
+ }
+ }
+ //free the message
+ if ( NULL != sendmsg )
+ {
+ free ( sendmsg );
+ }
+ }
+
+/*! \brief Documented in the header file
+*/
+gint send_response_to_client( message_hdr_req* hdr_req, gint error,
+ gboolean response )
+ {
+ int pri = MSG_PRI_NORMAL;
+ gint result = 0;
+ gint err = 0;
+ int timeout = NO_WAIT;
+ message_hdr_resp* msg_struct = NULL;
+
+ result = MsgQCreate( RESPONSE_QUEUE, MAX_MSG_Q_SIZE, MSG_Q_FIFO, &err );
+ if ( ERROR == result )
+ {
+ return ERROR;
+ }
+
+ msg_struct = ( message_hdr_resp* ) malloc ( sizeof( message_hdr_resp ) );
+ if ( NULL == msg_struct )
+ {
+ return MEM_ALLOCATION_ERROR;
+ }
+
+ //intialize memory to 0
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ //Copy the header request into response header..
+ //This req header in resp will be used to map the req to resp.
+ msg_struct->hdr_req.message_type = hdr_req->message_type;
+ msg_struct->hdr_req.protocol_id = hdr_req->protocol_id;
+ msg_struct->hdr_req.session_id = hdr_req->session_id;
+ msg_struct->hdr_req.request_id = hdr_req->request_id;
+
+ //set the error and responses..
+ msg_struct->error_type = error;
+ msg_struct->response = response;
+
+ //send the message to the client
+ result = MsgQSend( RESPONSE_QUEUE, (void*)msg_struct, sizeof( message_hdr_resp ),
+ pri, timeout, &err );
+
+ free ( msg_struct );
+
+ if ( 0 > result )
+ {
+ return MSG_Q_SEND_FAILED;
+ }
+
+ return 0;
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/bwins/opencmessagequeuelibraryu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+ MsgQCheck @ 1 NONAME
+ MsgQClean @ 2 NONAME
+ MsgQCreate @ 3 NONAME
+ MsgQDelete @ 4 NONAME
+ MsgQMaxCheck @ 5 NONAME
+ MsgQReceive @ 6 NONAME
+ MsgQSend @ 7 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/eabi/opencmessagequeuelibraryu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+ MsgQCheck @ 1 NONAME
+ MsgQClean @ 2 NONAME
+ MsgQCreate @ 3 NONAME
+ MsgQDelete @ 4 NONAME
+ MsgQMaxCheck @ 5 NONAME
+ MsgQReceive @ 6 NONAME
+ MsgQSend @ 7 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/*
+* ============================================================================
+* Name : isosearch.c
+* Part of : isolation server.
+* Version : %version: bh1cfmsg#13 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+
+PRJ_PLATFORMS
+ WINSCW ARMV5
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+messagequeuelibrary.mmp
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/group/messagequeuelibrary.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,89 @@
+/*
+* ============================================================================
+* Name : isosearch.c
+* Part of : isolation server.
+* Version : %version: bh1cfmsg#13 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#include<platform_paths.hrh>
+TARGET opencmessagequeuelibrary.dll
+TARGETTYPE DLL
+UID 0x1000008d 0x2001241B
+
+
+CAPABILITY ALL -TCB
+VENDORID VID_DEFAULT
+
+VERSION 10.0
+
+#ifndef WINSCW
+EPOCALLOWDLLDATA
+#endif //WINSCW
+
+#ifdef WINSCW
+MACRO EMULATOR
+#endif
+
+SOURCEPATH ../src
+
+
+/*
+#ifdef WINSCW
+SOURCE mesgq_wsd.cpp
+#endif
+*/
+
+SOURCE msgqcheck.c
+SOURCE msgqclean.c
+SOURCE msgqcreate.c
+SOURCE msgqdelete.c
+SOURCE msgqmaxcheck.c
+SOURCE msgqrecv.c
+SOURCE msgqsend.c
+SOURCE msgqinternals.cpp
+
+
+USERINCLUDE ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+
+
+LIBRARY libc.lib
+
+#ifdef WINSCW
+LIBRARY euser.lib
+LIBRARY ewsd.lib
+#endif
+#ifdef GCCE
+STATICLIBRARY libcrt0_gcce.lib
+#else
+STATICLIBRARY libcrt0.lib
+#endif
+
+
+LANG SC
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqcheck.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,59 @@
+/**
+ * @file MsgQCheck.cpp
+ * Description: Source file for MsgQLib's MsgQCheck API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <msgqinternal.h>
+#include <msgliterals.h>
+
+
+
+/*****************************************************************************
+* MsgQCheck
+* Function: Function for checking how many messages are in a queue
+*******************************************************************************/
+
+EXPORT_C int MsgQCheck(ULONG qName, int* err) {
+
+ int nMsgs;
+ struct msqid_ds qStatus ;
+ int qId;
+
+
+ if((qId = msgget((key_t) qName ,IPC_CREAT | 0666 /*| IPC_EXCL */)) >=0 ) {
+ // get total count of msgs from the msg queue
+ if ((msgctl(qId,IPC_STAT ,&qStatus)) >= 0 ) {
+ nMsgs=qStatus.msg_qnum ;
+ *err = OK;
+ return(nMsgs);
+ }
+ else
+ *err=errno;
+ }
+ else
+ *err = KMsgQLibQIdErr;
+ return(ERROR);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqclean.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,58 @@
+/**
+ * @file MsgQClean.cpp
+ * Description: Source file for MsgQLib's MsgQClean API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <msgqinternal.h>
+
+
+/****************************************************************************
+* MsgQClean (qName, err)
+* Description: Function that empties the specified queue
+*****************************************************************************/
+
+EXPORT_C int MsgQClean(ULONG qName, int* err) {
+
+ char msg[MAX_MSG_LEN];
+ int rcv_err;
+
+ if(( msgget((key_t) qName ,IPC_CREAT | 0666 /*| IPC_EXCL */ )) >=0 ) {
+ // sending a message is not allowed
+ // empty out the queue
+ while(MsgQReceive(qName, msg, MAX_MSG_LEN, IPC_NOWAIT, &rcv_err) != ERROR) {};
+ if (rcv_err == ENOMSG) {
+ *err = OK;
+ return (OK);
+ }
+ else
+ *err = rcv_err;
+ }
+ else
+ *err = KMsgQLibQIdErr;
+
+ return(ERROR);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqcreate-del.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,116 @@
+/**
+ * @file MsgQCreate.cpp
+ * Description: Source file for MsgQLib's MsgQCreate API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <MsgQInternal.h>
+
+
+/********************************************************************************
+* MsgQCreate
+* Description: Creates a message queue
+* Inputs:
+* qName : ULONG that represents the queue name
+* maxMsgs : ULONG that represents maximum size of messages
+*********************************************************************************/
+EXPORT_C int MsgQCreate(ULONG qName, ULONG maxMsgs, ULONG qOptions, int* err) {
+ int qId;
+ //int semId;
+ //int semName ;
+ struct msqid_ds qStatus ;
+ //struct semid_ds sStatus ;
+
+ //union semun {
+ // int val;
+ // struct semid_ds* buf;
+ // ushort_t* array;
+ //} arg ;
+
+ int hashInstErr;
+
+ //if (MsgQTableLookup(qName) != NULL) {
+ // *err = OK;
+ // return (OK);
+ //}
+ //else {
+ if((qOptions == MSG_Q_FIFO) || (qOptions == MSG_Q_PRIORITY)) {
+ // Set msg queue options to FIFO and create the message queue
+ qOptions= MSG_Q_FIFO ;
+
+ if((qId = msgget((key_t) qName ,IPC_CREAT | 0666 | IPC_EXCL )) >=0 ) {
+ // set msg queue parameter max # bytes in queue
+
+ if( msgctl(qId,IPC_STAT,&qStatus) == 0 )
+
+ if( qStatus.msg_qbytes > (maxMsgs * MAX_MSG_LEN) ) {
+ qStatus.msg_qbytes = maxMsgs * MAX_MSG_LEN ;
+ if( msgctl(qId,IPC_SET,&qStatus) < 0) {
+ // delete message queue on error
+ msgctl(qId,IPC_RMID,0);
+ *err = errno;
+ return(ERROR);
+ }
+ }
+ *err = OK;
+ return (OK);
+
+ // create semaphore
+ //semName= (key_t) qName;
+ //if((semId = semget(semName, 1, IPC_CREAT | 0666 |IPC_EXCL )) >= 0 ) {
+ // set the semaphore value
+ // arg.buf = &sStatus;
+ // arg.val = 1;
+ // semctl(semId , 0, SETVAL, arg) ;
+
+ //install queue data in hash table
+ // if(InstallMsqQTable(qName, qId, semId, &hashInstErr) == OK) {
+ // AddToMsgQTable(qName);
+ // *err = OK;
+ // return (OK);
+ // }
+ // else {
+ //delete semaphore on error
+ // semctl(semId,0,IPC_RMID,0) ;
+ // *err = hashInstErr;
+ // }
+ //}
+ //else {
+ // delete message queue on error
+ // msgctl(qId,IPC_RMID,0);
+ // *err = errno;
+ //}
+ }
+ else {
+ *err = errno;
+ }
+ }
+ else
+ *err = KMsgQLibParamErr;
+
+ return(ERROR);
+ //}
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqcreate.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,91 @@
+/**
+ * @file MsgQCreate.cpp
+ * Description: Source file for MsgQLib's MsgQCreate API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <msgqinternal.h>
+#include <msgliterals.h>
+
+
+/********************************************************************************
+* MsgQCreate
+* Description: Creates a message queue
+* Inputs:
+* qName : ULONG that represents the queue name
+* maxMsgs : ULONG that represents maximum size of messages
+*********************************************************************************/
+EXPORT_C int MsgQCreate(ULONG qName, ULONG maxMsgs, ULONG qOptions, int* err) {
+
+
+ UNUSED_FORMAL_PARAM(qName);
+ UNUSED_FORMAL_PARAM(maxMsgs);
+ UNUSED_FORMAL_PARAM(err);
+ if((qOptions == MSG_Q_FIFO) || (qOptions == MSG_Q_PRIORITY)) {
+ // Set msg queue options to FIFO and create the message queue
+ qOptions= MSG_Q_FIFO ;
+
+ if((msgget((key_t) qName ,IPC_CREAT | 0666 | IPC_EXCL )) == -1 ) {
+ if ( errno == 17 ){
+ // message queue already exists
+ // now just get the hanlde to it
+ // no need to leave over here;
+ }
+ }
+
+ if((msgget((key_t) qName ,IPC_CREAT | 0666 )) >=0 ) {
+
+ // set msg queue parameter max # bytes in queue
+
+ /* if( msgctl(qId,IPC_STAT,&qStatus) == 0 )
+
+ if( qStatus.msg_qbytes > (maxMsgs * MAX_MSG_LEN) ) {
+ qStatus.msg_qbytes = maxMsgs * MAX_MSG_LEN ;
+ if( msgctl(qId,IPC_SET,&qStatus) < 0) {
+ // delete message queue on error
+ msgctl(qId,IPC_RMID,0);
+ *err = errno;
+ return(ERROR);
+ }
+ }
+
+ */
+
+ *err = OK;
+ return (OK);
+
+
+ }
+ else {
+ *err = errno;
+ }
+ }
+ else {
+ *err = KMsgQLibParamErr;
+ }
+
+ return(ERROR);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqdelete.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,58 @@
+/**
+ * @file MsgQDelete.cpp
+ * Description: Source file for MsgQLib's MsgQDelete API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <msgqinternal.h>
+
+
+/*******************************************************************************
+* MsgQDelete (qName, err)
+* Description: Function for deleting a message queue
+********************************************************************************/
+
+EXPORT_C int MsgQDelete(ULONG qName, int* err)
+{
+ int qId;
+
+ if((qId = msgget((key_t) qName ,IPC_CREAT | 0666 /*| IPC_EXCL */ )) >=0 ) {
+
+ if (msgctl(qId,IPC_RMID,0) == 0) {
+ *err = OK;
+ return (OK);
+ }
+ else {
+ *err = errno;
+ }
+
+ }
+ else {
+ *err = KMsgQLibQIdErr;
+ }
+
+ return(ERROR);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqinternals.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,236 @@
+/**
+ * @file MsgQInternals.cpp
+ * Description: Source file for MsgQLib
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include <stdlib.h>
+#include <msgqinternal.h>
+#include <e32property.h>
+
+/* Declaration and definition of Internal Functions and data structures */
+#ifdef __WINSCW__
+
+#include <e32std.h>
+typedef void TAny;
+#include <pls.h> // For emulator WSD API
+
+const TUid KMsgQLibUid3 = {0xA0001319};
+
+
+typedef struct {
+ MSGQ_INFO_PTR _MsgQInfo[MSGQ_TBL_SZ];
+ MSGQ_INFO_LIST_PTR _MsgQListHead;
+}MsgQGlobalData;
+
+int InitWSDVar(MsgQGlobalData* p) {
+ p->_MsgQListHead = NULL;
+ return 0;
+}
+MsgQGlobalData* GetGlobal() {
+ // Access the PLS of this process
+ MsgQGlobalData* p = Pls<MsgQGlobalData>(KMsgQLibUid3, &InitWSDVar);
+ return p;
+}
+
+
+MSGQ_INFO_PTR* _MsgQInfo() {
+ //return &(GetGlobal()->_MsgQInfo[0]); // orig code
+ MSGQ_INFO_PTR* p = (GetGlobal()->_MsgQInfo);
+ return p;
+ //return (GetGlobal()->_MsgQInfo); // modified line
+};
+
+MSGQ_INFO_LIST_PTR* _MsgQListHead() {
+ return &(GetGlobal()->_MsgQListHead);
+};
+
+#define MsgQInfo (_MsgQInfo())
+#define MsgQListHead (*_MsgQListHead())
+
+#else
+MSGQ_INFO_PTR MsgQInfo[MSGQ_TBL_SZ];
+MSGQ_INFO_LIST_PTR MsgQListHead = NULL;
+#endif
+
+inline unsigned int HashIndex(ULONG qName);
+
+/*************** INTERNAL FUNCTIONS ******************************/
+
+/***************************************************************************
+* InstallMsqQTable (qName, qid, semId, sendState, numMsgs, err)
+* Function: This function installs a queue into the hash table
+****************************************************************************/
+
+int InstallMsqQTable(ULONG qName, int qId, int semId, int* err) {
+
+ MSGQ_INFO_PTR pMsgQInfo = NULL;
+ unsigned int index;
+
+ if ((pMsgQInfo = MsgQTableLookup(qName)) == NULL) {
+ pMsgQInfo = (MSGQ_INFO_PTR)malloc(sizeof(*pMsgQInfo));
+
+ if(pMsgQInfo != NULL) {
+ index = HashIndex(qName);
+
+ pMsgQInfo->next = MsgQInfo[index];
+ MsgQInfo[index] = pMsgQInfo;
+ pMsgQInfo->qName = qName;
+ pMsgQInfo->qId = qId;
+ pMsgQInfo->semId = semId;
+ pMsgQInfo->sendState = MSG_Q_READY;
+ pMsgQInfo->numMsgs = 0;
+
+ *err = OK;
+ return (OK);
+ }
+ else
+ *err = KMsgQLibNoMemoryErr;
+ }
+ else
+ *err = KMsgQLibQIdErr;
+
+ return(ERROR);
+
+}
+
+
+/******************************************************************************
+* HashIndex
+* Function: This function returns the hash index
+*******************************************************************************/
+
+inline unsigned int HashIndex(ULONG qName) {
+ unsigned int hash_index = (qName % MSGQ_TBL_SZ);
+ //return(qName % MSGQ_TBL_SZ);
+ return hash_index;
+}
+
+
+/************************************************************************
+* MsgQTableLookup (qName)
+* Function: This function finds the block pointer for each queue
+*************************************************************************/
+
+MSGQ_INFO* MsgQTableLookup(ULONG qName) {
+ MSGQ_INFO_PTR pMsgQInfo = NULL;
+
+ for (pMsgQInfo = MsgQInfo[HashIndex(qName)]; pMsgQInfo != NULL; pMsgQInfo = pMsgQInfo->next) {
+ if (qName == pMsgQInfo->qName)
+ return(pMsgQInfo);
+ }
+
+ return(NULL);
+}
+
+
+/*************************************************************************
+* RemoveFromMsqQTable (qName, err)
+* Function: This function removes a queue from the hash table
+**************************************************************************/
+
+
+int RemoveFromMsqQTable(ULONG qName, int* err) {
+ unsigned int index = 0;
+ MSGQ_INFO_PTR prev = NULL;
+ MSGQ_INFO_PTR pMsgQInfo = NULL;
+
+ index = HashIndex(qName);
+ for (pMsgQInfo = MsgQInfo[index]; pMsgQInfo != NULL; pMsgQInfo = pMsgQInfo->next) {
+ if (qName == pMsgQInfo->qName)
+ break;
+ prev = pMsgQInfo;
+ }
+
+ if (pMsgQInfo != NULL) {
+ if (prev == NULL)
+ MsgQInfo[index] = pMsgQInfo->next;
+ else
+ prev->next = pMsgQInfo->next;
+
+ free((void*)pMsgQInfo);
+ *err = OK;
+ return (OK);
+ }
+ else
+ *err = KMsgQLibQIdErr;
+
+ return(ERROR);
+}
+
+
+/************************************************************************
+* AddToMsgQTable (qName)
+* Function: Adding a queue to list
+*************************************************************************/
+
+void AddToMsgQTable(ULONG qName) {
+ MSGQ_INFO_LIST_PTR tempNext;
+
+ if (MsgQListHead != NULL) {
+ /* subsequent entries */
+ tempNext = MsgQListHead->next;
+
+ if ((MsgQListHead->next = (MSGQ_INFO_LIST*)malloc(sizeof(MSGQ_INFO_LIST))) != NULL) {
+ MsgQListHead->next->next = tempNext;
+ MsgQListHead->next->qName = qName;
+ }
+ else
+ MsgQListHead->next = tempNext;
+ }
+ else {
+ if ((MsgQListHead = (MSGQ_INFO_LIST*)malloc(sizeof(MSGQ_INFO_LIST))) != NULL) {
+ MsgQListHead->next = NULL;
+ MsgQListHead->qName = qName;
+ }
+ }
+}
+
+/************************************************************************
+* DeleteFromMsgQTable (qName)
+* Function: removing a queu entry from list
+*************************************************************************/
+
+void DeleteFromMsgQTable(ULONG qName) {
+ MSGQ_INFO_LIST_PTR prev = NULL;
+ MSGQ_INFO_LIST_PTR pMsgQInfo = NULL;
+
+ for (pMsgQInfo = MsgQListHead; pMsgQInfo != NULL; pMsgQInfo = pMsgQInfo->next) {
+ if (qName == pMsgQInfo->qName)
+ break;
+ prev = pMsgQInfo;
+ }
+
+ if (pMsgQInfo != NULL) {
+ /* Check whether prev pointer is null or not. If it is Null, update Head pointer */
+ if( prev == NULL )
+ MsgQListHead = MsgQListHead->next ;
+
+ /* Else update the linked list by removing present node and updating prev next pointer */
+ else
+ prev->next = pMsgQInfo->next;
+
+ /* Now free up the memory used by the present node */
+ free((void*) pMsgQInfo);
+ }
+}
+
+// end of fil
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqmaxcheck.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+/**
+ * @file MsgQMaxCheck.cpp
+ * Description: Source file for MsgQLib's MsgQMaxCheck API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+********************************************************************************************/
+
+#include <_ansi.h>
+#include <msgqinternal.h>
+#include <msgliterals.h>
+
+
+/**************************************************************************
+* MsgQMaxCheck
+* Function: This function checks the maximum number of messages in a
+***************************************************************************/
+
+EXPORT_C int MsgQMaxCheck(ULONG qName, int* err) {
+
+ //if ((pMsgQInfo = MsgQTableLookup(qName)) != NULL) {
+ // *err = OK;
+ // return (pMsgQInfo->maxNumMsgs);
+ //}
+ //else
+ // *err = KMsgQLibQIdErr;
+ UNUSED_FORMAL_PARAM(qName);
+ UNUSED_FORMAL_PARAM(err);
+ return(ERROR);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqrecv.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,76 @@
+/**
+ * @file MsgQRecv.cpp
+ * Description: Source file for MsgQLib's MsgQReceive API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <unistd.h>
+#include <string.h>
+#include <msgqinternal.h>
+
+
+
+/*******************************************************************************
+* MsgQReceive (qName, msg, maxNBytes, timeout, err)
+* Description: Function for receiving a message with internal copy
+********************************************************************************/
+
+EXPORT_C int MsgQReceive(ULONG qName, char* msg, ULONG maxNBytes, int timeout, int* err) {
+ ssize_t rxBytes;
+ int toTicks;
+
+ int qId;
+ struct {
+ long mtype;
+ char mtext[MAX_MSG_LEN];
+ } message;
+
+ /* check parameters */
+
+ if((qId = msgget((key_t) qName ,IPC_CREAT | 0666 /*| IPC_EXCL */ )) >=0 ) {
+
+ toTicks = timeout;
+ message.mtype = 1;
+ /* receive message */
+ if((rxBytes = msgrcv(qId, &message, (size_t)maxNBytes, 1, toTicks)) != -1) {
+ message.mtext[rxBytes-4] = '\0';
+ bcopy(message.mtext, msg, rxBytes);
+
+ *err = OK;
+ return ((ULONG)rxBytes);
+ }
+ else {
+ *err = errno;
+ }
+
+ }
+ else {
+ *err = KMsgQLibQIdErr;
+ }
+
+ return(ERROR);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/messagequeue/src/msgqsend.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,77 @@
+/**
+ * @file MsgQSend.cpp
+ * Description: Source file for MsgQLib's MsgQSend API
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <string.h>
+#include <msgqlib.h>
+
+#include <msgqinternal.h>
+
+/*******************************************************************************
+* MsgQSend (qName, msg, nBytes, priority, timeout, err)
+* Description: Function for sending a message with internal copy
+*********************************************************************************/
+
+EXPORT_C int MsgQSend(ULONG qName, char* msg, ULONG nBytes, ULONG priority, int timeout, int* err)
+{
+ int qId;
+ struct {
+ long mtype;
+ char mtext[MAX_MSG_LEN];
+ } message;
+
+ /* check parameters */
+ if ((priority == MSG_PRI_NORMAL) || (priority == MSG_PRI_URGENT)) {
+
+ if((qId = msgget((key_t) qName ,IPC_CREAT | 0666 /*| IPC_EXCL */ )) >=0 ) {
+
+ if( 1 ) {
+ message.mtype = 1;
+ bcopy(msg, message.mtext, nBytes);
+ message.mtext[nBytes] = '\0';
+
+ if(msgsnd (qId, &message, (size_t)nBytes+4, timeout) == OK) {
+ *err = OK;
+ /* After successfull send, unlock the message queue by using post operation on semaphore.*/
+ return (OK);
+ }
+ else {
+ *err = errno;
+ }
+ }
+ else
+ *err = errno;
+ }
+ else
+ *err = KMsgQLibQIdErr;
+ }
+ else
+ *err = KMsgQLibParamErr;
+
+ return(ERROR);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/rom/isoserver.iby Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* ============================================================================
+* Name : isoserver.iby
+* Part of : isolation server.
+* Version : %version: 1.1.1 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+#ifndef __ISOSERVER_IBY__
+#define __ISOSERVER_IBY__
+
+//Isolation server
+
+file=ABI_DIR\BUILD_DIR\OpenCMessageQueueLibrary.dll SHARED_LIB_DIR\OpenCMessageQueueLibrary.dll
+file=ABI_DIR\BUILD_DIR\IsoServer.exe PROGRAMS_DIR\IsoServer.exe
+
+// mecostub SIS, provides support for SIS upgrading
+//data=DATAZ_\system\install\meco_stub.sis system\install\meco_stub.sis
+
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/bwins/isolationserveru.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/conf/isolationserver.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,478 @@
+// Definitions
+[Define]
+SERVER talk.google.com
+USERNAME meco7777@gmail.com
+PASSWORD meco7778
+RECIPIENT nokiatestlm@gmail.com
+MESSAGE Hello
+SPECIALMESSAGE ***___HELLO++++
+RESOURCE mytest
+BADSERVER talk.gaagle.com
+BADPASSWORD junk123
+BLOCKEDUSER user.block2008@gmail.com
+UNEXISTUSERID isoserver@gmail.com
+MIXEDLETTERUSERNAME MEcO7777@gmail.com
+MAXLENGTHUSERID abcd123456abcd123456abcd123456@gmail.com
+PWD nokia123
+MINLENGTHUSERID ab123d@gmail.com
+NOTADDEDUSER rakesh.harsha@gmail.com
+PROXY_SERVER 172.16.42.135
+PROXY_PORT 8080
+PORT 443
+CONNMGR_BUS org.freedesktop.Telepathy.ConnectionManager.gabble
+CONNMGR_PATH /org/freedesktop/Telepathy/ConnectionManager/gabble
+PROTOCOL jabber
+CONTACT test_isoserver@gmail.com
+MIXCONTACT Test_IsoServer@gmail.com
+INVALIDUSERID ISOSERVER_TEST@gmail.com
+LONGMESSAGE abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
+SERVER_GIZMO chat.gizmoproject.com
+USERNAME_GIZMO testlmnokia@chat.gizmoproject.com
+PASSWORD_GIZMO loudmouth
+
+//dummy string
+DUMMY dummy
+
+//avatar
+AVATARFILEJPEG C:\data\Images\test.jpg
+MIMETYPEJPEG image/jpeg
+AVATARFILEPNG C:\data\Images\test.png
+MIMETYPEPNG image/png
+AVATARFILEGIF C:\data\Images\test.gif
+MIMETYPEGIF image/gif
+AVATARLARGEJPG C:\data\Images\large.jpg
+AVATARLARGEPNG C:\data\Images\large.png
+AVATARLARGEGIF C:\data\Images\large.gif
+AVATARFILEDRM C:\data\Images\drmprotected.jpg
+AVATARFILECORRUPT C:\data\Images\corrupted.jpg
+[Enddefine]
+
+
+[Test]
+title 1.LoginWithCorrectData
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithCorrectData SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 2.LoginWithWrongPassword
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithWrongPassword SERVER USERNAME BADPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 3.LoginWithUnexistUserId
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithUnexistUserId SERVER UNEXISTUSERID BADPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+
+delete isolationserverObj
+[Endtest]
+
+/*
+[Test]
+title 4.LoginWithUnexistServer
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithUnexistServer BADSERVER USERNAME BADPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+*/
+[Test]
+title 5.LoginWithMixedLetterUserId
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithMixedLetterUserId SERVER MIXEDLETTERUSERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 6.LoginWithMaximumLenghtUserId
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithMaximumLenghtUserId SERVER MAXLENGTHUSERID PWD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 7.LoginWithMinimumLenghtUserId
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithMinimumLenghtUserId SERVER MINLENGTHUSERID PWD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 8.LogoutFromServer
+create isolationservertest isolationserverObj
+isolationserverObj LogoutFromServer SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 9.LoginWithBlankUserId
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithBlankUserId SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 10.LoginLogOutWithReapitiveSession
+create isolationservertest isolationserverObj
+isolationserverObj LoginLogOutWithReapitiveSession SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 11.LoginWithCoreectUserIDWithSpace
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithCoreectUserIDWithSpace SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 12.SendMessageToCorrectUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendMessageToCorrectUserID SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 13.SendMaxLenMessageToCorrectUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendMaxLenMessageToCorrectUserID SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 14.SendTextMessageUnExistUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendTextMessageUnExistUserID SERVER USERNAME PASSWORD UNEXISTUSERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 15.SendTextMessageWithSpecialCharacter
+create isolationservertest isolationserverObj
+isolationserverObj SendTextMessageWithSpecialCharacter SERVER USERNAME PASSWORD RECIPIENT SPECIALMESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 16.SendMessageWithBlankUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendMessageWithBlankUserID SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 17.SendBlankMessageToUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendBlankMessageToUserID SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 18.SendSmilyToCorrectUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendSmilyToCorrectUserID SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 19.SendMessageToOfflineContact
+create isolationservertest isolationserverObj
+isolationserverObj SendMessageToOfflineContact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 20.SendContinuousltReapitiveMessage
+create isolationservertest isolationserverObj
+isolationserverObj SendContinuousltReapitiveMessage SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 21.SendTextMessageToBlockedUser
+create isolationservertest isolationserverObj
+isolationserverObj SendTextMessageToBlockedUser SERVER USERNAME PASSWORD BLOCKEDUSER MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+
+[Test]
+title 22.SendTextMessageUserWhoIsNotAddedInContactList
+create isolationservertest isolationserverObj
+isolationserverObj SendTextMessageUserWhoIsNotAddedInContactList SERVER USERNAME PASSWORD NOTADDEDUSER MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 23.MessageReceiveFromUser
+create isolationservertest isolationserverObj
+isolationserverObj MessageReceiveFromUser SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 24.AddExistingContact
+create isolationservertest isolationserverObj
+isolationserverObj AddExistingContact SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 25.ClientSendBlankUserIdForADD
+create isolationservertest isolationserverObj
+isolationserverObj ClientSendBlankUserIdForADD SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 26.AddUnexistingUserID
+create isolationservertest isolationserverObj
+isolationserverObj AddUnexistingUserID SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT UNEXISTUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 27.AddExistingContactWIthSpace
+create isolationservertest isolationserverObj
+isolationserverObj AddExistingContactWIthSpace SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 28.AddContactWhichIsAlreadyAdded
+create isolationservertest isolationserverObj
+isolationserverObj AddContactWhichIsAlreadyAdded SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 29.AddExistingContactWIthMixedLetter
+create isolationservertest isolationserverObj
+isolationserverObj AddExistingContactWIthMixedLetter SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT MIXCONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 30.AddInvalidContactWIthSpecialLetter
+create isolationservertest isolationserverObj
+isolationserverObj AddInvalidContactWIthSpecialLetter SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 31.DeleteExistingContact
+create isolationservertest isolationserverObj
+isolationserverObj DeleteExistingContact SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 32.ClientSendBlankUserIdForDELETE
+create isolationservertest isolationserverObj
+isolationserverObj ClientSendBlankUserIdForDELETE SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 33.DeleteUnexistingUserID
+create isolationservertest isolationserverObj
+isolationserverObj DeleteUnexistingUserID SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT UNEXISTUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 34.DeleteExistingContactWIthSpace
+create isolationservertest isolationserverObj
+isolationserverObj DeleteExistingContactWIthSpace SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 35.DeleteContactWhichIsAlreadyDeleted
+create isolationservertest isolationserverObj
+isolationserverObj DeleteContactWhichIsAlreadyDeleted SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 36.DeleteExistingContactWIthMixedLetter
+create isolationservertest isolationserverObj
+isolationserverObj DeleteExistingContactWIthMixedLetter SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT MIXCONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 37.DeleteInvalidContactWIthSpecialLetter
+create isolationservertest isolationserverObj
+isolationserverObj DeleteInvalidContactWIthSpecialLetter SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 38.UpdatePresenceWithAway
+create isolationservertest isolationserverObj
+isolationserverObj UpdatePresenceWithAway SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 39.UpdatePresenceWithDnd
+create isolationservertest isolationserverObj
+isolationserverObj UpdatePresenceWithDnd SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 40.UpdatePresenceWithAvailable
+create isolationservertest isolationserverObj
+isolationserverObj UpdatePresenceWithAvailable SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 41.UpdatePresenceMultipleTimeInSameSession
+create isolationservertest isolationserverObj
+isolationserverObj UpdatePresenceMultipleTimeInSameSession SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 42.UpdateOnlyStatusText
+create isolationservertest isolationserverObj
+isolationserverObj UpdateOnlyStatusText SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 43.UpdateOnlyUserAvailability
+create isolationservertest isolationserverObj
+isolationserverObj UpdateOnlyUserAvailability SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 44.UpdateOwnPresenceWithBlankData
+create isolationservertest isolationserverObj
+isolationserverObj UpdateOwnPresenceWithBlankData SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 45.UpdateStatusTextWithSpecialCharacter
+create isolationservertest isolationserverObj
+isolationserverObj UpdateStatusTextWithSpecialCharacter SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 46.UpdateStatusTextWithMaxLen
+create isolationservertest isolationserverObj
+isolationserverObj UpdateStatusTextWithMaxLen SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+/*
+[Test]
+title 47.LoginWithInvalidPortAddress
+create isolationservertest isolationserverObj
+isolationserverObj LoginWithInvalidPortAddress SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID
+delete isolationserverObj
+[Endtest]
+*/
+
+[Test]
+title 48.SetOwnAvatarJpeg
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEJPEG AVATARFILEJPEG
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 49.ClearOwnAvatarJpeg
+create isolationservertest isolationserverObj
+isolationserverObj ClearOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 50.SetOwnAvatarPng
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEPNG AVATARFILEPNG
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 51.ClearOwnAvatarPng
+create isolationservertest isolationserverObj
+isolationserverObj ClearOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 52.SetOwnAvatarGif
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEGIF AVATARFILEGIF
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 53.ClearOwnAvatarGif
+create isolationservertest isolationserverObj
+isolationserverObj ClearOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 54.ClearOwnAvatarNull
+create isolationservertest isolationserverObj
+isolationserverObj ClearOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 55.SetOwnAvatarDrm
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEJPEG AVATARFILEDRM
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 56.SetOwnAvatarLargeJpg
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEJPEG AVATARLARGEJPG
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 57.SetOwnAvatarLargePng
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEPNG AVATARLARGEPNG
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 58.SetOwnAvatarLargeGif
+create isolationservertest isolationserverObj
+isolationserverObj SetOwnAvatar SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL DUMMY DUMMY DUMMY DUMMY MIMETYPEGIF AVATARLARGEGIF
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 59.FetchCachedContacts
+create isolationservertest isolationserverObj
+isolationserverObj FetchCachedContacts SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/conf/isolationserver_manual.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,223 @@
+// Definitions
+[Define]
+SERVER talk.google.com
+USERNAME immeco8@gmail.com
+PASSWORD loudmouth
+RECIPIENT nokiatestlm@gmail.com
+MESSAGE Hello
+SPECIALMESSAGE ***___HELLO++++
+RESOURCE mytest
+BADSERVER talk.gaagle.com
+BADPASSWORD junk123
+BLOCKEDUSER user.block2008@gmail.com
+UNEXISTUSERID isoserver@gmail.com
+MIXEDLETTERUSERNAME ImMEco8@gmail.com
+MAXLENGTHUSERID abcd123456abcd123456abcd123456@gmail.com
+PWD nokia123
+MINLENGTHUSERID ab123d@gmail.com
+NOTADDEDUSER rakesh.harsha@gmail.com
+PROXY_SERVER 172.16.42.135
+PROXY_PORT 8080
+PORT 443
+CONNMGR_BUS org.freedesktop.Telepathy.ConnectionManager.gabble
+CONNMGR_PATH /org/freedesktop/Telepathy/ConnectionManager/gabble
+PROTOCOL jabber
+CONTACT test_isoserver@gmail.com
+MIXCONTACT Test_IsoServer@gmail.com
+INVALIDUSERID ISOSERVER_TEST@gmail.com
+LONGMESSAGE abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
+SERVER_GIZMO chat.gizmoproject.com
+USERNAME_GIZMO testlmnokia@chat.gizmoproject.com
+PASSWORD_GIZMO loudmouth
+
+//Search strings
+GIVEN_NAME first_name
+FULL_NAME fn
+MIDDLE_NAME last_name
+JID jid
+
+[Enddefine]
+
+
+
+
+[Test]
+title 1..MessageReceiveFromUser
+create isolationservertest isolationserverObj
+isolationserverObj MessageReceiveFromUser SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 2.HandelingPresenceNotification
+create isolationservertest isolationserverObj
+isolationserverObj HandelingPresenceNotification SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 3.LoginWhenTGAndDDAreNotRunning
+create isolationservertest isolationserverObj
+isolationserverObj LoginWhenTGAndDDAreNotRunning SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 4.AcceptAddRequestFromUser
+create isolationservertest isolationserverObj
+isolationserverObj AcceptAddRequestFromUser SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 5.RejectAddRequestFromUser
+create isolationservertest isolationserverObj
+isolationserverObj RejectAddRequestFromUser SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 6.SendAcceptRequestWithoutAnyUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendAcceptRequestWithoutAnyUserID SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 7.SendRejectRequestWithoutAnyUserID
+create isolationservertest isolationserverObj
+isolationserverObj SendRejectRequestWithoutAnyUserID SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+//this functionality is not there
+[Test]
+title 8.SendTextMessageToUserIdWhoIsBlockedSender
+create isolationservertest isolationserverObj
+isolationserverObj SendTextMessageToUserIdWhoIsBlockedSender SERVER USERNAME PASSWORD BLOCKEDUSER MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 9.SendLongTextMessageToUserId
+create isolationservertest isolationserverObj
+isolationserverObj SendLongTextMessageToUserId SERVER USERNAME PASSWORD RECIPIENT LONGMESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 10.SendAcceptRequestWithoutReceivingAddrequest
+create isolationservertest isolationserverObj
+isolationserverObj SendAcceptRequestWithoutReceivingAddrequest SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 11.SendRejectRequestWithoutReceivingAddrequest
+create isolationservertest isolationserverObj
+isolationserverObj SendRejectRequestWithoutReceivingAddrequest SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT CONTACT CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+
+
+[Test]
+title 12.SearchKeyValueInvalidParam2
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueInvalidParam2 SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 13.SearchKeyValueInvalidHashValues
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueInvalidHashValues SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 14.SearchKeyValueBlank
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueBlank SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 15.SearchKeyValueSpecialChar
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueSpecialChar SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 16.SearchKeyValueLargeString
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueLargeString SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 17.SearchKeyValue
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValue SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 18.SearchKeyValueWithResult
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueWithResult SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 19.SearchKeyValueInvalidParam
+create isolationservertest isolationserverObj
+isolationserverObj SearchKeyValueInvalidParam SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 20.SearchForLargeNoOfResult
+create isolationservertest isolationserverObj
+isolationserverObj SearchForLargeNoOfResult SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 21.SearchAndAddContact
+create isolationservertest isolationserverObj
+isolationserverObj SearchAndAddContact SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 22.SecondSearch
+create isolationservertest isolationserverObj
+isolationserverObj SecondSearch SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
+
+
+[Test]
+title 23.AddContatcs
+create isolationservertest isolationserverObj
+isolationserverObj AddContatcs SERVER USERNAME PASSWORD USERNAME MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL
+delete isolationserverObj
+[Endtest]
+
+[Test]
+title 24.GetKeysAndSearch
+create isolationservertest isolationserverObj
+isolationserverObj GetKeysAndSearch SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO USERNAME_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT INVALIDUSERID CONNMGR_BUS CONNMGR_PATH PROTOCOL GIVEN_NAME MIDDLE_NAME JID FULL_NAME
+delete isolationserverObj
+[Endtest]
Binary file isolationserver/tsrc/data/corrupted.jpg has changed
Binary file isolationserver/tsrc/data/drmprotected.jpg has changed
Binary file isolationserver/tsrc/data/large.gif has changed
Binary file isolationserver/tsrc/data/large.jpg has changed
Binary file isolationserver/tsrc/data/large.png has changed
Binary file isolationserver/tsrc/data/test.gif has changed
Binary file isolationserver/tsrc/data/test.jpg has changed
Binary file isolationserver/tsrc/data/test.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/eabi/isolationserveru.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+../init/TestFramework.ini /epoc32/winscw/c/TestFramework/TestFramework.ini
+../conf/isolationserver.cfg /epoc32/winscw/c/TestFramework/isolationserver.cfg
+//../conf/isolationserver_manual.cfg /epoc32/winscw/c/TestFramework/isolationserver_manual.cfg
+../data/test.jpg /epoc32/winscw/c/data/Images/test.jpg
+../data/test.gif /epoc32/winscw/c/data/Images/test.gif
+../data/test.png /epoc32/winscw/c/data/Images/test.png
+../data/large.jpg /epoc32/winscw/c/data/Images/large.jpg
+../data/large.gif /epoc32/winscw/c/data/Images/large.gif
+../data/large.png /epoc32/winscw/c/data/Images/large.png
+../data/corrupted.jpg /epoc32/winscw/c/data/Images/corrupted.jpg
+../data/drmprotected.jpg /epoc32/winscw/c/data/Images/drmprotected.jpg
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example:
+/*
+/agnmodel/inc/AGMCOMON.H
+*/
+
+PRJ_TESTMMPFILES
+// NOTE: If using ARS requirements .mmp file operation should be done under this.
+// 'abld test build'
+isolationservertest.mmp
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+/agnmodel/group/agnmodel.mmp
+#if defined(MARM)
+/agnmodel/group/agsvexe.mmp
+#endif
+*/
+//isolationservertest.mmp
+
+// End of File
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/inc/isolationserver.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,261 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolationserver.h
+*
+*/
+
+
+
+#ifndef ISOLATIONSERVER_H
+#define ISOLATIONSERVER_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <glib.h>
+
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+
+// MACROS
+//#define ?macro ?macro_def
+// Logging path
+_LIT( KisolationserverLogPath, "\\logs\\testframework\\isolationserver\\" );
+// Log file
+_LIT( KisolationserverLogFile, "isolationserver.txt" );
+_LIT( KisolationserverLogFileWithTitle, "isolationserver_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class Cisolationserver;
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+* Cisolationserver test class for STIF Test Framework TestScripter.
+* ?other_description_lines
+*
+* @lib ?library
+* @since ?Series60_version
+*/
+NONSHARABLE_CLASS(Cisolationserver) : public CScriptBase
+ {
+ public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static Cisolationserver* NewL( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * Destructor.
+ */
+ virtual ~Cisolationserver();
+
+ public: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ public: // Functions from base classes
+
+ /**
+ * From CScriptBase Runs a script line.
+ * @since ?Series60_version
+ * @param aItem Script line containing method name and parameters
+ * @return Symbian OS error code
+ */
+ virtual TInt RunMethodL( CStifItemParser& aItem );
+
+ protected: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ protected: // Functions from base classes
+
+ /**
+ * From ?base_class ?member_description
+ */
+ //?type ?member_function();
+
+ private:
+
+ /**
+ * C++ default constructor.
+ */
+ Cisolationserver( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ // Prohibit copy constructor if not deriving from CBase.
+ // ?classname( const ?classname& );
+ // Prohibit assigment operator if not deriving from CBase.
+ // ?classname& operator=( const ?classname& );
+
+ /**
+ * Frees all resources allocated from test methods.
+ * @since ?Series60_version
+ */
+ void Delete();
+
+ /**
+ * Test methods are listed below.
+ */
+
+ /**
+ * Example test method.
+ * @since ?Series60_version
+ * @param aItem Script line containing parameters.
+ * @return Symbian OS error code.
+ */
+ virtual TInt SecondSearch( CStifItemParser& aItem );
+ virtual TInt LoginWithCorrectdata( CStifItemParser& aItem );
+ virtual TInt LoginWithWrongPassword( CStifItemParser& aItem );
+ virtual TInt LoginWithUnexistUserId( CStifItemParser& aItem );
+ virtual TInt LoginWithUnexistServer( CStifItemParser& aItem );
+ virtual TInt LoginWithMixedletterUserId( CStifItemParser& aItem );
+ virtual TInt LoginWithMaximumLengthUserId( CStifItemParser& aItem );
+ virtual TInt LoginWithMinimumLengthUserId( CStifItemParser& aItem );
+ virtual TInt LogoutFromServer( CStifItemParser& aItem );
+ virtual TInt LoginWithBlankUserId(CStifItemParser& aItem);
+ virtual TInt LoginLogOutWithReapitiveSession(CStifItemParser& aItem);
+ virtual TInt LoginWithCoreectUserIDWithSpace(CStifItemParser& aItem);
+ virtual TInt LoginWithInvalidPortAddress(CStifItemParser& aItem);
+ virtual TInt LoginWithMissingSettings(CStifItemParser& aItem);
+ virtual TInt LoginWhenTGAndDDAreNotRunning(CStifItemParser& aItem);
+ virtual TInt SendMessageToCorrectUserID(CStifItemParser& aItem);
+ virtual TInt SendMaxLenMessageToCorrectUserID(CStifItemParser& aItem);
+ virtual TInt SendTextMessageUnExistUserID(CStifItemParser& aItem);
+ virtual TInt SendTextMessageWithSpecialCharacter(CStifItemParser& aItem);
+ virtual TInt SendMessageWithBlankUserID(CStifItemParser& aItem);
+ virtual TInt SendBlankMessageToUserID(CStifItemParser& aItem);
+ virtual TInt SendSmilyToCorrectUserID(CStifItemParser& aItem);
+ virtual TInt SendMessageToOfflineContact(CStifItemParser& aItem);
+ virtual TInt SendTextMessageToBlockedUser(CStifItemParser& aItem);
+ virtual TInt SendContinuousltReapitiveMessage(CStifItemParser& aItem);
+ virtual TInt SendTextMessageToUserIdWhoIsBlockedSender(CStifItemParser& aItem);
+ virtual TInt SendLongTextMessageToUserId(CStifItemParser& aItem);
+ virtual TInt SendTextMessageUserWhoIsNotAddedInContactList(CStifItemParser& aItem);
+ //virtual TInt FetchContactList(CStifItemParser& aItem);
+ virtual TInt MessageReceiveFromUser(CStifItemParser& aItem);
+ virtual TInt AddExistingContact(CStifItemParser& aItem);
+ virtual TInt ClientSendBlankUserIdForADD(CStifItemParser& aItem);
+ virtual TInt AddUnexistingUserID(CStifItemParser& aItem);
+ virtual TInt AddContactWhichIsAlreadyAdded(CStifItemParser& aItem);
+ virtual TInt AddExistingContactWIthSpace(CStifItemParser& aItem);
+ virtual TInt AddExistingContactWIthMixedLetter(CStifItemParser& aItem);
+ virtual TInt AddInvalidContactWIthSpecialLetter(CStifItemParser& aItem);
+ virtual TInt DeleteExistingContact(CStifItemParser& aItem);
+ virtual TInt ClientSendBlankUserIdForDELETE(CStifItemParser& aItem);
+ virtual TInt DeleteUnexistingUserID(CStifItemParser& aItem);
+ virtual TInt DeleteContactWhichIsAlreadyDeleted(CStifItemParser& aItem);
+ virtual TInt DeleteExistingContactWIthSpace(CStifItemParser& aItem);
+ virtual TInt DeleteExistingContactWIthMixedLetter(CStifItemParser& aItem);
+ virtual TInt DeleteInvalidContactWIthSpecialLetter(CStifItemParser& aItem);
+ virtual TInt Cisolationserver::FetchContatcs( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::AddContatcs( CStifItemParser& aItem );
+ virtual TInt UpdatePresenceWithAway(CStifItemParser& aItem);
+ virtual TInt UpdatePresenceWithDnd(CStifItemParser& aItem);
+ virtual TInt UpdatePresenceWithAvailable(CStifItemParser& aItem);
+ virtual TInt UpdatePresenceMultipleTimeInSameSession(CStifItemParser& aItem);
+ virtual TInt UpdateOnlyStatusText(CStifItemParser& aItem);
+ virtual TInt UpdateOnlyUserAvailability(CStifItemParser& aItem);
+ virtual TInt UpdateOwnPresenceWithBlankData(CStifItemParser& aItem);
+ virtual TInt UpdateStatusTextWithMaxLen(CStifItemParser& aItem);
+ virtual TInt UpdateStatusTextWithSpecialCharacter(CStifItemParser& aItem);
+ virtual TInt HandelingPresenceNotification(CStifItemParser& aItem);
+ virtual TInt Cisolationserver::SearchKeyValue( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueWithResult( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueInvalidParam( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchForLargeNoOfResult( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueInvalidParam2( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueInvalidHashValues( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueBlank( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueSpecialChar( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchKeyValueLargeString( CStifItemParser& aItem );
+ virtual TInt Cisolationserver::SearchAndAddContact( CStifItemParser& aItem );
+ virtual TInt AcceptAddRequestFromUser(CStifItemParser& aItem);
+ virtual TInt RejectAddRequestFromUser(CStifItemParser& aItem);
+ virtual TInt SendAcceptRequestWithoutReceivingAddrequest(CStifItemParser& aItem);
+ virtual TInt SendRejectRequestWithoutReceivingAddrequest(CStifItemParser& aItem);
+ virtual TInt SendAcceptRequestWithoutAnyUserID(CStifItemParser& aItem);
+ virtual TInt SendRejectRequestWithoutAnyUserID(CStifItemParser& aItem);
+ virtual TInt LogoutWhileUserIsNotLoggedIn(CStifItemParser& aItem);
+ virtual TInt GetKeysAndSearch( CStifItemParser& aItem );
+ virtual TInt SetOwnAvatar( CStifItemParser& aItem );
+ virtual TInt ClearOwnAvatar( CStifItemParser& aItem );
+ virtual TInt FetchCachedContacts( CStifItemParser& aItem );
+
+//ADD NEW METHOD DEC HERE
+ //[TestMethods] - Do not remove
+
+ public:
+
+ const gchar* GetSearchLabelForGizmoL(gchar* search_key);
+ const gchar* GetSearchLabelForYukonL(gchar* search_key);
+ const gchar* GetSearchLabelL(gchar* aService,gchar* aSearchKey);
+
+ public: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ protected: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ private: // Data
+
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ // Reserved pointer for future extension
+ //TAny* iReserved;
+
+ public: // Friend classes
+ //?friend_class_declaration;
+ protected: // Friend classes
+ //?friend_class_declaration;
+ private: // Friend classes
+ //?friend_class_declaration;
+
+ };
+
+#endif // ISOLATIONSERVER_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/init/TestFramework.ini Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Engine_Defaults]
+
+TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment',
+ 'TestCases' or 'FullReport'
+
+CreateTestReport= YES # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT # Possible values: TXT or HTML
+TestReportOutput= FILE # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\isolationserver.cfg
+[End_Module]
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\isolationserver_manual.cfg
+[End_Module]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Logger_Defaults]
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/src/isolationserver.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolationserver.cpp
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <StifTestInterface.h>
+#include "isolationserver.h"
+#include <SettingServerClient.h>
+
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+// ?value_n: ?description_line1
+// ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+ ?arg_type arg, // ?description
+ ?arg_type arg) // ?description
+ {
+
+ ?code // ?comment
+
+ // ?comment
+ ?code
+ }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Cisolationserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Cisolationserver::Cisolationserver(
+ CTestModuleIf& aTestModuleIf ):
+ CScriptBase( aTestModuleIf )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Cisolationserver::ConstructL()
+ {
+ //Read logger settings to check whether test case name is to be
+ //appended to log file name.
+ RSettingServer settingServer;
+ TInt ret = settingServer.Connect();
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Struct to StifLogger settigs.
+ TLoggerSettings loggerSettings;
+ // Parse StifLogger defaults from STIF initialization file.
+ ret = settingServer.GetLoggerSettings(loggerSettings);
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Close Setting server session
+ settingServer.Close();
+
+ TFileName logFileName;
+
+ if(loggerSettings.iAddTestCaseTitle)
+ {
+ TName title;
+ TestModuleIf().GetTestCaseTitleL(title);
+ logFileName.Format(KisolationserverLogFileWithTitle, &title);
+ }
+ else
+ {
+ logFileName.Copy(KisolationserverLogFile);
+ }
+
+ iLog = CStifLogger::NewL( KisolationserverLogPath,
+ logFileName,
+ CStifLogger::ETxt,
+ CStifLogger::EFile,
+ EFalse );
+
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Cisolationserver* Cisolationserver::NewL(
+ CTestModuleIf& aTestModuleIf )
+ {
+ Cisolationserver* self = new (ELeave) Cisolationserver( aTestModuleIf );
+
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+
+ return self;
+
+ }
+
+// Destructor
+Cisolationserver::~Cisolationserver()
+ {
+
+ // Delete resources allocated from test methods
+ Delete();
+
+ // Delete logger
+ delete iLog;
+
+ }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL(
+ CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+ {
+
+ return ( CScriptBase* ) Cisolationserver::NewL( aTestModuleIf );
+
+ }
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolationserver/tsrc/src/isolationserverBlocks.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,19062 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolationserverBlocks.cpp
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <StifTestInterface.h>
+#include "isolationserver.h"
+#include <e32const.h>
+
+#include <glib.h>
+#include <glib/gprintf.h> // for g_stpcpy
+#include <string.h>
+#include <stdlib.h>
+
+#include <glowmem.h>
+#include "msgliterals.h"
+#include "msg_enums.h"
+#include <math.h>
+#define ONE_K_OPENC_FIX 1020
+
+typedef enum
+{
+ RC_OK,
+ RC_ERROR
+} RC_Code_t;
+
+
+typedef struct
+{
+ gchar *recipient;
+ gchar *message;
+} MessageData;
+
+typedef struct
+{
+ gchar *proxy_server;
+ gchar *proxy_port;
+}ProxyData;
+
+typedef struct
+{
+ gchar *server;
+ gchar *username;
+ gchar *password;
+ gchar *resource;
+ MessageData *msg_data;
+ gchar *port;
+
+ ProxyData *proxy_data;
+ gchar *contact;
+ gchar *connmgr_bus;
+ gchar *connmgr_path;
+ gchar *protocol;
+ gchar *key_given_name;
+ gchar *key_middle_name;
+ gchar *key_jid;
+ gchar *key_full_name;
+ gchar *mimetype;
+ gchar *image_file_name;
+
+} ConnectData;
+
+
+// Function to read data from the cfg file
+static RC_Code_t read_data ( ConnectData*& connect_data,
+ CStifItemParser& aItem );
+
+// Function to free the allocated resources
+static void free_data ( ConnectData*& connect_data );
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : read_data
+// description : Reads data from the CFG file
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static RC_Code_t
+read_data ( ConnectData*& connect_data, CStifItemParser& aItem )
+ {
+ TPtrC string;
+ TBuf8<KMaxFileName> temp;
+ MessageData *msg_data = NULL;
+
+
+ ProxyData *proxy_data = NULL;
+// TInt proxy_port;
+
+
+
+ connect_data = g_new0 ( ConnectData, 1 );
+ if ( !connect_data )
+ {
+ return RC_ERROR;
+ }
+
+ msg_data = g_new0 ( MessageData, 1 );
+ if ( !msg_data )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+
+ connect_data->msg_data = msg_data;
+
+
+ proxy_data = g_new0 ( ProxyData, 1 );
+ if ( !proxy_data )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ connect_data->proxy_data = proxy_data;
+
+
+ // Read server name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->server = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->server )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->server, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Username
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->username = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->username )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->username, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Password corresponding to Username
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->password = g_new0 ( gchar, temp.Length () );
+ if ( !connect_data->password )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->password, ( gchar *) temp.Ptr() );
+ }
+
+ // Read recipient
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ msg_data->recipient = g_new0 ( gchar, temp.Length() );
+ if ( !msg_data->recipient )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( msg_data->recipient, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Message
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ msg_data->message = g_new0 ( gchar, temp.Length() );
+ if ( !msg_data->message )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( msg_data->message, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read resource identifier
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->resource = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->resource )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->resource, ( gchar * ) temp.Ptr() );
+ }
+
+
+ // Read proxy server and proxy port
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ proxy_data->proxy_server = g_new0 ( gchar, temp.Length() );
+ if ( !proxy_data->proxy_server )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( proxy_data->proxy_server, ( gchar * ) temp.Ptr() );
+ }
+
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ proxy_data->proxy_port = g_new0 ( gchar, temp.Length() );
+ if ( !proxy_data->proxy_port )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( proxy_data->proxy_port, ( gchar * ) temp.Ptr() );
+ }
+
+
+
+ /* if ( aItem.GetNextString ( proxy_port ) == KErrNone )
+ {
+ proxy_data->proxy_port = proxy_port;
+ } */
+
+
+ // Read POrt address
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->port = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->port )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->port, ( gchar * ) temp.Ptr() );
+ }
+
+ // read Add member
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->contact = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->contact )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->contact, ( gchar * ) temp.Ptr() );
+ }
+
+ // read CONNMGR_BUS
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->connmgr_bus = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->connmgr_bus )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->connmgr_bus, ( gchar * ) temp.Ptr() );
+ }
+
+ // read CONNMGR_PATH
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->connmgr_path = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->connmgr_path )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->connmgr_path, ( gchar * ) temp.Ptr() );
+ }
+
+ // read PROTOCOL
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->protocol = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->protocol )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->protocol, ( gchar * ) temp.Ptr() );
+ }
+
+
+ // read given Name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->key_given_name = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->key_given_name )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->key_given_name, ( gchar * ) temp.Ptr() );
+ }
+
+ // read middle Name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->key_middle_name = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->key_middle_name )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->key_middle_name, ( gchar * ) temp.Ptr() );
+ }
+
+ // read email Name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->key_jid = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->key_jid )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->key_jid, ( gchar * ) temp.Ptr() );
+ }
+
+ // read full Name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->key_full_name = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->key_full_name )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->key_full_name, ( gchar * ) temp.Ptr() );
+ }
+ // read mimetype
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->mimetype = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->mimetype )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->mimetype, ( gchar * ) temp.Ptr() );
+ }
+ // read image filename
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->image_file_name = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->image_file_name )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->image_file_name, ( gchar * ) temp.Ptr() );
+ }
+ return RC_OK;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : free_data
+// description : Deallocates all the data
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+free_data ( ConnectData*& connect_data )
+ {
+ if ( connect_data )
+ {
+ if ( connect_data->server )
+ {
+ g_free ( connect_data->server );
+ connect_data->server = NULL;
+ }
+
+ if ( connect_data->username )
+ {
+ g_free ( connect_data->username );
+ connect_data->username = NULL;
+ }
+
+ if ( connect_data->password )
+ {
+ g_free ( connect_data->password );
+ connect_data->password = NULL;
+ }
+
+ if ( connect_data->msg_data )
+ {
+ if ( connect_data->msg_data->recipient )
+ {
+ g_free ( connect_data->msg_data->recipient );
+ connect_data->msg_data->recipient = NULL;
+ }
+ if ( connect_data->msg_data->message )
+ {
+ g_free ( connect_data->msg_data->message );
+ connect_data->msg_data->message = NULL;
+ }
+ g_free ( connect_data->msg_data );
+ connect_data->msg_data = NULL;
+ }
+
+ if ( connect_data->resource )
+ {
+ g_free ( connect_data->resource );
+ connect_data->resource = NULL;
+ }
+
+
+ if ( connect_data->proxy_data )
+ {
+ if ( connect_data->proxy_data->proxy_server )
+ {
+ g_free ( connect_data->proxy_data->proxy_server );
+ connect_data->proxy_data->proxy_server = NULL;
+ }
+ g_free ( connect_data->proxy_data );
+ connect_data->proxy_data = NULL;
+ }
+
+ if ( connect_data->port )
+ {
+ g_free ( connect_data->port );
+ connect_data->port = NULL;
+ }
+
+
+ if ( connect_data->contact )
+ {
+ g_free ( connect_data->contact );
+ connect_data->contact = NULL;
+ }
+
+ if ( connect_data->key_given_name )
+ {
+ g_free ( connect_data->key_given_name );
+ connect_data->key_given_name = NULL;
+ }
+
+ if ( connect_data->key_middle_name )
+ {
+ g_free ( connect_data->key_middle_name );
+ connect_data->key_middle_name = NULL;
+ }
+
+ if ( connect_data->key_jid )
+ {
+ g_free ( connect_data->key_jid );
+ connect_data->key_jid = NULL;
+ }
+
+ if ( connect_data->key_full_name )
+ {
+ g_free ( connect_data->key_full_name );
+ connect_data->key_full_name = NULL;
+ }
+
+ g_free ( connect_data );
+ connect_data = NULL;
+ }
+ }
+
+ //-----------------------------------------------------------------------------
+// function_name : running isolation server exe
+// description : Deallocates all the data
+// Returns : None
+//-----------------------------------------------------------------------------
+ int run_isoserver()
+ {
+ // running isoserver
+ RProcess isosrv_launcher;
+ TInt lunch_err = 0;
+ _LIT(KProcess, "isoserver.exe");
+ lunch_err = isosrv_launcher.Create( KProcess, KNullDesC );
+ if ( KErrNone != lunch_err )
+ {
+ return KErrGeneral;
+
+ }
+ isosrv_launcher.Resume();
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+// ?value_n: ?description_line1
+// ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+ ?arg_type arg, // ?description
+ ?arg_type arg) // ?description
+ {
+
+ ?code // ?comment
+
+ // ?comment
+ ?code
+ }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Delete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+//
+void Cisolationserver::Delete()
+ {
+
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::RunMethodL(
+ CStifItemParser& aItem )
+ {
+
+ static TStifFunctionInfo const KFunctions[] =
+ {
+
+ ENTRY( "SecondSearch", Cisolationserver::SecondSearch),
+ ENTRY( "SearchAndAddContact", Cisolationserver::SearchAndAddContact ),
+ ENTRY( "LoginWithCorrectData", Cisolationserver::LoginWithCorrectdata ),
+ ENTRY( "LoginWithWrongPassword", Cisolationserver::LoginWithWrongPassword ),
+ ENTRY( "LoginWithUnexistUserId", Cisolationserver::LoginWithUnexistUserId),
+ ENTRY( "LoginWithUnexistServer", Cisolationserver::LoginWithUnexistServer),
+ ENTRY( "LoginWithMixedLetterUserId", Cisolationserver::LoginWithMixedletterUserId),
+ ENTRY( "LoginWithMaximumLenghtUserId", Cisolationserver::LoginWithMaximumLengthUserId),
+ ENTRY( "LoginWithMinimumLenghtUserId", Cisolationserver::LoginWithMinimumLengthUserId),
+ ENTRY( "LogoutFromServer", Cisolationserver::LogoutFromServer),
+ ENTRY( "LoginWithBlankUserId", Cisolationserver::LoginWithBlankUserId),
+ ENTRY( "LoginLogOutWithReapitiveSession", Cisolationserver::LoginLogOutWithReapitiveSession),
+ ENTRY( "LoginWithCoreectUserIDWithSpace", Cisolationserver::LoginWithCoreectUserIDWithSpace),
+ ENTRY( "LoginWithInvalidPortAddress", Cisolationserver::LoginWithInvalidPortAddress),
+ ENTRY( "LoginWithMissingSettings", Cisolationserver::LoginWithMissingSettings),
+ ENTRY( "LoginWhenTGAndDDAreNotRunning", Cisolationserver::LoginWhenTGAndDDAreNotRunning),
+ ENTRY( "SendMessageToCorrectUserID", Cisolationserver::SendMessageToCorrectUserID),
+ ENTRY( "SendMaxLenMessageToCorrectUserID", Cisolationserver::SendMaxLenMessageToCorrectUserID),
+ ENTRY( "SendTextMessageUnExistUserID", Cisolationserver::SendTextMessageUnExistUserID),
+ ENTRY( "SendTextMessageWithSpecialCharacter", Cisolationserver::SendTextMessageWithSpecialCharacter),
+ ENTRY( "SendMessageWithBlankUserID", Cisolationserver::SendMessageWithBlankUserID),
+ ENTRY( "SendSmilyToCorrectUserID", Cisolationserver::SendSmilyToCorrectUserID),
+ ENTRY( "SendBlankMessageToUserID", Cisolationserver::SendBlankMessageToUserID),
+ ENTRY( "SendMessageToOfflineContact", Cisolationserver::SendMessageToOfflineContact),
+ ENTRY( "SendContinuousltReapitiveMessage", Cisolationserver::SendContinuousltReapitiveMessage),
+ ENTRY( "SendTextMessageToBlockedUser", Cisolationserver::SendTextMessageToBlockedUser),
+ ENTRY( "SendTextMessageToUserIdWhoIsBlockedSender", Cisolationserver::SendTextMessageToUserIdWhoIsBlockedSender),
+ ENTRY( "SendLongTextMessageToUserId", Cisolationserver::SendLongTextMessageToUserId),
+ ENTRY( "SendTextMessageUserWhoIsNotAddedInContactList", Cisolationserver::SendTextMessageUserWhoIsNotAddedInContactList),
+ ENTRY( "MessageReceiveFromUser", Cisolationserver::MessageReceiveFromUser),
+ ENTRY( "AddExistingContact", Cisolationserver::AddExistingContact),
+ ENTRY( "ClientSendBlankUserIdForADD", Cisolationserver::ClientSendBlankUserIdForADD),
+ ENTRY( "AddContactWhichIsAlreadyAdded", Cisolationserver::AddContactWhichIsAlreadyAdded),
+ ENTRY( "AddExistingContactWIthSpace", Cisolationserver::AddExistingContactWIthSpace),
+ ENTRY( "AddUnexistingUserID", Cisolationserver::AddUnexistingUserID),
+ ENTRY( "AddExistingContactWIthMixedLetter", Cisolationserver::AddExistingContactWIthMixedLetter),
+ ENTRY( "AddInvalidContactWIthSpecialLetter", Cisolationserver::AddInvalidContactWIthSpecialLetter),
+ ENTRY( "DeleteExistingContact", Cisolationserver::DeleteExistingContact),
+ ENTRY( "ClientSendBlankUserIdForDELETE", Cisolationserver::ClientSendBlankUserIdForDELETE),
+ ENTRY( "DeleteContactWhichIsAlreadyDeleted", Cisolationserver::DeleteContactWhichIsAlreadyDeleted),
+ ENTRY( "DeleteExistingContactWIthSpace", Cisolationserver::DeleteExistingContactWIthSpace),
+ ENTRY( "DeleteUnexistingUserID", Cisolationserver::DeleteUnexistingUserID),
+ ENTRY( "DeleteExistingContactWIthMixedLetter", Cisolationserver::DeleteExistingContactWIthMixedLetter),
+ ENTRY( "DeleteInvalidContactWIthSpecialLetter", Cisolationserver::DeleteInvalidContactWIthSpecialLetter),
+ ENTRY( "FetchContatcs", Cisolationserver::FetchContatcs),
+ ENTRY( "AddContatcs", Cisolationserver::AddContatcs),
+ ENTRY( "UpdatePresenceWithAway", Cisolationserver::UpdatePresenceWithAway),
+ ENTRY( "UpdatePresenceWithDnd", Cisolationserver::UpdatePresenceWithDnd),
+ ENTRY( "UpdatePresenceWithAvailable", Cisolationserver::UpdatePresenceWithAvailable),
+ ENTRY( "UpdatePresenceMultipleTimeInSameSession", Cisolationserver::UpdatePresenceMultipleTimeInSameSession),
+ ENTRY( "UpdateOnlyStatusText", Cisolationserver::UpdateOnlyStatusText),
+ ENTRY( "UpdateOnlyUserAvailability", Cisolationserver::UpdateOnlyUserAvailability),
+ ENTRY( "UpdateOwnPresenceWithBlankData", Cisolationserver::UpdateOwnPresenceWithBlankData),
+ ENTRY( "UpdateStatusTextWithMaxLen", Cisolationserver::UpdateStatusTextWithMaxLen),
+ ENTRY( "UpdateStatusTextWithSpecialCharacter", Cisolationserver::UpdateStatusTextWithSpecialCharacter),
+ ENTRY( "HandelingPresenceNotification", Cisolationserver::HandelingPresenceNotification),
+ ENTRY( "SearchKeyValue", Cisolationserver::SearchKeyValue),
+ ENTRY( "SearchKeyValueWithResult", Cisolationserver::SearchKeyValueWithResult ),
+ ENTRY( "SearchKeyValueInvalidParam", Cisolationserver::SearchKeyValueInvalidParam ),
+ ENTRY( "SearchForLargeNoOfResult", Cisolationserver::SearchForLargeNoOfResult ),
+ ENTRY( "SearchKeyValueInvalidParam2", Cisolationserver::SearchKeyValueInvalidParam2 ),
+ ENTRY( "SearchKeyValueInvalidHashValues", Cisolationserver::SearchKeyValueInvalidHashValues ),
+ ENTRY( "SearchKeyValueBlank", Cisolationserver::SearchKeyValueBlank ),
+ ENTRY( "SearchKeyValueSpecialChar", Cisolationserver::SearchKeyValueSpecialChar ),
+ ENTRY( "SearchKeyValueLargeString", Cisolationserver::SearchKeyValueLargeString ),
+ ENTRY( "AcceptAddRequestFromUser", Cisolationserver::AcceptAddRequestFromUser ),
+ ENTRY( "RejectAddRequestFromUser", Cisolationserver::RejectAddRequestFromUser ),
+ ENTRY( "SendAcceptRequestWithoutReceivingAddrequest", Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest ),
+ ENTRY( "SendRejectRequestWithoutReceivingAddrequest", Cisolationserver::SendRejectRequestWithoutReceivingAddrequest ),
+ ENTRY( "SendAcceptRequestWithoutAnyUserID", Cisolationserver::SendAcceptRequestWithoutAnyUserID ),
+ ENTRY( "SendRejectRequestWithoutAnyUserID", Cisolationserver::SendRejectRequestWithoutAnyUserID ),
+ ENTRY( "LogoutWhileUserIsNotLoggedIn", Cisolationserver::LogoutWhileUserIsNotLoggedIn),
+ ENTRY( "GetKeysAndSearch", Cisolationserver::GetKeysAndSearch),
+ ENTRY( "SetOwnAvatar", Cisolationserver::SetOwnAvatar),
+ ENTRY( "ClearOwnAvatar", Cisolationserver::ClearOwnAvatar),
+ ENTRY( "FetchCachedContacts", Cisolationserver::FetchCachedContacts),
+ //ADD NEW ENTRY HERE
+ // [test cases entries] - Do not remove
+
+ };
+
+ const TInt count = sizeof( KFunctions ) /
+ sizeof( TStifFunctionInfo );
+
+ return RunInternalL( KFunctions, count, aItem );
+
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithCorrectdata( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+ FILE *fp;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+ // appending IAP id
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Logout from server
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LogoutFromServer( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+ FILE *fp;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+ // appending IAP id
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with mixed letter user
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithMixedletterUserId( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+ FILE *fp;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+ // appending IAP id
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with mixed letter user
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithMinimumLengthUserId( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+ FILE *fp;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+ // appending IAP id
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with mixed letter user
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithMaximumLengthUserId( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+ FILE *fp;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+ // appending IAP id
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+// -----------------------------------------------------------------------------
+// Cisolationserver::Login with bad password
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithWrongPassword( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Login with unexist user id
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithUnexistUserId( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if( msg_struct->response != 0 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::connect with unexist server
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithUnexistServer( CStifItemParser& aItem )
+ {
+
+ /*
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ //Send Message to queueOne
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // login end
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ */
+ //LM is not getting call back from server so we are just saying KerrGeneral
+ return KErrGeneral;
+ }
+
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithBlankUserId( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ // blank user id
+ smsg[index++]='\0';
+ smsg[index++]='\0';
+
+ //appending password
+
+ int len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->error_type > 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Logout from server
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginLogOutWithReapitiveSession( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isolation server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ //request formation
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::connect with invalid port
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithInvalidPortAddress( CStifItemParser& aItem )
+ {
+
+ /*
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+
+ smsg[index++]='4';
+ smsg[index++]='4';
+ smsg[index++]='2';
+
+ smsg[index++]='\0';
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ // Send Message to queueOne
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response == 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ */
+ //LM is not getting call back from server so we are just saying KerrGeneral
+ return KErrGeneral;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithMissingSettings( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ // ssl is missing here
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::LoginWhenTGAndDDAreNotRunning
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWhenTGAndDDAreNotRunning( CStifItemParser& aItem )
+ {
+ /*
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ // Send Message to queueOne
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value; */
+ return KErrNone;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LoginWithCoreectUserIDWithSpace( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ smsg[index++]='\0';
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->error_type >0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendMessageToCorrectUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Send message with max len
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendMaxLenMessageToCorrectUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send message to unexist user id
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendTextMessageUnExistUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ /* if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }*/
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send message to unexist user id
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendTextMessageWithSpecialCharacter( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send message to blank user id
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendMessageWithBlankUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ smsg[index++] = '\0';
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send blank message to user id
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendBlankMessageToUserID( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ smsg[index++]=' ';
+ smsg[index++]='\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send blank message to user id
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendSmilyToCorrectUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strncpy( smsg + index, connect_data->msg_data->message, strlen( connect_data->msg_data->message ) );
+ index += len;
+ smsg[index++] = ' ';
+ smsg[index++]=':';
+ smsg[index++]='-';
+ smsg[index++]=')';
+ smsg[index++] = '\0';
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendMessageToOfflineContact( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send messge--------------------------------------------
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //send message end---------------------------------------
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendContinuousltReapitiveMessage( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge 1 --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //send message end---------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendTextMessageToBlockedUser( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendTextMessageToUserIdWhoIsBlockedSender( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendLongTextMessageToUserId( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Send message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendTextMessageUserWhoIsNotAddedInContactList( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //send message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::MessageReceiveFromUser( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int i=0;
+ int msglen=0;
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp ;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ fp = fopen("c:\\receive_message_logs.txt","a");TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ // running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+
+ //send messge to our self--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ TBool ESend = EFalse , EReceive = EFalse;
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ // adding recipient
+ /*len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;*/
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ if(msg_struct->hdr_req.message_type==ESend_Request)
+ ESend=ETrue;
+ if(msg_struct->hdr_req.message_type==EText_Message_Receive)
+ ESend=ETrue;
+ } while (ESend/* == ETrue */&& EReceive/* ==ETrue*/) ;//(msg_struct->hdr_req.message_type!=ESend_Request);
+
+ /* if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //wait for message receive
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ fprintf( fp, "receive message %s\n", rmsg+24 );
+
+ for ( i=24 ; i <rmsg[i]!='\0';i++)
+ msglen++;
+ fprintf( fp, "receive message %s\n", rmsg+24+msglen+1 );
+ */
+
+ // login end
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::AddExistingContact( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+
+ //adding contact --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++]='\0';
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::AddUnexistingUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //add contact --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++] = '\0';
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::AddContactWhichIsAlreadyAdded( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //add member 1 st time--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+
+
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+ //add member 2 nd time--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::ClientSendBlankUserIdForADD( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //add contact --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ smsg[index++]='\0';
+ //client is sending blank user id
+ smsg[index++]='\0';
+
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if( msg_struct->error_type >0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::AddExistingContactWIthSpace( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++]=' ';
+
+ smsg[index++]= '\0';
+
+
+
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::AddExistingContactWIthMixedLetter( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++]='\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::AddInvalidContactWIthSpecialLetter( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::DeleteExistingContact( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //delete contact--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++] = '\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::DeleteUnexistingUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //delete contact--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::DeleteContactWhichIsAlreadyDeleted( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+
+ //add member 1 st time--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ // addiing in q for deleting contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end 1---------------------------------------
+
+ //delete member 1 st time--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // addiing in q for deleting contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //delete contact end 1---------------------------------------
+
+ //delete contact 2 nd time--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // delete contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //delete contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::ClientSendBlankUserIdForDELETE( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //delete contact --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ smsg[index++]='\0';
+ //client is sending blank user id
+ smsg[index++]='\0';
+
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if( msg_struct->error_type >0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //delete contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::DeleteExistingContactWIthSpace( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //delete contact--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding delete contact in queue
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++]='\0';
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //delete contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::DeleteExistingContactWIthMixedLetter( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //delete contact--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding delete contact id
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+
+ //delete contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::add member message
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::DeleteInvalidContactWIthSpecialLetter( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //delete contact--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding delete contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //delete contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::FetchContatcs( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ // logout test code from server
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+TInt Cisolationserver::AddContatcs( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+
+ //running isoserver
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //send msg copy
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ //------------------------1
+ // adding recipient
+ len = strlen( "santhosh09431243.ic@gmail.com" );
+ strcpy( smsg + index, "santhosh09431243.ic@gmail.com" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //send msg copy end
+
+
+
+ //EAdd_Contact_Request messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ //len = strlen( "tele1236@gmail.com" );
+ //strcpy( smsg + index, "tele1236@gmail.com" );
+ //index += len + 1;
+
+ strcpy( smsg + index, "testlm123@gmail.com" );
+ index += strlen( "testlm123@gmail.com" ) + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // sleep( 50 );
+ //EAdd_Contact_Request message end---------------------------------------
+
+ /* sleep( 100 );
+ //--------------------------------Trying to add client notification----------------------
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if ( status < 0 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ */
+ //--------------------------------Trying to add client end----------------------
+
+
+
+
+ //EAdd_Contact_Request messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ strcpy( smsg + index, "tele1236@gmail.com" );
+ index += strlen( "tele1236@gmail.com" ) + 1;
+
+ // adding recipient
+ //len = strlen(connect_data->msg_data->recipient );
+ //strcpy( smsg + index, connect_data->msg_data->recipient );
+ //index += len + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //EAdd_Contact_Request message end---------------------------------------
+
+
+
+ //EAdd_Contact_Request -ve messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ //-----------------1
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ strcpy( smsg + index, "tele1236@gmail.com" );
+ index += strlen( "tele1236@gmail.com" ) + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //-----------------2 -ve
+ index = 0;
+ index += sizeof( message_hdr_req );
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ memcpy( smsg + index, connect_data->msg_data->recipient, len );
+ index += len;
+
+ // adding message part
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //-----------------
+
+
+ //EAdd_Contact_Request -ve message end---------------------------------------
+
+ //send messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESend_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ //------------------------1
+ // adding recipient
+ len = strlen( "santhosh.ic@gmail.com" );
+ strcpy( smsg + index, "santhosh.ic@gmail.com" );
+ index += len + 1;
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //-----------------------------------2 -ve
+ index = 0;
+ index += sizeof( message_hdr_req );
+ // adding recipient
+ for ( int i = 0; i <= 11; i++ )
+ {
+ len = strlen( "santhosh.ic@gmail.com" );
+ strcpy( smsg + index, "santhosh.ic@gmail.com" );
+ index += len + 1;
+ }
+ smsg[index++] = '\0';
+ // adding message part
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ //-----------------------------------3 -ve
+ index = 0;
+ index += sizeof( message_hdr_req );
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ memcpy( smsg + index, connect_data->msg_data->recipient, len );
+ index += len;
+
+ // adding message part
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ESend_Request);
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //send message end---------------------------------------
+
+ //EDelete_Contact_Request messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ strcpy( smsg + index, "tele1236@gmail.com" );
+ index += strlen( "tele1236@gmail.com" ) + 1;
+
+ // adding recipient
+ //len = strlen(connect_data->msg_data->recipient );
+ //strcpy( smsg + index, connect_data->msg_data->recipient );
+ //index += len + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //--------------------delete----------------------
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EDelete_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding recipient
+ len = strlen(connect_data->msg_data->recipient );
+ strcpy( smsg + index, connect_data->msg_data->recipient );
+ index += len + 1;
+
+ strcpy( smsg + index, "rakesh.harsh@gmail.com" );
+ index += strlen( "rakesh.harsh@gmail.com" ) + 1;
+
+ // adding recipient
+ //len = strlen(connect_data->msg_data->recipient );
+ //strcpy( smsg + index, connect_data->msg_data->recipient );
+ //index += len + 1;
+
+ smsg[index++] = '\0';
+
+ // adding message part
+
+ len = strlen(connect_data->msg_data->message );
+ strcpy( smsg + index, connect_data->msg_data->message );
+ index += len + 1;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EDelete_Contact_Request);
+
+
+
+ //EDelete_Contact_Request message end---------------------------------------
+
+ //--------------Recieve message-----------------------------------
+ /* do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EText_Message_Receive);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EText_Message_Receive);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ } */ //------------------------Recieve message end---------------------
+
+ //-------------update presence with available---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "available";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "i m busy";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+// ------------------------------------------------------------------
+
+ //-------------update presence with available---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability1 = "dnd";
+ memcpy( smsg + index, availability1, strlen( availability1 ) );
+ index += strlen( availability1 );
+
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext1 = "i m busy";
+ memcpy( smsg + index, statustext1, strlen( statustext1 ) );
+ index += strlen( statustext1 );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+// ------------------------------------------------------------------
+
+ //-------------update presence with available---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability2 = "away";
+ memcpy( smsg + index, availability2, strlen( availability2 ) );
+ index += strlen( availability2 );
+
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext2 = "i m busy";
+ memcpy( smsg + index, statustext2, strlen( statustext2 ) );
+ index += strlen( statustext2 );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+// ------------------------------------------------------------------
+
+ //----------------------------presence negative case------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability with blank
+ smsg[index++]='\0';
+ smsg[index++]='\0';
+ //smsg[index++]='\0';
+
+ //updating status text
+ char *statustext4 = "i m not on desk";
+ memcpy( smsg + index, statustext4, strlen( statustext4 ) );
+ index += strlen( statustext4 );
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->error_type > 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //-------------------------1 end
+
+ // update 2 negative
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability4 = "available";
+ memcpy( smsg + index, availability, strlen( availability4 ) );
+ index += strlen( availability4 );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //----
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithAway
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdatePresenceWithAway( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "away";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "i m busy";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithAway
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdatePresenceWithAvailable( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "available";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "there is difference between thought and execution";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithDnd
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdatePresenceWithDnd( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "dnd";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "i m busy";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithDnd
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdatePresenceMultipleTimeInSameSession( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "dnd";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "i m busy";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //-------------update presence 2nd time---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability1 = "away";
+ memcpy( smsg + index, availability1, strlen( availability1 ) );
+ index += strlen( availability1 );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext1 = "i m not on desk";
+ memcpy( smsg + index, statustext1, strlen( statustext1 ) );
+ index += strlen( statustext1 );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogout_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithDnd
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdateOnlyStatusText( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability with blank
+ smsg[index++]='\0';
+ smsg[index++]='\0';
+ //smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "i m not on desk";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->error_type > 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithAway
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdateOnlyUserAvailability( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "available";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithAway
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdateOwnPresenceWithBlankData( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->error_type > 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithDnd
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdateStatusTextWithSpecialCharacter( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "dnd";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "hi i m_ fine here @@@@@ ********* &&&&&&&&&&&&";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithDnd
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::UpdateStatusTextWithMaxLen( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "dnd";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "thesr is difference between thoughts and execution ";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::UpdatePresenceWithDnd
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::HandelingPresenceNotification( CStifItemParser& aItem )
+ {
+
+ /*
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ // Send Message to queueOne
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //-------------update presence---------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnPresence;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // updating availability
+ char *availability = "dnd";
+ memcpy( smsg + index, availability, strlen( availability ) );
+ index += strlen( availability );
+ smsg[index++]='\0';
+
+ //updating status text
+ char *statustext = "i m busy";
+ memcpy( smsg + index, statustext, strlen( statustext ) );
+ index += strlen( statustext );
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnPresence);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // waiting for second change
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //wait for message receive
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // waiting for first change
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //wait for message receive
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // waiting for first change
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //wait for message receive
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // waiting for first change
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //wait for message receive
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // waiting for first change
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //wait for message receive
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value; */
+ return KErrNone;
+ }
+
+
+Cisolationserver::SearchKeyValue( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ TInt return_value = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+
+
+ // adding value
+
+ len = strlen("santhosh" );
+ strcpy( smsg + index, "santhosh" );
+ index += len + 1;
+
+
+ smsg[index++] = '\0';
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ ///-------------------------------------------------------------
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+Cisolationserver::SearchKeyValueWithResult( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+ // adding value
+
+ len = strlen("rakesh" );
+ strcpy( smsg + index, "rakesh" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+
+Cisolationserver::SearchKeyValueInvalidParam( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch );
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+
+Cisolationserver::SearchForLargeNoOfResult( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+
+
+ // adding value
+
+ len = strlen("a*" );
+ strcpy( smsg + index, "a*" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+Cisolationserver::SearchKeyValueInvalidParam2( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch );
+
+ if ( msg_struct->response != 0 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+Cisolationserver::SearchKeyValueInvalidHashValues( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding key
+ len = strlen( "firstGname" );
+ strcpy( smsg + index, "firstGname" );
+ index += len + 1;
+
+ // adding value
+ len = strlen("I" );
+ strcpy( smsg + index, "I" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch );
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+Cisolationserver::SearchKeyValueBlank( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding key
+ len = strlen( connect_data->key_jid );
+ strcpy( smsg + index, connect_data->key_jid );
+ index += len + 1;
+
+ // adding value
+ len = strlen("" );
+ strcpy( smsg + index, "" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch );
+
+
+ if( msg_struct->error_type != INVALID_PARAMETERES )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+Cisolationserver::SearchKeyValueLargeString( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+ // adding value
+ len = strlen( "Gmail is a new kind of webmail built on \
+ the idea that email can be more intuitive efficient and useful" );
+
+ strcpy( smsg + index, "Gmail is a new kind of webmail built on \
+ the idea that email can be more intuitive efficient and useful" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+Cisolationserver::SearchKeyValueSpecialChar( CStifItemParser& aItem )
+ {
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+ // adding value
+ len = strlen("happy_123@chat.gizmoproject.com" );
+ strcpy( smsg + index, "happy_123@chat.gizmoproject.com" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::RejectAddRequestFromUser
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//RejectAddRequestFromUser
+TInt Cisolationserver::RejectAddRequestFromUser( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+ // getting add notification from user
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+
+ do {
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ // memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ char *userid = (char *)malloc(100);
+ len=0;
+ len+=sizeof(message_hdr_resp);
+ strcpy(userid,rmsg+len);
+
+
+
+
+ // rejecting add request from user
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EReject_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ len=0;
+ len+=strlen(userid);
+ strcpy( smsg + index ,userid );
+ index += len + 1;
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EReject_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::AcceptAddRequestFromUser
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+Cisolationserver::SearchAndAddContact( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+ // adding value
+ len = strlen("rakesh" );
+ strcpy( smsg + index, "rakesh" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ gint temp = 0;
+ gchar* add_contact = NULL;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do
+ {
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ //To add contact only once for the first time
+ if ( 0 == temp && ESearch == msg_struct->hdr_req.message_type )
+ {
+ // length will point to the start of the contact to be added
+ int length = 0;
+ length += sizeof( message_hdr_resp );
+
+ while ( 0 != strcmp( "jid", rmsg + length )
+ && '\0' != *( rmsg + length + 1) )
+ {
+ length += strlen( rmsg + length ) + 1;
+ gchar* add_contact = rmsg + length;
+ }
+ length += strlen( rmsg + length ) + 1;
+
+ add_contact = strdup( rmsg + length );
+ //add contact end---------------------------------------
+ temp++;
+ }
+
+
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //search message end---------------------------------------
+
+ //adding contact --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAdd_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ // adding add contact
+ len = strlen( add_contact );
+ strcpy( smsg + index, add_contact );
+ index += len + 1;
+ smsg[index++]='\0';
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ } while (msg_struct->hdr_req.message_type!=EAdd_Contact_Request);
+
+ if ( msg_struct->response != 1 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::AcceptAddRequestFromUser
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+Cisolationserver::SecondSearch( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ const gchar* search_label = GetSearchLabelL(connect_data->server,connect_data->key_given_name);
+ // adding key
+ len = strlen(search_label);
+ strcpy( smsg + index, search_label );
+ index += len + 1;
+
+ // adding value
+ len = strlen("sharath" );
+ strcpy( smsg + index, "sharath" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ gint temp = 0;
+ gchar* add_contact = NULL;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do
+ {
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //search message end---------------------------------------
+
+
+ //second search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+
+
+ const gchar* search_label1 = GetSearchLabelL(connect_data->server,connect_data->key_middle_name);
+ // adding key
+ len = strlen(search_label1);
+ strcpy( smsg + index, search_label1 );
+ index += len + 1;
+
+ // adding value
+ len = strlen("Jeppu" );
+ strcpy( smsg + index, "Jeppu" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do
+ {
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //search message end---------------------------------------
+
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+TInt Cisolationserver::AcceptAddRequestFromUser( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+ // getting add notification from user
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+
+ do {
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ // memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ char *userid = (char *)malloc(100);
+ len=0;
+ len+=sizeof(message_hdr_resp);
+ strcpy(userid,rmsg+len);
+ // accepting add request from user
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EReject_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ len=0;
+ len+=strlen(userid);
+ strcpy( smsg + index ,userid );
+ index += len + 1;
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendAcceptRequestWithoutReceivingAddrequest( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //Accepting Add request from contact without ne add notification --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EAccept_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++] = '\0';
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request);
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::SendRejectRequestWithoutReceivingAddrequest
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendRejectRequestWithoutReceivingAddrequest( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //Accepting Add request from contact without ne add notification --------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EReject_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ // adding add contact
+ len = strlen(connect_data->contact );
+ strcpy( smsg + index, connect_data->contact );
+ index += len + 1;
+ smsg[index++] = '\0';
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EReject_Contact_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //add contact end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::SendAcceptRequestWithoutAnyUserID
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SendAcceptRequestWithoutAnyUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+ // getting add notification from user
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+
+ do {
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ // memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ char *userid = (char *)malloc(100);
+ len=0;
+ len+=sizeof(message_hdr_resp);
+ strcpy(userid,rmsg+len);
+ // accepting add request from user
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EReject_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ //no need to send user id with this message
+ //len=0;
+ //len+=strlen(userid);
+ //strcpy( smsg + index ,userid );
+ //index += len + 1;
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EAccept_Contact_Request);
+ // need to check response
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::SendRejectRequestWithoutAnyUserID
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//RejectAddRequestFromUser
+TInt Cisolationserver::SendRejectRequestWithoutAnyUserID( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+
+ int timeout = 100;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //fetch end
+ // getting add notification from user
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+
+ do {
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ // memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ETrying_To_Add_Contact_Publish);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ char *userid = (char *)malloc(100);
+ len=0;
+ len+=sizeof(message_hdr_resp);
+ strcpy(userid,rmsg+len);
+
+
+
+
+ // rejecting add request from user
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EReject_Contact_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ //len=0;
+ //len+=strlen(userid);
+ //strcpy( smsg + index ,userid );
+ //index += len + 1;
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EReject_Contact_Request);
+
+ if ( msg_struct->response != 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+ // -----------------------------------------------------------------------------
+// Cisolationserver::Login with correct data
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::LogoutWhileUserIsNotLoggedIn( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+
+ FILE *fp;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ELogin_Request;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+ //appending password
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+ //appending server name
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+ // appending IAP id
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+ #endif
+ //running isoserver
+ run_isoserver();
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+ //fetch end
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ return_value = KErrNone;
+ goto return_code;
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+
+ }
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::GetSearchLabelForYukonL
+// -----------------------------------------------------------------------------
+const gchar* Cisolationserver::GetSearchLabelForYukonL(gchar *search_key)
+{
+if(strcmp(search_key,"user") == 0)
+ {
+ gchar* label= "User";
+ return label;
+ }
+else if(strcmp(search_key,"fn") == 0)
+ {
+ gchar* label= "Full Name";
+ return label;
+ }
+else if(strcmp(search_key,"first") == 0)
+ {
+ gchar* label= "Name";
+ return label;
+ }
+else if(strcmp(search_key,"middle") == 0)
+ {
+ gchar* label= "Middle Name";
+ return label;
+ }
+else if(strcmp(search_key,"last") == 0)
+ {
+ gchar* label= "Family Name";
+ return label;
+ }
+else if(strcmp(search_key,"nick") == 0)
+ {
+ gchar* label= "Nickname";
+ return label;
+ }
+else if(strcmp(search_key,"email") == 0)
+ {
+ gchar* label= "Email";
+ return label;
+ }
+else if(strcmp(search_key,"bday") == 0)
+ {
+ gchar* label= "Birthday";
+ return label;
+ }
+else if(strcmp(search_key,"ctry") == 0)
+ {
+ gchar* label= "Country";
+ return label;
+ }
+else if(strcmp(search_key,"orgname") == 0)
+ {
+ gchar* label= "Organization Name";
+ return label;
+ }
+else if(strcmp(search_key,"locality") == 0)
+ {
+ gchar* label= "City";
+ return label;
+ }
+else if(strcmp(search_key,"orgunit") == 0)
+ {
+ gchar* label= "Organization Unit";
+ return label;
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::GetSearchLabelForGizmoL
+// -----------------------------------------------------------------------------
+const gchar* Cisolationserver::GetSearchLabelForGizmoL(gchar *search_key)
+{
+if(strcmp(search_key,"xmpp_user") == 0)
+ {
+ gchar* label= "Account Name";
+ return label;
+ }
+else if(strcmp(search_key,"email_address") == 0)
+ {
+ gchar* label= "Email Address";
+ return label;
+ }
+else if(strcmp(search_key,"first_name") == 0)
+ {
+ gchar* label= "First Name";
+ return label;
+ }
+else if(strcmp(search_key,"last_name") == 0)
+ {
+ gchar* label= "Family Name";
+ return label;
+ }
+else if(strcmp(search_key,"country") == 0)
+ {
+ gchar* label= "Country";
+ return label;
+ }
+else if(strcmp(search_key,"state") == 0)
+ {
+ gchar* label= "State/Province";
+ return label;
+ }
+else if(strcmp(search_key,"city") == 0)
+ {
+ gchar* label= "City";
+ return label;
+ }
+else if(strcmp(search_key,"max_results") == 0)
+ {
+ gchar* label= "Maximum # of Results";
+ return label;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::GetSearchLabelL
+// -----------------------------------------------------------------------------
+const gchar* Cisolationserver::GetSearchLabelL(gchar* aService,gchar* aSearchKey)
+{
+if(strcmp(aService,"chat.gizmoproject.com") == 0)
+ {
+ GetSearchLabelForGizmoL(aSearchKey);
+ }
+else if(strcmp(aService,"chat.ovi.com") == 0 )
+ {
+ GetSearchLabelForYukonL(aSearchKey);
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::AcceptAddRequestFromUser
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+Cisolationserver::GetKeysAndSearch( CStifItemParser& aItem )
+ {
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+ TInt return_value = 0;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '0';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+ run_isoserver();
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+
+
+ // get search keys test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ESearch_Get_Keys;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ } while (msg_struct->hdr_req.message_type!= ESearch_Get_Keys );
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ int length = sizeof( message_hdr_resp );
+ char* search_value = NULL;
+ do {
+ search_value = strdup ( rmsg + length );
+
+ if ( !search_value )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ length += strlen( search_value ) + 1;
+ } while ( ( 0 != strcmp( "First Name", search_value ) )
+ && length < status &&( free ( search_value ), search_value = NULL, 1 ) );
+
+
+
+
+ //search messge--------------------------------------------
+
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = ESearch;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ // adding key
+ len = strlen( search_value );
+ strcpy( smsg + index, search_value );
+ index += len + 1;
+
+ // adding value
+ len = strlen( "santhosh" );
+ strcpy( smsg + index, "santhosh" );
+ index += len + 1;
+
+ smsg[index++] = '\0';
+
+ gint temp = 0;
+ gchar* add_contact = NULL;
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do
+ {
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ } while (msg_struct->hdr_req.message_type!= ESearch_State_Finished );
+
+ if ( msg_struct->response != 1 )
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //search message end---------------------------------------
+
+
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ // result = MsgQDelete(REQUEST_QUEUE, &err);
+ // result = MsgQDelete(RESPONSE_QUEUE, &err);
+ return_value = KErrNone;
+ goto return_code;
+
+//killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::set avatar
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::SetOwnAvatar( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+ //set avatar
+ TPtrC filename;
+ TPtrC mimetype;
+ gchar *file_name;
+ gchar *mime_type;
+ gchar *filecontent;
+ int n;
+ TBuf8<KMaxFileName> temp;
+
+ index = 0;
+ index += sizeof( message_hdr_req );
+ // setting avatar
+ FILE *file;
+ char *buffer;
+ unsigned long fileLen;
+
+ //Open file
+ file = fopen(connect_data->image_file_name, "rb");
+ if (!file)
+ {
+ fprintf(stderr, "Unable to open file %s", file_name);
+ return;
+ }
+
+ //Get file length
+ fseek(file, 0, SEEK_END);
+ fileLen=ftell(file);
+ fseek(file, 0, SEEK_SET);
+
+
+ //strcpy(mime_type,"image\jpeg");
+ len = fileLen + strlen(connect_data->mimetype) + 1;
+ buffer=(char *)malloc(len);
+ if (!buffer)
+ {
+ fprintf(stderr, "Memory error!");
+ fclose(file);
+ return;
+ }
+ memset( buffer, '\0', len );
+ memcpy( buffer, connect_data->mimetype, strlen(connect_data->mimetype) );
+ //Read file contents into buffer
+
+ fread(buffer + strlen(connect_data->mimetype) + 1, fileLen, 1, file);
+ fclose(file);
+
+ //Do what ever with buffer
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EUpdateOwnAvtar;
+ // memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ /* Send Message to queueOne */
+ TInt header_size = sizeof( message_hdr_req );
+ //crashes for perticuler image.Need to fix
+ char* one_pdu = ( char* ) malloc( ONE_K_OPENC_FIX );
+ //run a loop for rest of the data and keep track of the case of nBytes being
+ //multiple of 1020 - sizeof(msghdr) and it being not
+ //Amount of payload that can be sent
+ TInt single_read = ONE_K_OPENC_FIX - header_size;
+ //Data recieved from PublishOwnPresenceL has message header at begining
+ TInt actual_data = fileLen;
+ //No of packets needed to send the image data
+ TInt total_packets = (TInt)ceil( ( double ) ( actual_data ) / single_read );
+ //This offset moves thru the msg pointer
+ TInt navigate_offset = 0;
+ for ( TInt i = 0; i < total_packets; i++ )
+ {
+ //till the last packet size_tobe_sent will be ONE_K_OPENC_FIX
+ //last packet data is actual_data % single_read if less than single_read else ONE_K_OPENC_FIX
+ TInt size_tobe_sent = ( i < total_packets - 1 ) ? ONE_K_OPENC_FIX :
+ ( actual_data % single_read ?
+ actual_data % single_read + header_size : ONE_K_OPENC_FIX );
+
+ if ( i < total_packets - 1 )
+ {
+ msgHdr->continue_flag = 1;
+ }
+ else
+ {
+ msgHdr->continue_flag = 0;
+ }
+
+ //memcpy ( msg + header_size , msg + navigate_offset, size_tobe_sent - header_size );
+ memcpy( one_pdu , msgHdr, header_size );
+ memcpy( one_pdu + header_size, buffer + navigate_offset, size_tobe_sent - header_size );
+ result = MsgQSend ( REQUEST_QUEUE, one_pdu, size_tobe_sent,
+ MSG_PRI_NORMAL, timeout, &err );
+ User::LeaveIfError ( result );
+ navigate_offset += single_read;
+ }
+ free(one_pdu);
+ free(buffer);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EUpdateOwnAvtar);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+ //set avatar end
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::clear avatar
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::ClearOwnAvatar( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ for (int i= 0 ;i<3 ;i++)
+ {
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (!((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts))&& 0 == msg_struct->continue_flag);
+ fclose(fp);
+
+ }
+
+ //fetch end
+
+ //clear avatar
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EClearOwnAvatar;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ smsg[index++]='\0';
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=EClearOwnAvatar);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //clear avatar end
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::clear avatar
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cisolationserver::FetchCachedContacts( CStifItemParser& aItem )
+ {
+
+
+ ConnectData *connect_data = NULL;
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ FILE *fp;
+
+ int timeout = 200;
+ int nBytes;
+
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+ int len = strlen(connect_data->username);
+ strcpy( smsg + index, connect_data->username );
+ index += len + 1;
+
+ //appending password
+
+ len = strlen(connect_data->password );
+ strcpy( smsg + index, connect_data->password );
+ index += len + 1;
+
+ //appending server name
+
+ len = strlen(connect_data->server );
+ strcpy( smsg + index, connect_data->server );
+ index += len + 1;
+
+ //appending resource
+ len = strlen(connect_data->resource );
+ strcpy( smsg + index, connect_data->resource );
+ index += len + 1;
+
+ //appending ssl
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending server port
+ len = strlen(connect_data->port );
+ strcpy( smsg + index, connect_data->port );
+ index += len + 1;
+
+ // appending IAP id
+
+ smsg[index++]= '1';
+ smsg[index++]= '\0';
+
+ //appending connmgr_bus
+ len = strlen(connect_data->connmgr_bus );
+ strcpy( smsg + index, connect_data->connmgr_bus );
+ index += len + 1;
+
+ //appending connmgr_path
+ len = strlen(connect_data->connmgr_path );
+ strcpy( smsg + index, connect_data->connmgr_path );
+ index += len + 1;
+
+ //appending protocol
+ len = strlen(connect_data->protocol );
+ strcpy( smsg + index, connect_data->protocol );
+ index += len + 1;
+
+ #ifdef __WINSCW__
+ //proxy server
+ len = strlen(connect_data->proxy_data->proxy_server );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_server );
+ index += len + 1;
+
+ //proxy port
+ len = strlen(connect_data->proxy_data->proxy_port );
+ strcpy( smsg + index, connect_data->proxy_data->proxy_port );
+ index += len + 1;
+
+ #endif
+
+ //running isoserver
+ run_isoserver();
+
+
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+
+
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ msg_struct = ( message_hdr_resp* ) malloc( sizeof( message_hdr_resp ) );
+ memset( msg_struct, '\0', sizeof( message_hdr_resp ) );
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+
+ if( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+
+
+ // login end
+
+ //fetch req..
+ TInt count = 0;
+
+ fp = fopen("c:\\fetch_contact.txt","a");
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fp);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ if ( (msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts) && 0 == msg_struct->continue_flag )
+ {
+ count++;
+ }
+
+
+ } while (count < 3 );
+ fclose(fp);
+
+
+
+
+ //fetch end
+ FILE* fop = NULL;
+ //clear avatar
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ index=0;
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EFetchCachedContacts;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ smsg[index++]='\0';
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ fop = fopen("c:\\santhosh.txt","a");
+ count = 0;
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ fwrite(rmsg,1,status,fop);
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ if ( ((msg_struct->hdr_req.message_type==ECurrent_Member_Contacts)
+ ||(msg_struct->hdr_req.message_type==ELocal_Pending_Contacts)
+ ||(msg_struct->hdr_req.message_type==ERemote_Pending_Contacts)) && 0 == msg_struct->continue_flag )
+ {
+ count++;
+ }
+
+
+ } while (count < 3 );
+ fclose(fop);
+
+ //clear avatar end
+ // logout test code from server
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogout_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ do {
+ status = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, 2000, &err);
+ memcpy( msg_struct, rmsg, sizeof( message_hdr_resp ) );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ } while (msg_struct->hdr_req.message_type!=ELogout_Request);
+
+ if ( msg_struct->response != 1)
+ {
+ return_value = KErrGeneral;
+ goto return_code;
+ }
+ //killing isoserver
+ return_code:
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free( msg_struct );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// Cisolationserver::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*
+TInt Cisolationserver::?member_function(
+ CItemParser& aItem )
+ {
+
+ ?code
+
+ }
+*/
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+// [End of File] - Do not remove
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+ <!ENTITY layer_real_source_path "sf/mw/opensrv" >
+]>
+
+<SystemDefinition name="opensrv" schema="1.4.0">
+ <systemModel>
+ <layer name="mw_layer">
+ <module name="opensrv">
+ <unit unitID="MeCoDo.opensrv" mrp="" bldFile="&layer_real_source_path;/group" name="opensrv" />
+ </module>
+ </layer>
+ </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/bwins/libtelepathyu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,18 @@
+EXPORTS
+ tp_chan_get_interface @ 1 NONAME
+ tp_chan_new @ 2 NONAME
+ tp_conn_get_interface @ 3 NONAME
+ tp_conn_get_type @ 4 NONAME
+ tp_conn_new_channel @ 5 NONAME
+ tp_connmgr_get_parameters @ 6 NONAME
+ tp_connmgr_list_protocols @ 7 NONAME
+ tp_connmgr_new @ 8 NONAME
+ tp_connmgr_new_connection @ 9 NONAME
+ tp_get_chan_contactsearch_interface @ 10 NONAME
+ tp_get_chan_group_interface @ 11 NONAME
+ tp_get_chan_text_interface @ 12 NONAME
+ tp_get_conn_avatar_interface @ 13 NONAME
+ tp_get_conn_presence_interface @ 14 NONAME
+ tp_get_props_interface @ 15 NONAME
+ tp_props_iface_get_type @ 16 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/eabi/libtelepathyu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,18 @@
+EXPORTS
+ tp_chan_get_interface @ 1 NONAME
+ tp_chan_new @ 2 NONAME
+ tp_conn_get_interface @ 3 NONAME
+ tp_conn_get_type @ 4 NONAME
+ tp_conn_new_channel @ 5 NONAME
+ tp_connmgr_get_parameters @ 6 NONAME
+ tp_connmgr_list_protocols @ 7 NONAME
+ tp_connmgr_new @ 8 NONAME
+ tp_connmgr_new_connection @ 9 NONAME
+ tp_get_chan_contactsearch_interface @ 10 NONAME
+ tp_get_chan_group_interface @ 11 NONAME
+ tp_get_chan_text_interface @ 12 NONAME
+ tp_get_conn_avatar_interface @ 13 NONAME
+ tp_get_conn_presence_interface @ 14 NONAME
+ tp_get_props_interface @ 15 NONAME
+ tp_props_iface_get_type @ 16 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,40 @@
+/* bld.inf
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+// Project configuration file for dbus
+
+// Project platforms
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+#include <platform_paths.hrh>
+
+// Project exports
+PRJ_EXPORTS
+../rom/libtelepathy.iby CORE_MW_LAYER_IBY_EXPORT_PATH(libtelepathy.iby)
+
+
+
+
+// MMP files for project components
+PRJ_MMPFILES
+libtelepathy.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/group/libtelepathy.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,98 @@
+/* libtelepathy.mmp
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+// General properties
+#include<platform_paths.hrh>
+TARGET libtelepathy.dll
+TARGETTYPE dll
+CAPABILITY CAP_GENERAL_DLL
+UID 0x1000008d 0x2000F850
+
+VERSION 10.0
+#ifndef WINSCW
+// Allow global writeable static data
+EPOCALLOWDLLDATA
+#endif
+
+// Macros
+MACRO SYMBIAN
+MACRO HAVE_CONFIG_H
+MACRO HAVE_ERRNO_H VERBOSE
+
+#ifdef WINSCW
+MACRO EMULATOR
+#endif
+
+
+SOURCEPATH ../src
+//START RESOURCE dbus-daemon_reg.rss
+#ifdef WINSCW
+TARGETPATH /private/10003a3f/apps
+#else
+TARGETPATH /private/10003a3f/import/apps
+#endif
+//END //RESOURCE
+
+// Source files
+#ifdef WINSCW
+SOURCE libtelepathy_wsd.cpp
+#endif /*WINSCW*/
+
+SOURCE tp-chan.c
+SOURCE tp-chan-ifaces-signal-setters.c
+SOURCE tp-chan-signals-marshal.c
+SOURCE tp-conn.c
+SOURCE tp-conn-ifaces-signal-setters.c
+SOURCE tp-connmgr.c
+SOURCE tp-connmgr-signals-marshal.c
+SOURCE tp-conn-signals-marshal.c
+SOURCE tp-helpers.c
+SOURCE tp-ifaces-signals-marshal.c
+SOURCE tp-props-iface.c
+
+// User include paths
+USERINCLUDE ../inc
+
+// System include paths
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+
+// Library dependencies
+#ifdef GCCE
+STATICLIBRARY libcrt0_gcce.lib
+#else
+STATICLIBRARY libcrt0.lib
+#endif
+LIBRARY libdbus.lib
+LIBRARY libc.lib
+LIBRARY libglib.lib
+LIBRARY libgobject.lib
+LIBRARY libdbus-glib.lib
+
+#ifdef WINSCW
+LIBRARY euser.lib // Needed in order to use Symbian services
+//wsd solution
+LIBRARY ewsd.lib
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-ch-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,71 @@
+/* tp-ch-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_ChannelHandler
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_ChannelHandler
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ch_handle_channel (DBusGProxy *proxy, const char * IN_bus_name, const char* IN_connection, const char * IN_channel_type, const char* IN_channel, const guint IN_handle_type, const guint IN_handle, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "HandleChannel", error, G_TYPE_STRING, IN_bus_name, DBUS_TYPE_G_OBJECT_PATH, IN_connection, G_TYPE_STRING, IN_channel_type, DBUS_TYPE_G_OBJECT_PATH, IN_channel, G_TYPE_UINT, IN_handle_type, G_TYPE_UINT, IN_handle, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ch_handle_channel_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ch_handle_channel_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ch_handle_channel_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ch_handle_channel_async (DBusGProxy *proxy, const char * IN_bus_name, const char* IN_connection, const char * IN_channel_type, const char* IN_channel, const guint IN_handle_type, const guint IN_handle, tp_ch_handle_channel_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "HandleChannel", tp_ch_handle_channel_async_callback, stuff, g_free, G_TYPE_STRING, IN_bus_name, DBUS_TYPE_G_OBJECT_PATH, IN_connection, G_TYPE_STRING, IN_channel_type, DBUS_TYPE_G_OBJECT_PATH, IN_channel, G_TYPE_UINT, IN_handle_type, G_TYPE_UINT, IN_handle, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_ChannelHandler */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,186 @@
+/* tp-chan.gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_close (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Close", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_close_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_close_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_close_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_close_async (DBusGProxy *proxy, tp_chan_close_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Close", tp_chan_close_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_get_channel_type (DBusGProxy *proxy, char ** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetChannelType", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_get_channel_type_reply) (DBusGProxy *proxy, char * OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_get_channel_type_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char * OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_get_channel_type_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_get_channel_type_async (DBusGProxy *proxy, tp_chan_get_channel_type_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetChannelType", tp_chan_get_channel_type_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_get_handle (DBusGProxy *proxy, guint* OUT_arg0, guint* OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetHandle", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_UINT, OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_get_handle_reply) (DBusGProxy *proxy, guint OUT_arg0, guint OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_chan_get_handle_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ guint OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_UINT, &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_chan_get_handle_reply)data->cb) (proxy, OUT_arg0, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_get_handle_async (DBusGProxy *proxy, tp_chan_get_handle_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetHandle", tp_chan_get_handle_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_get_interfaces (DBusGProxy *proxy, char *** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetInterfaces", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_get_interfaces_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_get_interfaces_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_get_interfaces_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_get_interfaces_async (DBusGProxy *proxy, tp_chan_get_interfaces_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetInterfaces", tp_chan_get_interfaces_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-iface-dtmf-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,71 @@
+/* tp-chan-iface-dtmf-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_DTMF
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_DTMF
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_dtmf_send_dt_mf (DBusGProxy *proxy, const guint IN_signal, const guint IN_duration, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SendDTMF", error, G_TYPE_UINT, IN_signal, G_TYPE_UINT, IN_duration, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_dtmf_send_dt_mf_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_dtmf_send_dt_mf_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_iface_dtmf_send_dt_mf_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_dtmf_send_dt_mf_async (DBusGProxy *proxy, const guint IN_signal, const guint IN_duration, tp_chan_iface_dtmf_send_dt_mf_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SendDTMF", tp_chan_iface_dtmf_send_dt_mf_async_callback, stuff, g_free, G_TYPE_UINT, IN_signal, G_TYPE_UINT, IN_duration, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_DTMF */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-iface-group-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,376 @@
+/* tp-chan-iface-group-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Group
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Group
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_add_members (DBusGProxy *proxy, const GArray* IN_contacts, const char * IN_message, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "AddMembers", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_STRING, IN_message, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_add_members_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_add_members_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_add_members_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_add_members_async (DBusGProxy *proxy, const GArray* IN_contacts, const char * IN_message, tp_chan_iface_group_add_members_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "AddMembers", tp_chan_iface_group_add_members_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_STRING, IN_message, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_all_members (DBusGProxy *proxy, GArray** OUT_arg0, GArray** OUT_arg1, GArray** OUT_arg2, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetAllMembers", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg0, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg1, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg2, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_all_members_reply) (DBusGProxy *proxy, GArray *OUT_arg0, GArray *OUT_arg1, GArray *OUT_arg2, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_all_members_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg0;
+ GArray* OUT_arg1;
+ GArray* OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg0, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg1, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_all_members_reply)data->cb) (proxy, OUT_arg0, OUT_arg1, OUT_arg2, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_all_members_async (DBusGProxy *proxy, tp_chan_iface_group_get_all_members_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetAllMembers", tp_chan_iface_group_get_all_members_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_group_flags (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetGroupFlags", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_group_flags_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_group_flags_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_group_flags_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_group_flags_async (DBusGProxy *proxy, tp_chan_iface_group_get_group_flags_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetGroupFlags", tp_chan_iface_group_get_group_flags_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_handle_owners (DBusGProxy *proxy, const GArray* IN_handles, GArray** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetHandleOwners", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_handle_owners_reply) (DBusGProxy *proxy, GArray *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_handle_owners_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_handle_owners_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_handle_owners_async (DBusGProxy *proxy, const GArray* IN_handles, tp_chan_iface_group_get_handle_owners_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetHandleOwners", tp_chan_iface_group_get_handle_owners_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_local_pending_members (DBusGProxy *proxy, GArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetLocalPendingMembers", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_local_pending_members_reply) (DBusGProxy *proxy, GArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_local_pending_members_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_local_pending_members_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_local_pending_members_async (DBusGProxy *proxy, tp_chan_iface_group_get_local_pending_members_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetLocalPendingMembers", tp_chan_iface_group_get_local_pending_members_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_members (DBusGProxy *proxy, GArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetMembers", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_members_reply) (DBusGProxy *proxy, GArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_members_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_members_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_members_async (DBusGProxy *proxy, tp_chan_iface_group_get_members_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetMembers", tp_chan_iface_group_get_members_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_remote_pending_members (DBusGProxy *proxy, GArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetRemotePendingMembers", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_remote_pending_members_reply) (DBusGProxy *proxy, GArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_remote_pending_members_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_remote_pending_members_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_remote_pending_members_async (DBusGProxy *proxy, tp_chan_iface_group_get_remote_pending_members_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetRemotePendingMembers", tp_chan_iface_group_get_remote_pending_members_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_get_self_handle (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetSelfHandle", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_get_self_handle_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_get_self_handle_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_get_self_handle_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_get_self_handle_async (DBusGProxy *proxy, tp_chan_iface_group_get_self_handle_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetSelfHandle", tp_chan_iface_group_get_self_handle_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_group_remove_members (DBusGProxy *proxy, const GArray* IN_contacts, const char * IN_message, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RemoveMembers", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_STRING, IN_message, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_group_remove_members_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_group_remove_members_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_iface_group_remove_members_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_group_remove_members_async (DBusGProxy *proxy, const GArray* IN_contacts, const char * IN_message, tp_chan_iface_group_remove_members_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RemoveMembers", tp_chan_iface_group_remove_members_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_STRING, IN_message, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Group */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-iface-hold-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,109 @@
+/* tp-chan-iface-hold-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Hold
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Hold
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_hold_get_hold_state (DBusGProxy *proxy, const guint IN_member, guint* OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetHoldState", error, G_TYPE_UINT, IN_member, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_hold_get_hold_state_reply) (DBusGProxy *proxy, guint OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_hold_get_hold_state_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_chan_iface_hold_get_hold_state_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_hold_get_hold_state_async (DBusGProxy *proxy, const guint IN_member, tp_chan_iface_hold_get_hold_state_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetHoldState", tp_chan_iface_hold_get_hold_state_async_callback, stuff, g_free, G_TYPE_UINT, IN_member, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_hold_request_hold (DBusGProxy *proxy, const guint IN_member, const gboolean IN_hold, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestHold", error, G_TYPE_UINT, IN_member, G_TYPE_BOOLEAN, IN_hold, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_hold_request_hold_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_hold_request_hold_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_iface_hold_request_hold_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_hold_request_hold_async (DBusGProxy *proxy, const guint IN_member, const gboolean IN_hold, tp_chan_iface_hold_request_hold_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestHold", tp_chan_iface_hold_request_hold_async_callback, stuff, g_free, G_TYPE_UINT, IN_member, G_TYPE_BOOLEAN, IN_hold, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Hold */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-iface-ice-signalling-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,72 @@
+/* tp-chan-iface-ice-signalling-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_IceSignalling
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_IceSignalling
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_ice_signalling_get_session_handlers (DBusGProxy *proxy, GPtrArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetSessionHandlers", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_INVALID)), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_ice_signalling_get_session_handlers_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_ice_signalling_get_session_handlers_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_INVALID)), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_ice_signalling_get_session_handlers_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_ice_signalling_get_session_handlers_async (DBusGProxy *proxy, tp_chan_iface_ice_signalling_get_session_handlers_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetSessionHandlers", tp_chan_iface_ice_signalling_get_session_handlers_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_IceSignalling */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-iface-password-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,110 @@
+/* tp-chan-iface-password-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Password
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Password
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_password_get_password_flags (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetPasswordFlags", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_password_get_password_flags_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_password_get_password_flags_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_iface_password_get_password_flags_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_password_get_password_flags_async (DBusGProxy *proxy, tp_chan_iface_password_get_password_flags_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetPasswordFlags", tp_chan_iface_password_get_password_flags_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_password_provide_password (DBusGProxy *proxy, const char * IN_password, gboolean* OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ProvidePassword", error, G_TYPE_STRING, IN_password, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_password_provide_password_reply) (DBusGProxy *proxy, gboolean OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_password_provide_password_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ gboolean OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_chan_iface_password_provide_password_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_password_provide_password_async (DBusGProxy *proxy, const char * IN_password, tp_chan_iface_password_provide_password_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ProvidePassword", tp_chan_iface_password_provide_password_async_callback, stuff, g_free, G_TYPE_STRING, IN_password, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Password */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-iface-transfer-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,71 @@
+/*tp-chan-iface-transfer-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Transfer
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Transfer
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_iface_transfer_transfer (DBusGProxy *proxy, const guint IN_member, const guint IN_destination, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Transfer", error, G_TYPE_UINT, IN_member, G_TYPE_UINT, IN_destination, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_iface_transfer_transfer_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_iface_transfer_transfer_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_iface_transfer_transfer_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_iface_transfer_transfer_async (DBusGProxy *proxy, const guint IN_member, const guint IN_destination, tp_chan_iface_transfer_transfer_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Transfer", tp_chan_iface_transfer_transfer_async_callback, stuff, g_free, G_TYPE_UINT, IN_member, G_TYPE_UINT, IN_destination, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Interface_Transfer */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-ifaces-signal-setters.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+/* tp-chan-ifaces-signal-setters.h
+ *
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef TP_CHAN_IFACES_SETTERS_H
+#define TP_CHAN_IFACES_SETTERS_H
+
+#include <dbus/dbus-glib.h>
+
+/* This header file contains definitions for the signal signature setters
+ * for the various interfaces provided by Channel */
+
+
+void tp_chan_set_contactsearch_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_streamedmedia_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_roomlist_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_text_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_dtmf_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_group_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_hold_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_password_signatures(DBusGProxy *proxy);
+
+void tp_chan_set_icesignalling_signatures(DBusGProxy *proxy);
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,34 @@
+/* tp-chan-signals-marshal.h
+ *
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __tp_chan_signals_marshal_MARSHAL_H__
+#define __tp_chan_signals_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:VOID (tp-chan-signals-marshal.list:1) */
+#define tp_chan_signals_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID
+
+G_END_DECLS
+
+#endif /* __tp_chan_signals_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-type-contact-list-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,29 @@
+/* tp-chan-type-contact-list-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-type-room-list-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,109 @@
+/* tp-chan-type-room-list-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_RoomList
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_RoomList
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_room_list_get_listing_rooms (DBusGProxy *proxy, gboolean* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetListingRooms", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_room_list_get_listing_rooms_reply) (DBusGProxy *proxy, gboolean OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_room_list_get_listing_rooms_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ gboolean OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_type_room_list_get_listing_rooms_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_room_list_get_listing_rooms_async (DBusGProxy *proxy, tp_chan_type_room_list_get_listing_rooms_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetListingRooms", tp_chan_type_room_list_get_listing_rooms_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_room_list_list_rooms (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ListRooms", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_room_list_list_rooms_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_room_list_list_rooms_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_type_room_list_list_rooms_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_room_list_list_rooms_async (DBusGProxy *proxy, tp_chan_type_room_list_list_rooms_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ListRooms", tp_chan_type_room_list_list_rooms_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_RoomList */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-type-search-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,166 @@
+/* tp-chan-type-search-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_Search
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_Search
+
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_search (DBusGProxy *proxy, const GHashTable* IN_terms, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Search", error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_terms, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_search_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_search_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error,G_TYPE_INVALID);
+ (*(tp_chan_type_search_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_search_async (DBusGProxy *proxy, const GHashTable *IN_params, tp_chan_type_search_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Search", tp_chan_type_search_async_callback, stuff, g_free, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_params, G_TYPE_INVALID);
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_search_get_search_state (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetSearchState", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_search_get_search_state_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_search_get_search_state_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error,G_TYPE_UINT, &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_chan_type_search_get_search_state_reply)data->cb) (proxy, OUT_arg2, error, data->userdata);
+ return;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_search_get_search_state_async (DBusGProxy *proxy, tp_chan_type_search_get_search_state_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetSearchState", tp_chan_type_search_get_search_state_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_search_get_search_keys (DBusGProxy *proxy, char ** OUT_arg0, char *** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetSearchKeys", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg0, G_TYPE_STRV, OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_search_get_search_keys_reply) (DBusGProxy *proxy, char * OUT_arg0, char * *OUT_arg1, GError *error, gpointer userdata);
+
+
+static void
+tp_chan_type_search_get_search_keys_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ char * OUT_arg0;
+ char ** OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg0, G_TYPE_STRV, &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_chan_type_search_get_search_keys_reply)data->cb) (proxy, OUT_arg0, OUT_arg1, error, data->userdata);
+ return;
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_search_get_search_keys_async (DBusGProxy *proxy, tp_chan_type_search_get_search_keys_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetSearchKeys", tp_chan_type_search_get_search_keys_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+
+
+
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_Search */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-type-streamed-media-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,110 @@
+/* tp-chan-type-streamed-media-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_StreamedMedia
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_StreamedMedia
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_streamed_media_list_streams (DBusGProxy *proxy, GPtrArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ListStreams", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_streamed_media_list_streams_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_streamed_media_list_streams_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_type_streamed_media_list_streams_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_streamed_media_list_streams_async (DBusGProxy *proxy, tp_chan_type_streamed_media_list_streams_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ListStreams", tp_chan_type_streamed_media_list_streams_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_streamed_media_request_streams (DBusGProxy *proxy, const guint IN_contact_handle, const GArray* IN_types, GArray** OUT_arg2, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestStreams", error, G_TYPE_UINT, IN_contact_handle, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_types, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg2, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_streamed_media_request_streams_reply) (DBusGProxy *proxy, GArray *OUT_arg2, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_streamed_media_request_streams_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_chan_type_streamed_media_request_streams_reply)data->cb) (proxy, OUT_arg2, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_streamed_media_request_streams_async (DBusGProxy *proxy, const guint IN_contact_handle, const GArray* IN_types, tp_chan_type_streamed_media_request_streams_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestStreams", tp_chan_type_streamed_media_request_streams_async_callback, stuff, g_free, G_TYPE_UINT, IN_contact_handle, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_types, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_StreamedMedia */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan-type-text-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,189 @@
+/* tp-chan-type-text-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_Text
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_Text
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_text_acknowledge_pending_messages (DBusGProxy *proxy, const GArray* IN_ids, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "AcknowledgePendingMessages", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_ids, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_text_acknowledge_pending_messages_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_text_acknowledge_pending_messages_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_type_text_acknowledge_pending_messages_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_text_acknowledge_pending_messages_async (DBusGProxy *proxy, const GArray* IN_ids, tp_chan_type_text_acknowledge_pending_messages_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "AcknowledgePendingMessages", tp_chan_type_text_acknowledge_pending_messages_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_ids, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_text_get_message_types (DBusGProxy *proxy, GArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetMessageTypes", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_text_get_message_types_reply) (DBusGProxy *proxy, GArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_text_get_message_types_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_chan_type_text_get_message_types_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_text_get_message_types_async (DBusGProxy *proxy, tp_chan_type_text_get_message_types_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetMessageTypes", tp_chan_type_text_get_message_types_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_text_list_pending_messages (DBusGProxy *proxy, const gboolean IN_clear, GPtrArray** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ListPendingMessages", error, G_TYPE_BOOLEAN, IN_clear, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID)), OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_text_list_pending_messages_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_text_list_pending_messages_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID)), &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_chan_type_text_list_pending_messages_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_text_list_pending_messages_async (DBusGProxy *proxy, const gboolean IN_clear, tp_chan_type_text_list_pending_messages_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ListPendingMessages", tp_chan_type_text_list_pending_messages_async_callback, stuff, g_free, G_TYPE_BOOLEAN, IN_clear, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_chan_type_text_send (DBusGProxy *proxy, const guint IN_type, const char * IN_text, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Send", error, G_TYPE_UINT, IN_type, G_TYPE_STRING, IN_text, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_chan_type_text_send_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_chan_type_text_send_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_chan_type_text_send_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_chan_type_text_send_async (DBusGProxy *proxy, const guint IN_type, const char * IN_text, tp_chan_type_text_send_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ GError *error = NULL;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ //callback(proxy, error, userdata);
+ return dbus_g_proxy_begin_call (proxy, "Send", tp_chan_type_text_send_async_callback, stuff, g_free, G_TYPE_UINT, IN_type, G_TYPE_STRING, IN_text, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Channel_Type_Text */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-chan.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,209 @@
+/* tp-chan.h
+ *
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef TP_CHAN_H
+#define TP_CHAN_H
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+#include "tp-chan-gen.h"
+#include "tp-interfaces.h"
+#include "tp-chan-signals-marshal.h"
+#include "tp-ifaces-signals-marshal.h"
+#include "tp-chan-ifaces-signal-setters.h"
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+
+
+#define TELEPATHY_CHAN_TYPE (tp_chan_get_type ())
+
+#define TELEPATHY_CHAN(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), TELEPATHY_CHAN_TYPE, \
+ TpChan))
+
+#define TELEPATHY_CHAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), TELEPATHY_CHAN_TYPE, \
+ TpChanClass))
+
+#define TELEPATHY_IS_CHAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), TELEPATHY_CHAN_TYPE))
+
+#define TELEPATHY_IS_CHAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE \
+ ((klass), TELEPATHY_CHAN_TYPE))
+
+#define TELEPATHY_CHAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), TELEPATHY_CHAN_TYPE, \
+ TpChanClass))
+
+#define TELEPATHY_CHAN_IFACE_QUARK (tp_get_chan_interface())
+#define TELEPATHY_CHAN_IFACE_CONTACTLIST_QUARK (tp_get_chan_contactlist_interface())
+#define TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK (tp_get_chan_contactsearch_interface())
+#define TELEPATHY_CHAN_IFACE_STREAMED_QUARK (tp_get_chan_streamed_interface())
+#define TELEPATHY_CHAN_IFACE_ROOMLIST_QUARK (tp_get_chan_roomlist_interface())
+#define TELEPATHY_CHAN_IFACE_TEXT_QUARK (tp_get_chan_text_interface())
+#define TELEPATHY_CHAN_IFACE_DTMF_QUARK (tp_get_chan_dtmf_interface())
+#define TELEPATHY_CHAN_IFACE_GROUP_QUARK (tp_get_chan_group_interface())
+#define TELEPATHY_CHAN_IFACE_HOLD_QUARK (tp_get_chan_hold_interface())
+#define TELEPATHY_CHAN_IFACE_PASSWORD_QUARK (tp_get_chan_password_interface())
+#define TELEPATHY_CHAN_IFACE_TRANSFER_QUARK (tp_get_chan_transfer_interface())
+
+/* The signal name for the synthesized Closed signal */
+#define TP_IFACE_CHAN_SIGNAL_CLOSED_SYNTHESIZED \
+ "received::org-freedesktop-Telepathy-Channel-Closed"
+
+typedef struct _tp_chan TpChan;
+typedef struct _tp_chanclass TpChanClass;
+
+struct _tp_chan
+{
+ DBusGProxy parent;
+ gchar *type;
+ guint handle_type;
+ guint handle;
+ GData *interface_list;
+ gboolean first_run;
+};
+
+struct _tp_chanclass
+{
+ DBusGProxyClass parent_class;
+ GData *iface_signal_sigs;
+};
+
+GType tp_chan_get_type(void);
+
+/* Actual function definitions */
+
+
+/*
+ * Creates a new channel object.
+ *
+ * @param connection: The D-BUS connection for this channel.
+ * @param bus_name: The D-BUS bus name for this channel.
+ * @param object_name: The name of the D-BUS path for this channel.
+ * @param type: The type string for this channel.
+ * @param handle_type: The type of this channel.
+ * @param handle: The handle of this channel, will be filled by this call.
+ * @return A new TpChan (channel) object, or NULL if unsuccesfull
+ */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+TpChan *tp_chan_new(DBusGConnection *connection, const gchar *bus_name,
+ const gchar *object_path, const gchar *type,
+ guint handle_type, guint handle);
+#ifdef __cplusplus
+}
+#endif
+
+
+/* Create and store the D-BUS proxy objects for the interfaces provided
+ * by this channel. Expects data provided by the GetInterfaces method.
+ *
+ * @param self: The channel object whose interfaces will be stored.
+ * @param interfaces: The array of strings containing the interface names
+ *
+ */
+
+
+void tp_chan_local_set_interfaces(TpChan *self, gchar **interfaces);
+
+
+/*
+ * This function checks whether the channel has the specified
+ * interface and returns a proxy object that can be used to call
+ * its methods, if it exists. The supported interfaces are listed
+ * in the beginning of this header as macros.
+ *
+ * @param self The channel object that is queried for the interface
+ * proxy object
+ * @param iface_quark GQuark corresponding to the interface name
+ * string.
+ * @return A DBusGProxy object for the interface, or NULL if not found
+ */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+DBusGProxy *tp_chan_get_interface(TpChan *self, GQuark iface_quark);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+GQuark tp_get_chan_interface(void);
+GQuark tp_get_chan_contactlist_interface(void);
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GQuark tp_get_chan_contactsearch_interface(void);
+#ifdef __cplusplus
+}
+#endif
+GQuark tp_get_chan_streamed_interface(void);
+GQuark tp_get_chan_roomlist_interface(void);
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GQuark tp_get_chan_group_interface(void);
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GQuark tp_get_chan_text_interface(void);
+GQuark tp_get_chan_dtmf_interface(void);
+GQuark tp_get_chan_hold_interface(void);
+GQuark tp_get_chan_password_interface(void);
+GQuark tp_get_chan_transfer_interface(void);
+#ifdef __cplusplus
+}
+#endif
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,486 @@
+/* tp-conn-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_connect (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Connect", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_connect_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_connect_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_connect_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_connect_async (DBusGProxy *proxy, tp_conn_connect_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Connect", tp_conn_connect_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_disconnect (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Disconnect", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_disconnect_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_disconnect_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_disconnect_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_disconnect_async (DBusGProxy *proxy, tp_conn_disconnect_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Disconnect", tp_conn_disconnect_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_get_interfaces (DBusGProxy *proxy, char *** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetInterfaces", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_get_interfaces_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_get_interfaces_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_get_interfaces_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_get_interfaces_async (DBusGProxy *proxy, tp_conn_get_interfaces_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetInterfaces", tp_conn_get_interfaces_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_get_protocol (DBusGProxy *proxy, char ** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetProtocol", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_get_protocol_reply) (DBusGProxy *proxy, char * OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_get_protocol_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char * OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_get_protocol_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_get_protocol_async (DBusGProxy *proxy, tp_conn_get_protocol_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetProtocol", tp_conn_get_protocol_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_get_self_handle (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetSelfHandle", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_get_self_handle_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_get_self_handle_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_get_self_handle_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_get_self_handle_async (DBusGProxy *proxy, tp_conn_get_self_handle_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetSelfHandle", tp_conn_get_self_handle_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_get_status (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetStatus", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_get_status_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_get_status_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_get_status_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_get_status_async (DBusGProxy *proxy, tp_conn_get_status_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetStatus", tp_conn_get_status_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_hold_handles (DBusGProxy *proxy, const guint IN_handle_type, const GArray* IN_handles, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "HoldHandles", error, G_TYPE_UINT, IN_handle_type, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_hold_handles_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_hold_handles_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_hold_handles_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_hold_handles_async (DBusGProxy *proxy, const guint IN_handle_type, const GArray* IN_handles, tp_conn_hold_handles_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "HoldHandles", tp_conn_hold_handles_async_callback, stuff, g_free, G_TYPE_UINT, IN_handle_type, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_inspect_handles (DBusGProxy *proxy, const guint IN_handle_type, const GArray* IN_handles, char *** OUT_arg2, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "InspectHandles", error, G_TYPE_UINT, IN_handle_type, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg2, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_inspect_handles_reply) (DBusGProxy *proxy, char * *OUT_arg2, GError *error, gpointer userdata);
+
+static void
+tp_conn_inspect_handles_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_conn_inspect_handles_reply)data->cb) (proxy, OUT_arg2, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_inspect_handles_async (DBusGProxy *proxy, const guint IN_handle_type, const GArray* IN_handles, tp_conn_inspect_handles_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "InspectHandles", tp_conn_inspect_handles_async_callback, stuff, g_free, G_TYPE_UINT, IN_handle_type, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_list_channels (DBusGProxy *proxy, GPtrArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ListChannels", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_list_channels_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_list_channels_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_list_channels_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_list_channels_async (DBusGProxy *proxy, tp_conn_list_channels_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ListChannels", tp_conn_list_channels_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_release_handles (DBusGProxy *proxy, const guint IN_handle_type, const GArray* IN_handles, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ReleaseHandles", error, G_TYPE_UINT, IN_handle_type, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_release_handles_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_release_handles_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_release_handles_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_release_handles_async (DBusGProxy *proxy, const guint IN_handle_type, const GArray* IN_handles, tp_conn_release_handles_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ReleaseHandles", tp_conn_release_handles_async_callback, stuff, g_free, G_TYPE_UINT, IN_handle_type, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_request_channel (DBusGProxy *proxy, const char * IN_type, const guint IN_handle_type, const guint IN_handle, const gboolean IN_suppress_handler, char** OUT_arg4, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestChannel", error, G_TYPE_STRING, IN_type, G_TYPE_UINT, IN_handle_type, G_TYPE_UINT, IN_handle, G_TYPE_BOOLEAN, IN_suppress_handler, G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, OUT_arg4, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_request_channel_reply) (DBusGProxy *proxy, char *OUT_arg4, GError *error, gpointer userdata);
+
+static void
+tp_conn_request_channel_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char* OUT_arg4;
+ dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_G_OBJECT_PATH, &OUT_arg4, G_TYPE_INVALID);
+ (*(tp_conn_request_channel_reply)data->cb) (proxy, OUT_arg4, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_request_channel_async (DBusGProxy *proxy, const char * IN_type, const guint IN_handle_type, const guint IN_handle, const gboolean IN_suppress_handler, tp_conn_request_channel_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestChannel", tp_conn_request_channel_async_callback, stuff, g_free, G_TYPE_STRING, IN_type, G_TYPE_UINT, IN_handle_type, G_TYPE_UINT, IN_handle, G_TYPE_BOOLEAN, IN_suppress_handler, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_request_handles (DBusGProxy *proxy, const guint IN_handle_type, const char ** IN_names, GArray** OUT_arg2, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestHandles", error, G_TYPE_UINT, IN_handle_type, G_TYPE_STRV, IN_names, G_TYPE_INVALID, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), OUT_arg2, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_request_handles_reply) (DBusGProxy *proxy, GArray *OUT_arg2, GError *error, gpointer userdata);
+
+static void
+tp_conn_request_handles_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GArray* OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_conn_request_handles_reply)data->cb) (proxy, OUT_arg2, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_request_handles_async (DBusGProxy *proxy, const guint IN_handle_type, const char ** IN_names, tp_conn_request_handles_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestHandles", tp_conn_request_handles_async_callback, stuff, g_free, G_TYPE_UINT, IN_handle_type, G_TYPE_STRV, IN_names, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-aliasing-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,147 @@
+/* tp-conn-iface-aliasing-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Aliasing
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Aliasing
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_aliasing_get_alias_flags (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetAliasFlags", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_aliasing_get_alias_flags_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_aliasing_get_alias_flags_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_iface_aliasing_get_alias_flags_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_aliasing_get_alias_flags_async (DBusGProxy *proxy, tp_conn_iface_aliasing_get_alias_flags_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetAliasFlags", tp_conn_iface_aliasing_get_alias_flags_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_aliasing_request_aliases (DBusGProxy *proxy, const GArray* IN_contacts, char *** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestAliases", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_aliasing_request_aliases_reply) (DBusGProxy *proxy, char * *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_aliasing_request_aliases_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_conn_iface_aliasing_request_aliases_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_aliasing_request_aliases_async (DBusGProxy *proxy, const GArray* IN_contacts, tp_conn_iface_aliasing_request_aliases_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestAliases", tp_conn_iface_aliasing_request_aliases_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_aliasing_set_aliases (DBusGProxy *proxy, const GHashTable* IN_aliases, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetAliases", error, dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, G_TYPE_STRING), IN_aliases, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_aliasing_set_aliases_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_aliasing_set_aliases_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_aliasing_set_aliases_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_aliasing_set_aliases_async (DBusGProxy *proxy, const GHashTable* IN_aliases, tp_conn_iface_aliasing_set_aliases_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetAliases", tp_conn_iface_aliasing_set_aliases_async_callback, stuff, g_free, dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, G_TYPE_STRING), IN_aliases, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Aliasing */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-avatars-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,222 @@
+/* tp-conn-iface-avatars-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Avatars
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Avatars
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_avatars_get_avatar_requirements (DBusGProxy *proxy, char *** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetAvatarRequirements", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_avatars_get_avatar_requirements_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_avatars_get_avatar_requirements_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ char ** OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_iface_avatars_get_avatar_requirements_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_avatars_get_avatar_requirements_async (DBusGProxy *proxy, tp_conn_iface_avatars_get_avatar_requirements_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetAvatarRequirements", tp_conn_iface_avatars_get_avatar_requirements_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_avatars_get_known_avatar_tokens (DBusGProxy *proxy, const GArray* IN_contacts, GHashTable** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetKnownAvatarTokens", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, G_TYPE_STRING), OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_avatars_get_known_avatar_tokens_reply) (DBusGProxy *proxy, GHashTable *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_avatars_get_known_avatar_tokens_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ GHashTable* OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, G_TYPE_STRING), &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_conn_iface_avatars_get_known_avatar_tokens_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_avatars_get_known_avatar_tokens_async (DBusGProxy *proxy, const GArray* IN_contacts, tp_conn_iface_avatars_get_known_avatar_tokens_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetKnownAvatarTokens", tp_conn_iface_avatars_get_known_avatar_tokens_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_avatars_request_avatars (DBusGProxy *proxy, const GArray* IN_contact, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestAvatars", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contact, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_avatars_request_avatars_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_avatars_request_avatars_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_avatars_request_avatars_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_avatars_request_avatars_async (DBusGProxy *proxy, const GArray* IN_contact, tp_conn_iface_avatars_request_avatars_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestAvatars", tp_conn_iface_avatars_request_avatars_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contact, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_avatars_set_avatar (DBusGProxy *proxy, const GArray* IN_avatar, const char * IN_mime_type, char ** OUT_arg2, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetAvatar", error, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), IN_avatar, G_TYPE_STRING, IN_mime_type, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg2, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_avatars_set_avatar_reply) (DBusGProxy *proxy, char * OUT_arg2, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_avatars_set_avatar_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ char * OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_conn_iface_avatars_set_avatar_reply)data->cb) (proxy, OUT_arg2, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_avatars_set_avatar_async (DBusGProxy *proxy, const GArray* IN_avatar, const char * IN_mime_type, tp_conn_iface_avatars_set_avatar_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetAvatar", tp_conn_iface_avatars_set_avatar_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), IN_avatar, G_TYPE_STRING, IN_mime_type, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_avatars_clear_avatar (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ClearAvatar", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_avatars_clear_avatar_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_avatars_clear_avatar_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_avatars_clear_avatar_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_avatars_clear_avatar_async (DBusGProxy *proxy, tp_conn_iface_avatars_clear_avatar_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ClearAvatar", tp_conn_iface_avatars_clear_avatar_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Avatars */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-capabilities-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,110 @@
+/* tp-conn-iface-capabilities-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Capabilities
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Capabilities
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_capabilities_advertise_capabilities (DBusGProxy *proxy, const char ** IN_add, const char ** IN_remove, char *** OUT_arg2, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "AdvertiseCapabilities", error, G_TYPE_STRV, IN_add, G_TYPE_STRV, IN_remove, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg2, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_capabilities_advertise_capabilities_reply) (DBusGProxy *proxy, char * *OUT_arg2, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_capabilities_advertise_capabilities_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg2;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg2, G_TYPE_INVALID);
+ (*(tp_conn_iface_capabilities_advertise_capabilities_reply)data->cb) (proxy, OUT_arg2, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_capabilities_advertise_capabilities_async (DBusGProxy *proxy, const char ** IN_add, const char ** IN_remove, tp_conn_iface_capabilities_advertise_capabilities_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "AdvertiseCapabilities", tp_conn_iface_capabilities_advertise_capabilities_async_callback, stuff, g_free, G_TYPE_STRV, IN_add, G_TYPE_STRV, IN_remove, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_capabilities_get_capabilities (DBusGProxy *proxy, const GArray* IN_handles, GPtrArray** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetCapabilities", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)), OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_capabilities_get_capabilities_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_capabilities_get_capabilities_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)), &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_conn_iface_capabilities_get_capabilities_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_capabilities_get_capabilities_async (DBusGProxy *proxy, const GArray* IN_handles, tp_conn_iface_capabilities_get_capabilities_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetCapabilities", tp_conn_iface_capabilities_get_capabilities_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_handles, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Capabilities */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-contact-info-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,71 @@
+/* tp-conn-iface-contact-info-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_ContactInfo
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_ContactInfo
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_contact_info_request_contact_info (DBusGProxy *proxy, const guint IN_contact, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestContactInfo", error, G_TYPE_UINT, IN_contact, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_contact_info_request_contact_info_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_contact_info_request_contact_info_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_contact_info_request_contact_info_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_contact_info_request_contact_info_async (DBusGProxy *proxy, const guint IN_contact, tp_conn_iface_contact_info_request_contact_info_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestContactInfo", tp_conn_iface_contact_info_request_contact_info_async_callback, stuff, g_free, G_TYPE_UINT, IN_contact, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_ContactInfo */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-forwarding-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,109 @@
+/* tp-conn-iface-forwarding-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Forwarding
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Forwarding
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_forwarding_get_forwarding_handle (DBusGProxy *proxy, guint* OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetForwardingHandle", error, G_TYPE_INVALID, G_TYPE_UINT, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_forwarding_get_forwarding_handle_reply) (DBusGProxy *proxy, guint OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_forwarding_get_forwarding_handle_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ guint OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_UINT, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_iface_forwarding_get_forwarding_handle_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_forwarding_get_forwarding_handle_async (DBusGProxy *proxy, tp_conn_iface_forwarding_get_forwarding_handle_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetForwardingHandle", tp_conn_iface_forwarding_get_forwarding_handle_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_forwarding_set_forwarding_handle (DBusGProxy *proxy, const guint IN_forward_to, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetForwardingHandle", error, G_TYPE_UINT, IN_forward_to, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_forwarding_set_forwarding_handle_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_forwarding_set_forwarding_handle_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_forwarding_set_forwarding_handle_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_forwarding_set_forwarding_handle_async (DBusGProxy *proxy, const guint IN_forward_to, tp_conn_iface_forwarding_set_forwarding_handle_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetForwardingHandle", tp_conn_iface_forwarding_set_forwarding_handle_async_callback, stuff, g_free, G_TYPE_UINT, IN_forward_to, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Forwarding */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-presence-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,294 @@
+/* tp-conn-iface-presence-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Presence
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Presence
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_add_status (DBusGProxy *proxy, const char * IN_status, const GHashTable* IN_parms, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "AddStatus", error, G_TYPE_STRING, IN_status, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_parms, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_add_status_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_add_status_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_add_status_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_add_status_async (DBusGProxy *proxy, const char * IN_status, const GHashTable* IN_parms, tp_conn_iface_presence_add_status_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "AddStatus", tp_conn_iface_presence_add_status_async_callback, stuff, g_free, G_TYPE_STRING, IN_status, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_parms, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_clear_status (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ClearStatus", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_clear_status_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_clear_status_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_clear_status_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_clear_status_async (DBusGProxy *proxy, tp_conn_iface_presence_clear_status_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ClearStatus", tp_conn_iface_presence_clear_status_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_get_statuses (DBusGProxy *proxy, GHashTable** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetStatuses", error, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), G_TYPE_INVALID)), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_get_statuses_reply) (DBusGProxy *proxy, GHashTable *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_get_statuses_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GHashTable* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), G_TYPE_INVALID)), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_get_statuses_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_get_statuses_async (DBusGProxy *proxy, tp_conn_iface_presence_get_statuses_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetStatuses", tp_conn_iface_presence_get_statuses_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_remove_status (DBusGProxy *proxy, const char * IN_status, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RemoveStatus", error, G_TYPE_STRING, IN_status, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_remove_status_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_remove_status_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_remove_status_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_remove_status_async (DBusGProxy *proxy, const char * IN_status, tp_conn_iface_presence_remove_status_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RemoveStatus", tp_conn_iface_presence_remove_status_async_callback, stuff, g_free, G_TYPE_STRING, IN_status, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_request_presence (DBusGProxy *proxy, const GArray* IN_contacts, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestPresence", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_request_presence_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_request_presence_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_request_presence_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_request_presence_async (DBusGProxy *proxy, const GArray* IN_contacts, tp_conn_iface_presence_request_presence_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestPresence", tp_conn_iface_presence_request_presence_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_contacts, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_set_last_activity_time (DBusGProxy *proxy, const guint IN_time, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetLastActivityTime", error, G_TYPE_UINT, IN_time, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_set_last_activity_time_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_set_last_activity_time_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_set_last_activity_time_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_set_last_activity_time_async (DBusGProxy *proxy, const guint IN_time, tp_conn_iface_presence_set_last_activity_time_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetLastActivityTime", tp_conn_iface_presence_set_last_activity_time_async_callback, stuff, g_free, G_TYPE_UINT, IN_time, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_presence_set_status (DBusGProxy *proxy, const GHashTable* IN_statuses, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetStatus", error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)), IN_statuses, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_presence_set_status_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_presence_set_status_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_presence_set_status_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_presence_set_status_async (DBusGProxy *proxy, const GHashTable* IN_statuses, tp_conn_iface_presence_set_status_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetStatus", tp_conn_iface_presence_set_status_async_callback, stuff, g_free, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)), IN_statuses, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Presence */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-privacy-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,147 @@
+/* tp-conn-iface-privacy-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Privacy
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Privacy
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_privacy_get_privacy_mode (DBusGProxy *proxy, char ** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetPrivacyMode", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_privacy_get_privacy_mode_reply) (DBusGProxy *proxy, char * OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_privacy_get_privacy_mode_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char * OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_iface_privacy_get_privacy_mode_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_privacy_get_privacy_mode_async (DBusGProxy *proxy, tp_conn_iface_privacy_get_privacy_mode_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetPrivacyMode", tp_conn_iface_privacy_get_privacy_mode_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_privacy_get_privacy_modes (DBusGProxy *proxy, char *** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetPrivacyModes", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_privacy_get_privacy_modes_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_privacy_get_privacy_modes_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_conn_iface_privacy_get_privacy_modes_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_privacy_get_privacy_modes_async (DBusGProxy *proxy, tp_conn_iface_privacy_get_privacy_modes_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetPrivacyModes", tp_conn_iface_privacy_get_privacy_modes_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_privacy_set_privacy_mode (DBusGProxy *proxy, const char * IN_mode, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetPrivacyMode", error, G_TYPE_STRING, IN_mode, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_privacy_set_privacy_mode_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_privacy_set_privacy_mode_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_privacy_set_privacy_mode_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_privacy_set_privacy_mode_async (DBusGProxy *proxy, const char * IN_mode, tp_conn_iface_privacy_set_privacy_mode_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetPrivacyMode", tp_conn_iface_privacy_set_privacy_mode_async_callback, stuff, g_free, G_TYPE_STRING, IN_mode, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Privacy */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-iface-renaming-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,71 @@
+/* tp-conn-iface-renaming-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Renaming
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Renaming
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_conn_iface_renaming_request_rename (DBusGProxy *proxy, const char * IN_name, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestRename", error, G_TYPE_STRING, IN_name, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_conn_iface_renaming_request_rename_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_conn_iface_renaming_request_rename_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_conn_iface_renaming_request_rename_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_conn_iface_renaming_request_rename_async (DBusGProxy *proxy, const char * IN_name, tp_conn_iface_renaming_request_rename_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestRename", tp_conn_iface_renaming_request_rename_async_callback, stuff, g_free, G_TYPE_STRING, IN_name, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Connection_Interface_Renaming */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-ifaces-signal-setters.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,44 @@
+/* tp-conn-ifaces-signal-setters.h
+ *
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef TP_CONN_IFACES_SETTERS_H
+#define TP_CONN_IFACES_SETTERS_H
+
+#include <dbus/dbus-glib.h>
+
+/* This header file contains definitions for the signal signature setters
+ * for the various interfaces provided by Connections */
+
+void tp_conn_set_aliasing_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_capabilities_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_contactinfo_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_forwarding_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_presence_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_privacy_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_renaming_signatures(DBusGProxy *proxy);
+
+void tp_conn_set_avatar_signatures(DBusGProxy *proxy);
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,50 @@
+/*
+ * tp-conn-signals-marshal.h - Header for Telepathy interface names
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __tp_conn_signals_marshal_MARSHAL_H__
+#define __tp_conn_signals_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:OBJECT,STRING,UINT,UINT,BOOLEAN (tp-conn-signals-marshal.list:1) */
+extern void tp_conn_signals_marshal_VOID__OBJECT_STRING_UINT_UINT_BOOLEAN (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT (tp-conn-signals-marshal.list:2) */
+extern void tp_conn_signals_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:BOXED (tp-conn-signals-marshal.list:3) */
+#define tp_conn_signals_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED
+
+G_END_DECLS
+
+#endif /* __tp_conn_signals_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-conn.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,220 @@
+/* tp-conn.h
+ *
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef TP_CONN_H
+#define TP_CONN_H
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+#include "tp-conn-gen.h"
+#include "tp-conn-iface-forwarding-gen.h"
+#include "tp-chan.h"
+#include "tp-conn-signals-marshal.h"
+#include "tp-ifaces-signals-marshal.h"
+#include "tp-conn-ifaces-signal-setters.h"
+#include "tp-interfaces.h"
+#include "tp-constants.h"
+
+#include <dbus/dbus-glib.h>
+
+#define DBUS_TYPE_G_ARRAY_OF_STRUCTS dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE_ARRAY);
+
+#define TELEPATHY_CONN_TYPE (tp_conn_get_type ())
+
+#define TELEPATHY_CONN(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), TELEPATHY_CONN_TYPE, \
+ TpConn))
+
+#define TELEPATHY_CONN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), TELEPATHY_CONN_TYPE, \
+ TpConnClass))
+
+#define TELEPATHY_IS_CONN(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), TELEPATHY_CONN_TYPE))
+
+#define TELEPATHY_IS_CONN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE \
+ ((klass), TELEPATHY_CONN_TYPE))
+
+#define TELEPATHY_CONN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), TELEPATHY_CONN_TYPE, \
+ TpConnClass))
+
+#define TELEPATHY_CONN_IFACE_QUARK (tp_get_conn_interface())
+#define TELEPATHY_CONN_IFACE_ALIASING_QUARK (tp_get_conn_aliasing_interface())
+#define TELEPATHY_CONN_IFACE_CAPABILITIES_QUARK (tp_get_conn_capabilities_interface())
+#define TELEPATHY_CONN_IFACE_CONTACTINFO_QUARK (tp_get_conn_contactinfo_interface())
+#define TELEPATHY_CONN_IFACE_FORWARDING_QUARK (tp_get_conn_forwarding_interface())
+#define TELEPATHY_CONN_IFACE_PRESENCE_QUARK (tp_get_conn_presence_interface())
+#define TELEPATHY_CONN_IFACE_PRIVACY_QUARK (tp_get_conn_privacy_interface())
+#define TELEPATHY_CONN_IFACE_RENAMING_QUARK (tp_get_conn_renaming_interface())
+#define TELEPATHY_CONN_IFACE_AVATAR_QUARK (tp_get_conn_avatar_interface())
+
+
+/* The signal name for the synthesized StatusChanged signal */
+#define TP_IFACE_CONN_SIGNAL_STATUSCHANGED_SYNTHESIZED \
+ "received::org-freedesktop-Telepathy-Connection-StatusChanged"
+
+typedef struct _tp_conn TpConn;
+typedef struct _tp_connclass TpConnClass;
+
+struct _tp_conn
+{
+ DBusGProxy parent;
+ GData *interface_list;
+ gboolean first_run;
+};
+
+
+struct _tp_connclass
+{
+ DBusGProxyClass parent_class;
+ GData *iface_signal_sigs;
+};
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GType tp_conn_get_type(void);
+#ifdef __cplusplus
+}
+#endif
+
+/* Actual function definitions */
+
+/*
+ * Create a new TpConn (Connection) object.
+ *
+ * @param connection The D-BUS connection
+ * @param name: The D-BUS service name for the connection object
+ * @param path_name: The D-BUS path name for the connection object
+ * @param interface_name: The D-BUS interface name for the connection object
+ * @return A new TpConn connection object, or NULL if unsuccesful.
+ */
+
+TpConn *tp_conn_new(DBusGConnection *connection,
+ const char *bus_name,
+ const char *object_path);
+
+/* Create a TpChan channel object for this connection. Also initialises
+ * the proxy object that is used for the actual method calls.
+ *
+ * @param connection: The DBusGConnection for the channel
+ * @param tpconn: The Connection object for which the channel is done
+ * @param bus_name: The D-Bus interface name for the channel
+ * @param type: The channel type string
+ * @param handle_type: The type of the channel handle
+ * @param handle: The channel handle value is set and stored here after
+ * @param the call returns.
+ * @param supress_handler: if TRUE, indicates that no handler needs to be
+ * launched
+ *
+ * @return A new TpChan (channel) object
+ */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+TpChan *tp_conn_new_channel(DBusGConnection *connection, TpConn *tpconn,
+ const gchar *bus_name,
+ gchar *type, guint handle_type,
+ guint handle, gboolean supress_handler);
+#ifdef __cplusplus
+}
+#endif
+
+/* Creates the proxy objects for the channel interfaces. GetInterfaces
+ * method should be called before this to acquire the interface name
+ * list.
+ *
+ * @param self: The connection object
+ * @param interfaces: An array of the interface name strings
+ */
+
+void tp_conn_local_set_interfaces(TpConn *self, gchar **interfaces);
+
+
+/*
+ * Provides access to the connection proxy object to use for actual
+ * method calls
+ *
+ * @param self: The connection object whose proxy should be retrieved
+ * @return The D-BUS proxy object
+ */
+
+DBusGProxy *tp_conn_get_proxy(TpConn *self);
+
+/*
+ * This function checks whether the Connection has the specified
+ * interface and returns a proxy object that can be used to call
+ * its methods, if it exists. The supported interfaces are listed
+ * in the beginning of this header as macros.
+ *
+ * @param self The connection object that is queried for the
+ * interface proxy object
+ * @param iface_quark GQuark corresponding to the interface name
+ * string.
+ * @return A DBusGProxy object for the interface, or NULL if not found
+ */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+DBusGProxy *tp_conn_get_interface(TpConn *self, GQuark iface_quark);
+#ifdef __cplusplus
+}
+#endif
+
+GQuark tp_get_conn_interface(void);
+GQuark tp_get_conn_aliasing_interface(void);
+GQuark tp_get_conn_capabilities_interface(void);
+GQuark tp_get_conn_contactinfo_interface(void);
+GQuark tp_get_conn_forwarding_interface(void);
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GQuark tp_get_conn_presence_interface(void);
+GQuark tp_get_conn_avatar_interface(void);
+#ifdef __cplusplus
+}
+#endif
+GQuark tp_get_conn_privacy_interface(void);
+GQuark tp_get_conn_renaming_interface(void);
+
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-connmgr-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,153 @@
+/* tp-connmgr-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_ConnectionManager
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_ConnectionManager
+
+/* Vinod commented out
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_connmgr_get_parameters (DBusGProxy *proxy, const char * IN_proto, GPtrArray** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetParameters", error, G_TYPE_STRING, IN_proto, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID)), OUT_arg1, G_TYPE_INVALID);
+}
+*/
+typedef void (*tp_connmgr_get_parameters_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_connmgr_get_parameters_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID)), &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_connmgr_get_parameters_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_connmgr_get_parameters_async (DBusGProxy *proxy, const char * IN_proto, tp_connmgr_get_parameters_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetParameters", tp_connmgr_get_parameters_async_callback, stuff, g_free, G_TYPE_STRING, IN_proto, G_TYPE_INVALID);
+}
+
+/*MTa - commenting out for now
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_connmgr_list_protocols (DBusGProxy *proxy, char *** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ListProtocols", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_arg0, G_TYPE_INVALID);
+}
+*/
+
+typedef void (*tp_connmgr_list_protocols_reply) (DBusGProxy *proxy, char * *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_connmgr_list_protocols_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char ** OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_connmgr_list_protocols_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_connmgr_list_protocols_async (DBusGProxy *proxy, tp_connmgr_list_protocols_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ListProtocols", tp_connmgr_list_protocols_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_connmgr_request_connection (DBusGProxy *proxy, const char * IN_proto, const GHashTable* IN_parameters, char ** OUT_arg2, char** OUT_arg3, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "RequestConnection", error, G_TYPE_STRING, IN_proto, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_parameters, G_TYPE_INVALID, G_TYPE_STRING, OUT_arg2, DBUS_TYPE_G_OBJECT_PATH, OUT_arg3, G_TYPE_INVALID);
+}
+
+typedef void (*tp_connmgr_request_connection_reply) (DBusGProxy *proxy, char * OUT_arg2, char *OUT_arg3, GError *error, gpointer userdata);
+
+static void
+tp_connmgr_request_connection_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ char * OUT_arg2;
+ char* OUT_arg3;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_arg2, DBUS_TYPE_G_OBJECT_PATH, &OUT_arg3, G_TYPE_INVALID);
+ (*(tp_connmgr_request_connection_reply)data->cb) (proxy, OUT_arg2, OUT_arg3, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_connmgr_request_connection_async (DBusGProxy *proxy, const char * IN_proto, const GHashTable* IN_parameters, tp_connmgr_request_connection_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "RequestConnection", tp_connmgr_request_connection_async_callback, stuff, g_free, G_TYPE_STRING, IN_proto, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), IN_parameters, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_ConnectionManager */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-connmgr-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,39 @@
+/*
+ * tp-connmgr-signals-marshal.h - Header for Telepathy interface names
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __tp_connmgr_signals_marshal_MARSHAL_H__
+#define __tp_connmgr_signals_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:STRING,OBJECT,STRING (tp-connmgr-signals-marshal.list:1) */
+extern void tp_connmgr_signals_marshal_VOID__STRING_OBJECT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __tp_connmgr_signals_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-connmgr.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,167 @@
+/* tp-connmgr.h
+ *
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+
+#ifndef TP_CONNMGR_H
+#define TP_CONNMGR_H
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+#include "tp-connmgr-gen.h"
+#include "tp-conn.h"
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
+#include <glib.h>
+
+
+
+#define TELEPATHY_CONNMGR_TYPE (tp_connmgr_get_type ())
+
+#define TELEPATHY_CONNMGR(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), TELEPATHY_CONNMGR_TYPE, \
+ TpConnMgr))
+
+#define TELEPATHY_CONNMGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), TELEPATHY_CONNMGR_TYPE, \
+ TpConnMgrClass))
+
+#define TELEPATHY_IS_CONNMGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), TELEPATHY_CONNMGR_TYPE))
+
+#define TELEPATHY_IS_CONNMGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE \
+ ((klass), TELEPATHY_CONNMGR_TYPE))
+
+#define TELEPATHY_CONNMGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), TELEPATHY_CONNMGR_TYPE, \
+ TpConnMgrClass))
+
+typedef struct _tp_connmgr TpConnMgr;
+typedef struct _tp_connmgrclass TpConnMgrClass;
+
+struct _tp_connmgr
+{
+ DBusGProxy parent;
+
+ gboolean first_run;
+};
+
+struct _tp_connmgrclass
+{
+ DBusGProxyClass parent_class;
+};
+
+GType tp_connmgr_get_type(void);
+
+/* Actual function definitions */
+
+
+/*
+* Creates a new TpConnmgr (Connection Manager) object.
+* @param connection: A connection to the D-BUS.
+* @param name: The service name for the connection manager
+* @param path_name: The path name for the connection manager
+* @param interface_name: The interface name for the connection manager
+* @return A new Connection Manager object, or NULL if failed
+*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+TpConnMgr *tp_connmgr_new(DBusGConnection *connection,
+ const char *bus_name,
+ const char *object_path,
+ const char *interface_name);
+ #ifdef __cplusplus
+}
+#endif
+
+
+
+/*
+ * Creates a new TpConn object for this connection manager.
+ * Also initializes a DBusGProxy object that is used to perform the
+ * actual method calls. Thus, the connection should be usable
+ * if this succeeds.
+ *
+ * @param self: The connection manager object that the new connection
+ * object is created for.
+ * @param connection_parameters: The parameters for the connection.
+ * @protocol: The protocol for the connection.
+ *
+ * @return A TpConn object, or NULL if object could not be created.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+TpConn *tp_connmgr_new_connection(TpConnMgr *self,
+ GHashTable *connection_parameters,
+ gchar *protocol);
+#ifdef __cplusplus
+}
+#endif
+
+
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+gboolean tp_connmgr_list_protocols(TpConnMgr *self, char *** proto);
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+gboolean tp_connmgr_get_parameters (TpConnMgr *self, const char * IN_proto, GPtrArray** OUT_arg1);
+#ifdef __cplusplus
+}
+#endif
+
+
+
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-constants.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,193 @@
+/*
+ * tp-constants.h - constants used in telepathy
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_CONSTANTS_H__
+#define __TELEPATHY_CONSTANTS_H__
+
+#include <glib.h>
+G_BEGIN_DECLS
+
+typedef enum {
+TP_CONN_ALIAS_FLAG_USER_SET = 1,
+LAST_TP_CONN_ALIAS_FLAG
+} ConnectionAliasFlags;
+
+typedef enum {
+TP_CONN_CAPABILITY_TYPE_CREATE = 0,
+TP_CONN_CAPABILITY_TYPE_INVITE = 1,
+LAST_TP_CONN_CAPABILITY_TYPE
+} TelepathyConnectionCapabilityType;
+
+typedef enum {
+TP_CONN_HANDLE_TYPE_NONE = 0,
+TP_CONN_HANDLE_TYPE_CONTACT = 1,
+TP_CONN_HANDLE_TYPE_ROOM = 2,
+TP_CONN_HANDLE_TYPE_LIST = 3,
+LAST_TP_CONN_HANDLE_TYPE
+} TelepathyConnectionHandleType;
+
+typedef enum {
+TP_CONN_PRESENCE_TYPE_UNSET = 0,
+TP_CONN_PRESENCE_TYPE_OFFLINE = 1,
+TP_CONN_PRESENCE_TYPE_AVAILABLE = 2,
+TP_CONN_PRESENCE_TYPE_AWAY = 3,
+TP_CONN_PRESENCE_TYPE_EXTENDED_AWAY = 4,
+TP_CONN_PRESENCE_TYPE_HIDDEN = 5,
+LAST_TP_CONN_PRESENCE_TYPE
+} TelepathyConnectionPresenceType;
+
+typedef enum {
+TP_CONN_STATUS_CONNECTED = 0,
+TP_CONN_STATUS_CONNECTING = 1,
+TP_CONN_STATUS_DISCONNECTED = 2,
+LAST_TP_CONN_STATUS
+} TelepathyConnectionStatus;
+
+typedef enum {
+TP_CONN_STATUS_REASON_NONE_SPECIFIED = 0,
+TP_CONN_STATUS_REASON_REQUESTED = 1,
+TP_CONN_STATUS_REASON_NETWORK_ERROR = 2,
+TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED = 3,
+TP_CONN_STATUS_REASON_ENCRYPTION_ERROR = 4,
+TP_CONN_STATUS_REASON_NAME_IN_USE = 5,
+TP_CONN_STATUS_REASON_CERT_NOT_PROVIDED = 6,
+TP_CONN_STATUS_REASON_CERT_UNTRUSTED = 7,
+TP_CONN_STATUS_REASON_CERT_EXPIRED = 8,
+TP_CONN_STATUS_REASON_CERT_NOT_ACTIVATED = 9,
+TP_CONN_STATUS_REASON_CERT_HOSTNAME_MISMATCH = 10,
+TP_CONN_STATUS_REASON_CERT_FINGERPRINT_MISMATCH = 11,
+TP_CONN_STATUS_REASON_CERT_SELF_SIGNED = 12,
+TP_CONN_STATUS_REASON_CERT_OTHER_ERROR = 13,
+LAST_TP_CONN_STATUS_REASON
+} TelepathyConnectionStatusReason;
+
+typedef enum {
+TP_CHANNEL_CONTACT_SEARCH_STATE_BEFORE = 0,
+TP_CHANNEL_CONTACT_SEARCH_STATE_DURING = 1,
+TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER = 2,
+LAST_TP_CHANNEL_CONTACT_SEARCH_STATE
+} TelepathyChannelContactSearchState;
+
+typedef enum {
+TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL = 0,
+TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION = 1,
+TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE = 2,
+TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY = 3,
+LAST_TP_CHANNEL_TEXT_MESSAGE_TYPE
+} TelepathyChannelTextMessageType;
+
+typedef enum {
+TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN = 0,
+TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE = 1,
+TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT = 2,
+TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED = 3,
+TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG = 4,
+LAST_TP_CHANNEL_TEXT_SEND_ERROR
+} TelepathyChannelTextSendError;
+
+typedef enum {
+TP_CHANNEL_GROUP_FLAG_CAN_ADD = 1,
+TP_CHANNEL_GROUP_FLAG_CAN_REMOVE = 2,
+TP_CHANNEL_GROUP_FLAG_CAN_RESCIND = 4,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD = 8,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE = 16,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_ACCEPT = 32,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_REJECT = 64,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_RESCIND = 128,
+TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES = 256,
+LAST_TP_CHANNEL_GROUP_FLAG
+} TelepathyChannelGroupFlags;
+
+typedef enum {
+TP_CHANNEL_HOLD_STATE_NONE = 0,
+TP_CHANNEL_HOLD_STATE_SEND_ONLY = 1,
+TP_CHANNEL_HOLD_STATE_RECV_ONLY = 2,
+TP_CHANNEL_HOLD_STATE_BOTH = 3,
+LAST_TP_CHANNEL_HOLD_STATE
+} TelepathyChannelHoldState;
+
+typedef enum {
+TP_CHANNEL_PASSWORD_FLAG_REQUIRED = 1,
+TP_CHANNEL_PASSWORD_FLAG_VISIBLE = 2,
+TP_CHANNEL_PASSWORD_FLAG_MODIFIABLE = 4,
+TP_CHANNEL_PASSWORD_FLAG_PROVIDE = 8,
+LAST_TP_CHANNEL_PASSWORD_FLAG
+} TelepathyChannelPasswordFlags;
+
+typedef enum {
+TP_CHANNEL_SUBJECT_FLAG_PRESENT = 1,
+TP_CHANNEL_SUBJECT_FLAG_MODIFIABLE = 2,
+LAST_TP_CHANNEL_SUBJECT_FLAG
+} TelepathyChannelSubjectFlags;
+
+typedef enum {
+TP_MEDIA_STREAM_TYPE_AUDIO = 0,
+TP_MEDIA_STREAM_TYPE_VIDEO = 1,
+LAST_TP_MEDIA_STREAM_TYPE
+} TelepathyMediaStreamType;
+
+typedef enum {
+TP_MEDIA_STREAM_DIRECTION_NONE = 0,
+TP_MEDIA_STREAM_DIRECTION_SEND = 1,
+TP_MEDIA_STREAM_DIRECTION_RECIEVE = 2,
+TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3,
+LAST_TP_MEDIA_STREAM_DIRECTION
+} TelepathyMediaStreamDirection;
+
+typedef enum {
+TP_MEDIA_STREAM_ERROR_UNKNOWN = 0,
+TP_MEDIA_STREAM_ERROR_EOS = 1,
+LAST_TP_MEDIA_STREAM_ERROR
+} TelepathyMediaStreamError;
+
+typedef enum {
+TP_MEDIA_STREAM_PROTO_UDP = 0,
+TP_MEDIA_STREAM_PROTO_TCP = 1,
+LAST_TP_MEDIA_STREAM_PROTO
+} TelepathyMediaStreamProto;
+
+typedef enum {
+TP_MEDIA_STREAM_TRANSPORT_TYPE_LOCAL = 0,
+TP_MEDIA_STREAM_TRANSPORT_TYPE_DERIVED = 1,
+TP_MEDIA_STREAM_TRANSPORT_TYPE_RELAY = 2,
+LAST_TP_MEDIA_STREAM_TRANSPORT_TYPE
+} TelepathyMediaStreamTransportType;
+
+typedef enum {
+TP_CODEC_MEDIA_TYPE_AUDIO = 0,
+TP_CODEC_MEDIA_TYPE_VIDEO = 1,
+} TelepathyCodecMediaType;
+
+typedef enum {
+TP_MEDIA_STREAM_STATE_STOPPED = 0,
+TP_MEDIA_STREAM_STATE_PLAYING = 1,
+TP_MEDIA_STREAM_STATE_CONNECTING = 2,
+TP_MEDIA_STREAM_STATE_CONNECTED = 3
+} TelepathyMediaStreamState;
+
+typedef enum {
+TP_PROPERTY_FLAG_READ = 1,
+TP_PROPERTY_FLAG_WRITE = 2
+} TelepathyPropertyFlags;
+
+G_END_DECLS
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-helpers.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,82 @@
+/*
+ * tp-helpers.h - Header for various helper functions
+ * for telepathy implementation
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_HELPERS_H__
+#define __TELEPATHY_HELPERS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+ gpointer key;
+ gpointer value;
+} TpKeyValue;
+
+DBusGConnection * tp_get_bus ();
+DBusGProxy * tp_get_bus_proxy ();
+GSList *tp_hash_to_key_value_list(GHashTable *hashtable);
+void tp_key_value_list_free(GSList *list);
+
+
+typedef struct _tp_connmgr_info TpConnMgrInfo;
+typedef struct _tp_connmgr_protocol_info TpConnMgrProtInfo;
+
+struct _tp_connmgr_protocol_info
+{
+ gchar **mandatory_params;
+ gchar **optional_params;
+
+ /* defaul value hash */
+ GHashTable *default_params;
+};
+
+struct _tp_connmgr_info
+{
+ gchar *name;
+ gchar *bus_name;
+ gchar *object_path;
+ gchar **protocols;
+
+ /* hash of protocol infos */
+ GHashTable *protocol_info;
+};
+
+/*
+ * Lists all the connection manager files.
+ * @return A list of connection manager names
+ */
+GSList *tp_connmgr_list_cms(void);
+
+/*
+ * Returns the connection manager information for the given connection manager
+ * @param cm: the connection manager name string
+ * @return A struct containing all the information read from the connection
+ * manager file.
+ */
+TpConnMgrInfo *tp_connmgr_get_info(gchar *cm);
+
+
+G_END_DECLS
+
+#endif /* __TELEPATHY_HELPERS_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-ice-session-handler-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,108 @@
+/* tp-ice-session-handler-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Ice_SessionHandler
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Ice_SessionHandler
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_session_handler_error (DBusGProxy *proxy, const guint IN_errno, const char * IN_message, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Error", error, G_TYPE_UINT, IN_errno, G_TYPE_STRING, IN_message, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_session_handler_error_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_session_handler_error_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_session_handler_error_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_session_handler_error_async (DBusGProxy *proxy, const guint IN_errno, const char * IN_message, tp_ice_session_handler_error_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Error", tp_ice_session_handler_error_async_callback, stuff, g_free, G_TYPE_UINT, IN_errno, G_TYPE_STRING, IN_message, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_session_handler_ready (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Ready", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_session_handler_ready_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_session_handler_ready_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_session_handler_ready_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_session_handler_ready_async (DBusGProxy *proxy, tp_ice_session_handler_ready_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Ready", tp_ice_session_handler_ready_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Ice_SessionHandler */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-ice-stream-handler-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,330 @@
+/* tp-ice-stream-handler-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Ice_StreamHandler
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Ice_StreamHandler
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_codec_choice (DBusGProxy *proxy, const guint IN_codec_id, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "CodecChoice", error, G_TYPE_UINT, IN_codec_id, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_codec_choice_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_codec_choice_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_codec_choice_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_codec_choice_async (DBusGProxy *proxy, const guint IN_codec_id, tp_ice_stream_handler_codec_choice_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "CodecChoice", tp_ice_stream_handler_codec_choice_async_callback, stuff, g_free, G_TYPE_UINT, IN_codec_id, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_error (DBusGProxy *proxy, const guint IN_errno, const char * IN_message, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Error", error, G_TYPE_UINT, IN_errno, G_TYPE_STRING, IN_message, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_error_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_error_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_error_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_error_async (DBusGProxy *proxy, const guint IN_errno, const char * IN_message, tp_ice_stream_handler_error_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Error", tp_ice_stream_handler_error_async_callback, stuff, g_free, G_TYPE_UINT, IN_errno, G_TYPE_STRING, IN_message, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_native_candidates_prepared (DBusGProxy *proxy, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "NativeCandidatesPrepared", error, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_native_candidates_prepared_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_native_candidates_prepared_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_native_candidates_prepared_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_native_candidates_prepared_async (DBusGProxy *proxy, tp_ice_stream_handler_native_candidates_prepared_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "NativeCandidatesPrepared", tp_ice_stream_handler_native_candidates_prepared_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_new_active_candidate_pair (DBusGProxy *proxy, const char * IN_native_candidate_id, const char * IN_remote_candidate_id, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "NewActiveCandidatePair", error, G_TYPE_STRING, IN_native_candidate_id, G_TYPE_STRING, IN_remote_candidate_id, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_new_active_candidate_pair_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_new_active_candidate_pair_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_new_active_candidate_pair_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_new_active_candidate_pair_async (DBusGProxy *proxy, const char * IN_native_candidate_id, const char * IN_remote_candidate_id, tp_ice_stream_handler_new_active_candidate_pair_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "NewActiveCandidatePair", tp_ice_stream_handler_new_active_candidate_pair_async_callback, stuff, g_free, G_TYPE_STRING, IN_native_candidate_id, G_TYPE_STRING, IN_remote_candidate_id, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_new_native_candidate (DBusGProxy *proxy, const char * IN_candidate_id, const GPtrArray* IN_transports, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "NewNativeCandidate", error, G_TYPE_STRING, IN_candidate_id, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)), IN_transports, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_new_native_candidate_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_new_native_candidate_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_new_native_candidate_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_new_native_candidate_async (DBusGProxy *proxy, const char * IN_candidate_id, const GPtrArray* IN_transports, tp_ice_stream_handler_new_native_candidate_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "NewNativeCandidate", tp_ice_stream_handler_new_native_candidate_async_callback, stuff, g_free, G_TYPE_STRING, IN_candidate_id, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)), IN_transports, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_ready (DBusGProxy *proxy, const GPtrArray* IN_codecs, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "Ready", error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), G_TYPE_INVALID)), IN_codecs, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_ready_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_ready_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_ready_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_ready_async (DBusGProxy *proxy, const GPtrArray* IN_codecs, tp_ice_stream_handler_ready_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "Ready", tp_ice_stream_handler_ready_async_callback, stuff, g_free, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), G_TYPE_INVALID)), IN_codecs, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_stream_state (DBusGProxy *proxy, const guint IN_state, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "StreamState", error, G_TYPE_UINT, IN_state, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_stream_state_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_stream_state_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_stream_state_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_stream_state_async (DBusGProxy *proxy, const guint IN_state, tp_ice_stream_handler_stream_state_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "StreamState", tp_ice_stream_handler_stream_state_async_callback, stuff, g_free, G_TYPE_UINT, IN_state, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_ice_stream_handler_supported_codecs (DBusGProxy *proxy, const GPtrArray* IN_codecs, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SupportedCodecs", error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), G_TYPE_INVALID)), IN_codecs, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_ice_stream_handler_supported_codecs_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_ice_stream_handler_supported_codecs_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_ice_stream_handler_supported_codecs_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_ice_stream_handler_supported_codecs_async (DBusGProxy *proxy, const GPtrArray* IN_codecs, tp_ice_stream_handler_supported_codecs_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SupportedCodecs", tp_ice_stream_handler_supported_codecs_async_callback, stuff, g_free, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), G_TYPE_INVALID)), IN_codecs, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Ice_StreamHandler */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-ifaces-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,142 @@
+/*
+ * tp-ifaces-signals-marshal.h - Header for Telepathy interface names
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __tp_ifaces_signals_marshal_MARSHAL_H__
+#define __tp_ifaces_signals_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,STRING (tp-ifaces-signals-marshal.list:3) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,BOXED,BOXED (tp-ifaces-signals-marshal.list:5) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_BOXED_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:STRING (tp-ifaces-signals-marshal.list:7) */
+#define tp_ifaces_signals_marshal_VOID__STRING g_cclosure_marshal_VOID__STRING
+
+/* VOID:INT,BOXED (tp-ifaces-signals-marshal.list:11) */
+extern void tp_ifaces_signals_marshal_VOID__INT_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+
+/* VOID:STRING,BOXED */
+//Added for search
+extern void
+tp_ifaces_signals_marshal_VOID__UINT_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT (tp-ifaces-signals-marshal.list:13) */
+#define tp_ifaces_signals_marshal_VOID__UINT g_cclosure_marshal_VOID__UINT
+
+/* VOID:UINT,STRING,STRING (tp-ifaces-signals-marshal.list:15) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT,UINT (tp-ifaces-signals-marshal.list:17) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:BOOLEAN (tp-ifaces-signals-marshal.list:19) */
+#define tp_ifaces_signals_marshal_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN
+
+/* VOID:UINT,UINT,UINT,UINT,UINT,STRING (tp-ifaces-signals-marshal.list:21) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT,STRING (tp-ifaces-signals-marshal.list:23) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT (tp-ifaces-signals-marshal.list:27) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT (tp-ifaces-signals-marshal.list:29) */
+extern void tp_ifaces_signals_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:BOXED (tp-ifaces-signals-marshal.list:33) */
+#define tp_ifaces_signals_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED
+
+/* VOID:UINT,UINT,UINT,STRING (tp-ifaces-signals-marshal.list:35) */
+extern void tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:OBJECT,STRING (tp-ifaces-signals-marshal.list:37) */
+extern void tp_ifaces_signals_marshal_VOID__OBJECT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __tp_ifaces_signals_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-interfaces.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,83 @@
+/*
+ * tp-interfaces.h - Header for Telepathy interface names
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_INTERFACES_H__
+#define __TELEPATHY_INTERFACES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TP_IFACE_CHANNEL_INTERFACE \
+ "org.freedesktop.Telepathy.Channel"
+#define TP_IFACE_CHANNEL_INTERFACE_DTMF \
+ "org.freedesktop.Telepathy.Channel.Interface.DTMF"
+#define TP_IFACE_CHANNEL_INTERFACE_GROUP \
+ "org.freedesktop.Telepathy.Channel.Interface.Group"
+#define TP_IFACE_CHANNEL_INTERFACE_HOLD \
+ "org.freedesktop.Telepathy.Channel.Interface.Hold"
+#define TP_IFACE_CHANNEL_INTERFACE_PASSWORD \
+ "org.freedesktop.Telepathy.Channel.Interface.Password"
+#define TP_IFACE_CHANNEL_INTERFACE_SUBJECT \
+ "org.freedesktop.Telepathy.Channel.Interface.Subject"
+#define TP_IFACE_CHANNEL_INTERFACE_TRANSFER \
+ "org.freedesktop.Telepathy.Channel.Interface.Transfer"
+#define TP_IFACE_CHANNEL_TYPE_CONTACT_LIST \
+ "org.freedesktop.Telepathy.Channel.Type.ContactList"
+
+#define TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH \
+ "org.freedesktop.Telepathy.Channel.Type.ContactSearch"
+
+#define TP_IFACE_CHANNEL_TYPE_ROOM_LIST \
+ "org.freedesktop.Telepathy.Channel.Type.RoomList"
+#define TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA \
+ "org.freedesktop.Telepathy.Channel.Type.StreamedMedia"
+#define TP_IFACE_CHANNEL_TYPE_TEXT \
+ "org.freedesktop.Telepathy.Channel.Type.Text"
+#define TP_IFACE_CONN_INTERFACE \
+ "org.freedesktop.Telepathy.Connection"
+#define TP_IFACE_CONN_INTERFACE_ALIASING \
+ "org.freedesktop.Telepathy.Connection.Interface.Aliasing"
+#define TP_IFACE_CONN_INTERFACE_CAPABILITIES \
+ "org.freedesktop.Telepathy.Connection.Interface.Capabilities"
+#define TP_IFACE_CONN_INTERFACE_CONTACT_INFO \
+ "org.freedesktop.Telepathy.Connection.Interface.ContactInfo"
+#define TP_IFACE_CONN_INTERFACE_FORWARDING \
+ "org.freedesktop.Telepathy.Connection.Interface.Forwarding"
+#define TP_IFACE_CONN_INTERFACE_PRESENCE \
+ "org.freedesktop.Telepathy.Connection.Interface.Presence"
+#define TP_IFACE_CONN_INTERFACE_PRIVACY \
+ "org.freedesktop.Telepathy.Connection.Interface.Privacy"
+#define TP_IFACE_CONN_INTERFACE_AVATAR \
+ "org.freedesktop.Telepathy.Connection.Interface.Avatars"
+#define TP_IFACE_CONN_INTERFACE_RENAMING \
+ "org.freedesktop.Telepathy.Connection.Interface.Renaming"
+#define TP_IFACE_CONN_MGR_INTERFACE \
+ "org.freedesktop.Telepathy.ConnectionManager"
+#define TP_IFACE_MEDIA_SESSION_HANDLER \
+ "org.freedesktop.Telepathy.Media.SessionHandler"
+#define TP_IFACE_MEDIA_STREAM_HANDLER \
+ "org.freedesktop.Telepathy.Media.StreamHandler"
+#define TP_IFACE_PROPERTIES \
+ "org.freedesktop.Telepathy.Properties"
+
+G_END_DECLS
+
+#endif /* #ifndef __TELEPATHY_INTERFACES_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-props-iface-gen.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,147 @@
+/* tp-props-iface-gen.h
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Properties
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Properties
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_props_iface_get_properties (DBusGProxy *proxy, const GArray* IN_properties, GPtrArray** OUT_arg1, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "GetProperties", error, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_properties, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID)), OUT_arg1, G_TYPE_INVALID);
+}
+
+typedef void (*tp_props_iface_get_properties_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg1, GError *error, gpointer userdata);
+
+static void
+tp_props_iface_get_properties_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg1;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID)), &OUT_arg1, G_TYPE_INVALID);
+ (*(tp_props_iface_get_properties_reply)data->cb) (proxy, OUT_arg1, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_props_iface_get_properties_async (DBusGProxy *proxy, const GArray* IN_properties, tp_props_iface_get_properties_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "GetProperties", tp_props_iface_get_properties_async_callback, stuff, g_free, dbus_g_type_get_collection ("GArray", G_TYPE_UINT), IN_properties, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_props_iface_list_properties (DBusGProxy *proxy, GPtrArray** OUT_arg0, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "ListProperties", error, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)), OUT_arg0, G_TYPE_INVALID);
+}
+
+typedef void (*tp_props_iface_list_properties_reply) (DBusGProxy *proxy, GPtrArray *OUT_arg0, GError *error, gpointer userdata);
+
+static void
+tp_props_iface_list_properties_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ GPtrArray* OUT_arg0;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)), &OUT_arg0, G_TYPE_INVALID);
+ (*(tp_props_iface_list_properties_reply)data->cb) (proxy, OUT_arg0, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_props_iface_list_properties_async (DBusGProxy *proxy, tp_props_iface_list_properties_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "ListProperties", tp_props_iface_list_properties_async_callback, stuff, g_free, G_TYPE_INVALID);
+}
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+tp_props_iface_set_properties (DBusGProxy *proxy, const GPtrArray* IN_properties, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "SetProperties", error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID)), IN_properties, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*tp_props_iface_set_properties_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+tp_props_iface_set_properties_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*)user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(tp_props_iface_set_properties_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+tp_props_iface_set_properties_async (DBusGProxy *proxy, const GPtrArray* IN_properties, tp_props_iface_set_properties_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "SetProperties", tp_props_iface_set_properties_async_callback, stuff, g_free, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID)), IN_properties, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_Telepathy_Properties */
+
+G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/inc/tp-props-iface.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,121 @@
+/* tp-props-iface.h
+ *
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef TP_PROPS_IFACE_H
+#define TP_PROPS_IFACE_H
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+#include <dbus/dbus-glib.h>
+
+#include "tp-constants.h"
+#include "tp-props-iface-gen.h"
+
+#define TELEPATHY_PROPS_IFACE_QUARK (tp_get_props_interface())
+
+typedef struct _TpPropsIface TpPropsIface;
+typedef struct _TpPropsIfaceClass TpPropsIfaceClass;
+
+struct _TpPropsIface
+{
+ DBusGProxy parent;
+ gpointer priv;
+};
+
+struct _TpPropsIfaceClass
+{
+ DBusGProxyClass parent_class;
+};
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GType tp_props_iface_get_type (void);
+#ifdef __cplusplus
+}
+#endif
+
+#define TELEPATHY_PROPS_IFACE_TYPE (tp_props_iface_get_type ())
+
+#define TELEPATHY_PROPS_IFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), TELEPATHY_PROPS_IFACE_TYPE, \
+ TpPropsIface))
+
+#define TELEPATHY_PROPS_IFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), TELEPATHY_PROPS_IFACE_TYPE, \
+ TpPropsIfaceClass))
+
+#define TELEPATHY_IS_PROPS_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), TELEPATHY_PROPS_IFACE_TYPE))
+
+#define TELEPATHY_IS_PROPS_IFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE \
+ ((klass), TELEPATHY_PROPS_IFACE_TYPE))
+
+#define TELEPATHY_PROPS_IFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), TELEPATHY_PROPS_IFACE_TYPE, \
+ TpPropsIfaceClass))
+
+/**
+ * TpPropsChangedFlags:
+ * @TP_PROPS_CHANGED_VALUE: The value of the property changed.
+ * @TP_PROPS_CHANGED_FLAGS: The flags of the property changed.
+ */
+typedef enum
+{
+ TP_PROPS_CHANGED_VALUE = 0x01,
+ TP_PROPS_CHANGED_FLAGS = 0x02
+} TpPropsChanged;
+
+TpPropsIface * tp_props_iface_new (DBusGConnection *connection,
+ const char *name,
+ const char *path_name);
+
+void tp_props_iface_set_mapping (TpPropsIface *iface,
+ const gchar *first_name, ...);
+gboolean tp_props_iface_get_value (TpPropsIface* iface, guint prop_id,
+ GValue *return_value);
+
+gboolean tp_props_iface_set_value (TpPropsIface* iface, guint prop_id,
+ const GValue *value);
+
+TelepathyPropertyFlags tp_props_iface_property_flags (TpPropsIface* iface, guint prop_id);
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GQuark tp_get_props_interface(void);
+#ifdef __cplusplus
+}
+#endif
+
+void tp_props_interface_set_signatures (DBusGProxy *proxy);
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/rom/libtelepathy.iby Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,34 @@
+
+/* libtelepathy.iby
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef __LIBTELEPATHY_IBY__
+#define __LIBTELEPATHY_IBY__
+
+
+//Telepathy DLLs
+file=ABI_DIR\BUILD_DIR\libtelepathy.dll SHARED_LIB_DIR\libtelepathy.dll
+
+// mecostub SIS, provides support for SIS upgrading
+//data=DATAZ_\system\install\meco_stub.sis system\install\meco_stub.sis
+
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/Makefile.am Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,100 @@
+# Move this back to GENHEADERS once dbus-binding-tool supports 'g' type
+# tp-chan-type-contact-search-gen.h
+
+GENHEADERS = \
+ tp-connmgr-gen.h \
+ tp-conn-gen.h \
+ tp-chan-gen.h \
+ tp-conn-iface-avatars-gen.h \
+ tp-chan-iface-dtmf-gen.h \
+ tp-chan-iface-group-gen.h \
+ tp-chan-iface-hold-gen.h \
+ tp-chan-iface-password-gen.h \
+ tp-chan-iface-transfer-gen.h \
+ tp-chan-iface-ice-signalling-gen.h \
+ tp-chan-type-contact-list-gen.h \
+ tp-chan-type-room-list-gen.h \
+ tp-chan-type-streamed-media-gen.h \
+ tp-chan-type-text-gen.h \
+ tp-conn-iface-aliasing-gen.h \
+ tp-conn-iface-capabilities-gen.h \
+ tp-conn-iface-contact-info-gen.h \
+ tp-conn-iface-forwarding-gen.h \
+ tp-conn-iface-presence-gen.h \
+ tp-conn-iface-privacy-gen.h \
+ tp-conn-iface-renaming-gen.h \
+ tp-props-iface-gen.h \
+ tp-ch-gen.h \
+ tp-ice-session-handler-gen.h \
+ tp-ice-stream-handler-gen.h \
+ tp-ifaces-signals-marshal.h \
+ tp-chan-signals-marshal.h \
+ tp-conn-signals-marshal.h \
+ tp-connmgr-signals-marshal.h
+
+MARSHALLER_SOURCES = \
+ tp-ifaces-signals-marshal.c \
+ tp-chan-signals-marshal.c \
+ tp-conn-signals-marshal.c \
+ tp-connmgr-signals-marshal.c
+
+
+BUILT_SOURCES = \
+ $(GENHEADERS) \
+ $(MARSHALLER_SOURCES)
+
+
+# Correctly clean the generated headers, but keep the xml description
+CLEANFILES = $(BUILT_SOURCES)
+#Rule to generate the binding headers
+%-gen.h: $(top_builddir)/xml/%.xml Makefile.am
+ dbus-binding-tool --prefix=$* --mode=glib-client $< > $*-gen.h
+
+# Create the necessary marshallers for the signals implemented by the
+# library
+
+%-marshal.h: %-marshal.list Makefile.am
+ glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
+
+%-marshal.c: %-marshal.list Makefile.am
+ glib-genmarshal --body --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.c
+
+lib_LTLIBRARIES = libtelepathy.la
+
+libtelepathy_la_CFLAGS = $(DBUS_CFLAGS) $(ERROR_CFLAGS) $(GLIB_CFLAGS)
+libtelepathy_la_LIBADD = $(DBUS_LIBS) $(GLIB_LIBS)
+libtelepathy_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -export-symbols-regex '^tp_' \
+ -export-dynamic
+
+CORESOURCES = \
+ tp-chan.c \
+ tp-conn.c \
+ tp-connmgr.c \
+ tp-helpers.c \
+ tp-props-iface.c
+
+COREHEADERS = \
+ tp-chan-ifaces-signal-setters.h \
+ tp-conn-ifaces-signal-setters.h \
+ tp-chan.h \
+ tp-conn.h \
+ tp-connmgr.h \
+ tp-constants.h \
+ tp-helpers.h \
+ tp-interfaces.h \
+ tp-props-iface.h
+
+libtelepathy_la_SOURCES = \
+ tp-chan-ifaces-signal-setters.c \
+ tp-conn-ifaces-signal-setters.c \
+ $(MARSHALLER_SOURCES) \
+ $(CORESOURCES) \
+ $(COREHEADERS)
+
+telepathyincdir=$(includedir)/telepathy-1.0/libtelepathy
+
+telepathyinc_HEADERS = \
+ $(COREHEADERS) \
+ $(GENHEADERS)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/Makefile.in Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,695 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Move this back to GENHEADERS once dbus-binding-tool supports 'g' type
+# tp-chan-type-contact-search-gen.h
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ $(telepathyinc_HEADERS)
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(telepathyincdir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libtelepathy_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am__objects_1 = libtelepathy_la-tp-ifaces-signals-marshal.lo \
+ libtelepathy_la-tp-chan-signals-marshal.lo \
+ libtelepathy_la-tp-conn-signals-marshal.lo \
+ libtelepathy_la-tp-connmgr-signals-marshal.lo
+am__objects_2 = libtelepathy_la-tp-chan.lo libtelepathy_la-tp-conn.lo \
+ libtelepathy_la-tp-connmgr.lo libtelepathy_la-tp-helpers.lo \
+ libtelepathy_la-tp-props-iface.lo
+am__objects_3 =
+am_libtelepathy_la_OBJECTS = \
+ libtelepathy_la-tp-chan-ifaces-signal-setters.lo \
+ libtelepathy_la-tp-conn-ifaces-signal-setters.lo \
+ $(am__objects_1) $(am__objects_2) $(am__objects_3)
+libtelepathy_la_OBJECTS = $(am_libtelepathy_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libtelepathy_la_SOURCES)
+DIST_SOURCES = $(libtelepathy_la_SOURCES)
+telepathyincHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(telepathyinc_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GREP = @GREP@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTELEPATHY_BINARY_AGE = @LIBTELEPATHY_BINARY_AGE@
+LIBTELEPATHY_INTERFACE_AGE = @LIBTELEPATHY_INTERFACE_AGE@
+LIBTELEPATHY_MAJORMINOR = @LIBTELEPATHY_MAJORMINOR@
+LIBTELEPATHY_MAJOR_VERSION = @LIBTELEPATHY_MAJOR_VERSION@
+LIBTELEPATHY_MICRO_VERSION = @LIBTELEPATHY_MICRO_VERSION@
+LIBTELEPATHY_MINOR_VERSION = @LIBTELEPATHY_MINOR_VERSION@
+LIBTELEPATHY_VERSION = @LIBTELEPATHY_VERSION@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+GENHEADERS = \
+ tp-connmgr-gen.h \
+ tp-conn-gen.h \
+ tp-chan-gen.h \
+ tp-conn-iface-avatars-gen.h \
+ tp-chan-iface-dtmf-gen.h \
+ tp-chan-iface-group-gen.h \
+ tp-chan-iface-hold-gen.h \
+ tp-chan-iface-password-gen.h \
+ tp-chan-iface-transfer-gen.h \
+ tp-chan-iface-ice-signalling-gen.h \
+ tp-chan-type-contact-list-gen.h \
+ tp-chan-type-room-list-gen.h \
+ tp-chan-type-streamed-media-gen.h \
+ tp-chan-type-text-gen.h \
+ tp-conn-iface-aliasing-gen.h \
+ tp-conn-iface-capabilities-gen.h \
+ tp-conn-iface-contact-info-gen.h \
+ tp-conn-iface-forwarding-gen.h \
+ tp-conn-iface-presence-gen.h \
+ tp-conn-iface-privacy-gen.h \
+ tp-conn-iface-renaming-gen.h \
+ tp-props-iface-gen.h \
+ tp-ch-gen.h \
+ tp-ice-session-handler-gen.h \
+ tp-ice-stream-handler-gen.h \
+ tp-ifaces-signals-marshal.h \
+ tp-chan-signals-marshal.h \
+ tp-conn-signals-marshal.h \
+ tp-connmgr-signals-marshal.h
+
+MARSHALLER_SOURCES = \
+ tp-ifaces-signals-marshal.c \
+ tp-chan-signals-marshal.c \
+ tp-conn-signals-marshal.c \
+ tp-connmgr-signals-marshal.c
+
+BUILT_SOURCES = \
+ $(GENHEADERS) \
+ $(MARSHALLER_SOURCES)
+
+
+# Correctly clean the generated headers, but keep the xml description
+CLEANFILES = $(BUILT_SOURCES)
+lib_LTLIBRARIES = libtelepathy.la
+libtelepathy_la_CFLAGS = $(DBUS_CFLAGS) $(ERROR_CFLAGS) $(GLIB_CFLAGS)
+libtelepathy_la_LIBADD = $(DBUS_LIBS) $(GLIB_LIBS)
+libtelepathy_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -export-symbols-regex '^tp_' \
+ -export-dynamic
+
+CORESOURCES = \
+ tp-chan.c \
+ tp-conn.c \
+ tp-connmgr.c \
+ tp-helpers.c \
+ tp-props-iface.c
+
+COREHEADERS = \
+ tp-chan-ifaces-signal-setters.h \
+ tp-conn-ifaces-signal-setters.h \
+ tp-chan.h \
+ tp-conn.h \
+ tp-connmgr.h \
+ tp-constants.h \
+ tp-helpers.h \
+ tp-interfaces.h \
+ tp-props-iface.h
+
+libtelepathy_la_SOURCES = \
+ tp-chan-ifaces-signal-setters.c \
+ tp-conn-ifaces-signal-setters.c \
+ $(MARSHALLER_SOURCES) \
+ $(CORESOURCES) \
+ $(COREHEADERS)
+
+telepathyincdir = $(includedir)/telepathy-1.0/libtelepathy
+telepathyinc_HEADERS = \
+ $(COREHEADERS) \
+ $(GENHEADERS)
+
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libtelepathy.la: $(libtelepathy_la_OBJECTS) $(libtelepathy_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libtelepathy_la_LDFLAGS) $(libtelepathy_la_OBJECTS) $(libtelepathy_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-chan-ifaces-signal-setters.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-chan-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-chan.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-conn-ifaces-signal-setters.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-conn-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-conn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-connmgr-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-connmgr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-helpers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-ifaces-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtelepathy_la-tp-props-iface.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+libtelepathy_la-tp-chan-ifaces-signal-setters.lo: tp-chan-ifaces-signal-setters.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-chan-ifaces-signal-setters.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-chan-ifaces-signal-setters.Tpo" -c -o libtelepathy_la-tp-chan-ifaces-signal-setters.lo `test -f 'tp-chan-ifaces-signal-setters.c' || echo '$(srcdir)/'`tp-chan-ifaces-signal-setters.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-chan-ifaces-signal-setters.Tpo" "$(DEPDIR)/libtelepathy_la-tp-chan-ifaces-signal-setters.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-chan-ifaces-signal-setters.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-chan-ifaces-signal-setters.c' object='libtelepathy_la-tp-chan-ifaces-signal-setters.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-chan-ifaces-signal-setters.lo `test -f 'tp-chan-ifaces-signal-setters.c' || echo '$(srcdir)/'`tp-chan-ifaces-signal-setters.c
+
+libtelepathy_la-tp-conn-ifaces-signal-setters.lo: tp-conn-ifaces-signal-setters.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-conn-ifaces-signal-setters.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-conn-ifaces-signal-setters.Tpo" -c -o libtelepathy_la-tp-conn-ifaces-signal-setters.lo `test -f 'tp-conn-ifaces-signal-setters.c' || echo '$(srcdir)/'`tp-conn-ifaces-signal-setters.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-conn-ifaces-signal-setters.Tpo" "$(DEPDIR)/libtelepathy_la-tp-conn-ifaces-signal-setters.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-conn-ifaces-signal-setters.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-conn-ifaces-signal-setters.c' object='libtelepathy_la-tp-conn-ifaces-signal-setters.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-conn-ifaces-signal-setters.lo `test -f 'tp-conn-ifaces-signal-setters.c' || echo '$(srcdir)/'`tp-conn-ifaces-signal-setters.c
+
+libtelepathy_la-tp-ifaces-signals-marshal.lo: tp-ifaces-signals-marshal.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-ifaces-signals-marshal.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-ifaces-signals-marshal.Tpo" -c -o libtelepathy_la-tp-ifaces-signals-marshal.lo `test -f 'tp-ifaces-signals-marshal.c' || echo '$(srcdir)/'`tp-ifaces-signals-marshal.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-ifaces-signals-marshal.Tpo" "$(DEPDIR)/libtelepathy_la-tp-ifaces-signals-marshal.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-ifaces-signals-marshal.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-ifaces-signals-marshal.c' object='libtelepathy_la-tp-ifaces-signals-marshal.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-ifaces-signals-marshal.lo `test -f 'tp-ifaces-signals-marshal.c' || echo '$(srcdir)/'`tp-ifaces-signals-marshal.c
+
+libtelepathy_la-tp-chan-signals-marshal.lo: tp-chan-signals-marshal.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-chan-signals-marshal.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-chan-signals-marshal.Tpo" -c -o libtelepathy_la-tp-chan-signals-marshal.lo `test -f 'tp-chan-signals-marshal.c' || echo '$(srcdir)/'`tp-chan-signals-marshal.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-chan-signals-marshal.Tpo" "$(DEPDIR)/libtelepathy_la-tp-chan-signals-marshal.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-chan-signals-marshal.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-chan-signals-marshal.c' object='libtelepathy_la-tp-chan-signals-marshal.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-chan-signals-marshal.lo `test -f 'tp-chan-signals-marshal.c' || echo '$(srcdir)/'`tp-chan-signals-marshal.c
+
+libtelepathy_la-tp-conn-signals-marshal.lo: tp-conn-signals-marshal.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-conn-signals-marshal.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-conn-signals-marshal.Tpo" -c -o libtelepathy_la-tp-conn-signals-marshal.lo `test -f 'tp-conn-signals-marshal.c' || echo '$(srcdir)/'`tp-conn-signals-marshal.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-conn-signals-marshal.Tpo" "$(DEPDIR)/libtelepathy_la-tp-conn-signals-marshal.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-conn-signals-marshal.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-conn-signals-marshal.c' object='libtelepathy_la-tp-conn-signals-marshal.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-conn-signals-marshal.lo `test -f 'tp-conn-signals-marshal.c' || echo '$(srcdir)/'`tp-conn-signals-marshal.c
+
+libtelepathy_la-tp-connmgr-signals-marshal.lo: tp-connmgr-signals-marshal.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-connmgr-signals-marshal.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-connmgr-signals-marshal.Tpo" -c -o libtelepathy_la-tp-connmgr-signals-marshal.lo `test -f 'tp-connmgr-signals-marshal.c' || echo '$(srcdir)/'`tp-connmgr-signals-marshal.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-connmgr-signals-marshal.Tpo" "$(DEPDIR)/libtelepathy_la-tp-connmgr-signals-marshal.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-connmgr-signals-marshal.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-connmgr-signals-marshal.c' object='libtelepathy_la-tp-connmgr-signals-marshal.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-connmgr-signals-marshal.lo `test -f 'tp-connmgr-signals-marshal.c' || echo '$(srcdir)/'`tp-connmgr-signals-marshal.c
+
+libtelepathy_la-tp-chan.lo: tp-chan.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-chan.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-chan.Tpo" -c -o libtelepathy_la-tp-chan.lo `test -f 'tp-chan.c' || echo '$(srcdir)/'`tp-chan.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-chan.Tpo" "$(DEPDIR)/libtelepathy_la-tp-chan.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-chan.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-chan.c' object='libtelepathy_la-tp-chan.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-chan.lo `test -f 'tp-chan.c' || echo '$(srcdir)/'`tp-chan.c
+
+libtelepathy_la-tp-conn.lo: tp-conn.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-conn.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-conn.Tpo" -c -o libtelepathy_la-tp-conn.lo `test -f 'tp-conn.c' || echo '$(srcdir)/'`tp-conn.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-conn.Tpo" "$(DEPDIR)/libtelepathy_la-tp-conn.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-conn.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-conn.c' object='libtelepathy_la-tp-conn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-conn.lo `test -f 'tp-conn.c' || echo '$(srcdir)/'`tp-conn.c
+
+libtelepathy_la-tp-connmgr.lo: tp-connmgr.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-connmgr.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-connmgr.Tpo" -c -o libtelepathy_la-tp-connmgr.lo `test -f 'tp-connmgr.c' || echo '$(srcdir)/'`tp-connmgr.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-connmgr.Tpo" "$(DEPDIR)/libtelepathy_la-tp-connmgr.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-connmgr.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-connmgr.c' object='libtelepathy_la-tp-connmgr.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-connmgr.lo `test -f 'tp-connmgr.c' || echo '$(srcdir)/'`tp-connmgr.c
+
+libtelepathy_la-tp-helpers.lo: tp-helpers.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-helpers.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-helpers.Tpo" -c -o libtelepathy_la-tp-helpers.lo `test -f 'tp-helpers.c' || echo '$(srcdir)/'`tp-helpers.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-helpers.Tpo" "$(DEPDIR)/libtelepathy_la-tp-helpers.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-helpers.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-helpers.c' object='libtelepathy_la-tp-helpers.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-helpers.lo `test -f 'tp-helpers.c' || echo '$(srcdir)/'`tp-helpers.c
+
+libtelepathy_la-tp-props-iface.lo: tp-props-iface.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -MT libtelepathy_la-tp-props-iface.lo -MD -MP -MF "$(DEPDIR)/libtelepathy_la-tp-props-iface.Tpo" -c -o libtelepathy_la-tp-props-iface.lo `test -f 'tp-props-iface.c' || echo '$(srcdir)/'`tp-props-iface.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libtelepathy_la-tp-props-iface.Tpo" "$(DEPDIR)/libtelepathy_la-tp-props-iface.Plo"; else rm -f "$(DEPDIR)/libtelepathy_la-tp-props-iface.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tp-props-iface.c' object='libtelepathy_la-tp-props-iface.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtelepathy_la_CFLAGS) $(CFLAGS) -c -o libtelepathy_la-tp-props-iface.lo `test -f 'tp-props-iface.c' || echo '$(srcdir)/'`tp-props-iface.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+install-telepathyincHEADERS: $(telepathyinc_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(telepathyincdir)" || $(mkdir_p) "$(DESTDIR)$(telepathyincdir)"
+ @list='$(telepathyinc_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(telepathyincHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(telepathyincdir)/$$f'"; \
+ $(telepathyincHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(telepathyincdir)/$$f"; \
+ done
+
+uninstall-telepathyincHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(telepathyinc_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(telepathyincdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(telepathyincdir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(telepathyincdir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-telepathyincHEADERS
+
+install-exec-am: install-libLTLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-telepathyincHEADERS
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am \
+ install-libLTLIBRARIES install-man install-strip \
+ install-telepathyincHEADERS installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-telepathyincHEADERS
+
+#Rule to generate the binding headers
+%-gen.h: $(top_builddir)/xml/%.xml Makefile.am
+ dbus-binding-tool --prefix=$* --mode=glib-client $< > $*-gen.h
+
+# Create the necessary marshallers for the signals implemented by the
+# library
+
+%-marshal.h: %-marshal.list Makefile.am
+ glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
+
+%-marshal.c: %-marshal.list Makefile.am
+ glib-genmarshal --body --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.c
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/libtelepathy_wsd.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,88 @@
+/*
+ *
+ * Copyright (C) 2008 Nokia Corporation.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include <e32std.h>
+#include "libtelepathy_wsd_solution.h"
+#include <pls.h> // For emulator WSD API
+
+const TUid KLibTelUid3 = {0x2000F850}; // This is the UID of the library
+
+struct libtelepathy_global_struct* libtelepathy_ImpurePtr()
+{
+ #if defined(__WINSCW__) || defined(__WINS__)
+
+ // Access the PLS of this process
+ struct libtelepathy_global_struct *g = Pls<struct libtelepathy_global_struct>(KLibTelUid3, &libtelepathy_Init);
+ return g;
+
+ #else
+
+ return NULL;
+
+ #endif
+
+}
+
+int libtelepathy_Init(libtelepathy_global_struct *g)
+{
+ if(g)
+ {
+
+ g->GET_WSD_VAR_NAME(parent_class,tp_chan,s) = NULL;
+ g->GET_WSD_VAR_NAME(type1,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret1,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret2,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret3,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret4,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret5,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret6,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret7,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret8,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret9,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret10,tp_chan,s) = 0;
+ g->GET_WSD_VAR_NAME(ret11,tp_chan,s) = 0;
+
+ g->GET_WSD_VAR_NAME(parent_class,tp_conn,s) = NULL;
+ g->GET_WSD_VAR_NAME(type1,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret1,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret2,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret3,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret4,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret5,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret6,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret7,tp_conn,s) = 0;
+ g->GET_WSD_VAR_NAME(ret8,tp_conn,s) = 0;
+
+ g->GET_WSD_VAR_NAME(parent_class,tp_connmgr,s) = NULL;
+ g->GET_WSD_VAR_NAME(type1,tp_connmgr,s) = 0;
+
+ g->GET_WSD_VAR_NAME(bus_proxy,tp_helpers,s) = NULL;
+ g->GET_WSD_VAR_NAME(bus1,tp_helpers,s) = NULL;
+
+
+ g->GET_WSD_VAR_NAME(parent_class,tp_props_iface,s) = NULL;
+ g->GET_WSD_VAR_NAME(type1,tp_props_iface,s) = 0;
+ g->GET_WSD_VAR_NAME(ret,tp_props_iface,s) = 0;
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,tp_props_iface,s)),0,LAST_SIGNAL_TP_PROPS_IFACE*sizeof(guint));
+
+ return 0;
+ }
+ return 1;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/libtelepathy_wsd_macros.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,66 @@
+/* libtelepathy_wsd_macros.h
+ *
+ *
+ * Copyright (C) 2008 Nokia Corporation.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef _LIBTELEPATHY_WSD_DEFS_H_
+#define _LIBTELEPATHY_WSD_DEFS_H_
+
+#if (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
+#if EMULATOR
+#undef EMULATOR
+#endif
+#ifdef GET_WSD_VAR_NAME
+#undef GET_WSD_VAR_NAME
+#endif
+
+#define EMULATOR (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
+#define GET_WSD_VAR_NAME(var,filename,prefix) _##prefix##_##filename##_##var
+
+#define RETURN_WSD_VAR(var,filename,prefix) (libtelepathy_ImpurePtr()->GET_WSD_VAR_NAME(var,filename,prefix))
+
+#define GET_WSD_VAR_FROM_TLS(var,filename,type,prefix)\
+type *_##prefix##_##filename##_##var()\
+{\
+ return (&RETURN_WSD_VAR(var,filename,prefix));\
+}
+
+#define GET_WSD_ARRAY_FROM_TLS(var,filename,type,prefix)\
+type *_##prefix##_##filename##_##var()\
+{\
+ return (RETURN_WSD_VAR(var,filename,prefix));\
+}
+
+#define VARIABLE_DECL(var,varprefix,filename,datatype)\
+datatype GET_WSD_VAR_NAME(var,filename,varprefix);
+
+#define VARIABLE_DECL_ARRAY(var,prefix,filename,datatype,size) \
+datatype GET_WSD_VAR_NAME(var,filename,prefix)[size];
+
+
+#define GET_STATIC_VAR_FROM_TLS(var,filename,type) GET_WSD_VAR_FROM_TLS(var,filename,type,s)
+
+#define GET_GLOBAL_VAR_FROM_TLS(var,filename,type) GET_WSD_VAR_FROM_TLS(var,filename,type,g)
+
+#define GET_STATIC_ARRAY_FROM_TLS(var,filename,type) GET_WSD_ARRAY_FROM_TLS(var,filename,type,s)
+
+#define GET_GLOBAL_ARRAY_FROM_TLS(var,filename,type) GET_WSD_ARRAY_FROM_TLS(var,filename,type,g)
+
+#endif
+#endif //_LIBTELEPATHY_WSD_DEFS_H_
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/libtelepathy_wsd_solution.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,96 @@
+/* libtelepathy_wsd_solution.h part of libtelepathy
+ *
+ *
+ * Copyright (C) 2007 Nokia Corporation.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef _LIBTELEPATHY_WSD_H
+#define _LIBTELEPATHY_WSD_H
+#include "libtelepathy_wsd_macros.h"
+
+#include <glib/ghash.h>
+#include <glib/gquark.h>
+#include <glib-object.h>
+#include "glibconfig.h"
+#include <dbus/dbus.h>
+
+#include <gobject/gvaluecollector.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+
+#define LAST_SIGNAL_TP_PROPS_IFACE 2
+
+#if EMULATOR
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct libtelepathy_global_struct
+{
+
+ VARIABLE_DECL(parent_class,s,tp_chan,GObjectClass *)
+ VARIABLE_DECL(type1,s,tp_chan,GType)
+ VARIABLE_DECL(ret1,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret2,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret3,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret4,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret5,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret6,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret7,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret8,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret9,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret10,s,tp_chan,GQuark)
+ VARIABLE_DECL(ret11,s,tp_chan,GQuark)
+
+ VARIABLE_DECL(parent_class,s,tp_conn,GObjectClass *)
+ VARIABLE_DECL(type1,s,tp_conn,GType)
+ VARIABLE_DECL(ret1,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret2,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret3,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret4,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret5,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret6,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret7,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret8,s,tp_conn,GQuark)
+ VARIABLE_DECL(ret9,s,tp_conn,GQuark)
+
+ VARIABLE_DECL(parent_class,s,tp_connmgr,GObjectClass *)
+ VARIABLE_DECL(type1,s,tp_connmgr,GType)
+
+ VARIABLE_DECL(bus_proxy,s,tp_helpers,DBusGProxy *)
+ VARIABLE_DECL(bus1,s,tp_helpers,DBusGConnection *)
+
+ VARIABLE_DECL(parent_class,s,tp_props_iface,GObjectClass *)
+ VARIABLE_DECL(type1,s,tp_props_iface,GType)
+ VARIABLE_DECL(ret,s,tp_props_iface,GQuark)
+ VARIABLE_DECL_ARRAY(signals,s,tp_props_iface,guint,LAST_SIGNAL_TP_PROPS_IFACE)
+
+ /*END-global vars*/
+
+ };
+
+struct libtelepathy_global_struct * libtelepathy_ImpurePtr();
+int libtelepathy_Init(struct libtelepathy_global_struct *);
+#ifdef __cplusplus
+}
+#endif
+#endif //EMULATOR
+#endif //header guard _LIBTELEPATHY_WSD_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-chan-ifaces-signal-setters.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,103 @@
+/* tp-chan-ifaces-signal-setters.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "tp-chan-ifaces-signal-setters.h"
+
+
+void tp_chan_set_contactsearch_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "SearchResultReceived", G_TYPE_UINT,
+ (dbus_g_type_get_map ("GHashTable",
+ G_TYPE_STRING, G_TYPE_VALUE)), G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "SearchStateChanged",
+ G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+
+void tp_chan_set_streamedmedia_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "StreamStateChanged",
+ G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_INVALID);
+ /* FIXME: Outdated
+ dbus_g_proxy_add_signal(proxy, "ReceivedMediaParameters",
+ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ */
+}
+
+void tp_chan_set_roomlist_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "GotRooms",
+ (dbus_g_type_get_struct ("GValueArray",
+ G_TYPE_UINT, G_TYPE_STRING,
+ (dbus_g_type_get_map ("GHashTable",
+ G_TYPE_STRING, G_TYPE_VALUE)))), G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "ListingRooms",
+ G_TYPE_BOOLEAN, G_TYPE_INVALID);
+}
+
+void tp_chan_set_text_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "Received", G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "Sent", G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "SendError", G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "LostMessage", G_TYPE_INVALID);
+}
+
+void tp_chan_set_dtmf_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "ReceivedDTMF", G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+void tp_chan_set_group_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "GroupFlagsChanged", G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "MembersChanged", G_TYPE_STRING,
+ DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY,
+ DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY,
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+void tp_chan_set_hold_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "HoldStateChanged", G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+void tp_chan_set_password_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "PasswordFlagsChanged",
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+void tp_chan_set_icesignalling_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "NewIceSessionHandler",
+ DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING,
+ G_TYPE_INVALID);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-chan-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,70 @@
+/* tp-chan-signals-marshal.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:VOID (tp-chan-signals-marshal.list:1) */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-chan.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,649 @@
+/* tp-chan.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <string.h>
+#include "tp-chan.h"
+#include "tp-chan-signals-marshal.h"
+#include "tp-props-iface.h"
+#include "tp-helpers.h"
+
+#ifdef EMULATOR
+#include "libtelepathy_wsd_solution.h"
+#endif
+
+#ifdef EMULATOR
+
+ GET_STATIC_VAR_FROM_TLS(parent_class,tp_chan,GObjectClass *)
+ #define parent_class (*GET_WSD_VAR_NAME(parent_class,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(type1,tp_chan,GType)
+ #define type1 (*GET_WSD_VAR_NAME(type1,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret1,tp_chan,GQuark)
+ #define ret1 (*GET_WSD_VAR_NAME(ret1,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret2,tp_chan,GQuark)
+ #define ret2 (*GET_WSD_VAR_NAME(ret2,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret3,tp_chan,GQuark)
+ #define ret3 (*GET_WSD_VAR_NAME(ret3,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret4,tp_chan,GQuark)
+ #define ret4 (*GET_WSD_VAR_NAME(ret4,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret5,tp_chan,GQuark)
+ #define ret5 (*GET_WSD_VAR_NAME(ret5,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret6,tp_chan,GQuark)
+ #define ret6 (*GET_WSD_VAR_NAME(ret6,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret7,tp_chan,GQuark)
+ #define ret7 (*GET_WSD_VAR_NAME(ret7,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret8,tp_chan,GQuark)
+ #define ret8 (*GET_WSD_VAR_NAME(ret8,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret9,tp_chan,GQuark)
+ #define ret9 (*GET_WSD_VAR_NAME(ret9,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret10,tp_chan,GQuark)
+ #define ret10 (*GET_WSD_VAR_NAME(ret10,tp_chan,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret11,tp_chan,GQuark)
+ #define ret11 (*GET_WSD_VAR_NAME(ret11,tp_chan,s)())
+
+
+#else
+ static GObjectClass *parent_class = NULL;
+#endif
+
+static void synthesize_closed(TpChan *chan);
+
+static void _tp_chan_register_signal_marshallers()
+{
+ /* Register marshaller for the Close signal */
+ dbus_g_object_register_marshaller(tp_chan_signals_marshal_VOID__VOID,
+ G_TYPE_NONE, G_TYPE_INVALID);
+}
+
+static void _tp_chan_register_interface_signal_marshallers()
+{
+
+ /* Register marshaller for ContactSearch interface signal
+ SearchResultReceived*/
+
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_BOXED,
+ G_TYPE_NONE, G_TYPE_UINT, G_TYPE_BOXED, G_TYPE_INVALID);
+
+ /* Register marshaller for ContactSearch interface signal
+ * SearchStateChanged */
+
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT,
+ G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INVALID);
+
+ /* Register marshaller for StreamedMedia interface signal
+ ReceivedMediaParameters */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+ /* Register marshaller for StreamedMedia interface signal
+ StreamStateChanged */
+
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+
+ /* Register marshaller for RoomList interface signal GotRooms */
+
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__BOXED,
+ G_TYPE_NONE, G_TYPE_BOXED, G_TYPE_INVALID);
+
+ /* Register marshaller for RoomList interface signal ListingRooms */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, G_TYPE_BOOLEAN,
+ G_TYPE_INVALID);
+
+ /* Register marshaller for channel type Text interface signal Received */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING,
+ G_TYPE_INVALID);
+
+ /* Register marshaller for channel type Text interface Sent */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+
+ /* Register marshaller used by the following iface/signal pairs:
+ * DTFM/ReceivedDTMF, Group/GroupFlagsChanged, Hold/HoldStateChanged,
+ * Password/PasswordFlagsChanged, Subject/SubjectFlagsChanged */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_INVALID);
+ /* Register marshaller for Group interface signal MembersChanged */
+
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOXED,
+ G_TYPE_BOXED, G_TYPE_BOXED, G_TYPE_BOXED,
+ G_TYPE_UINT, G_TYPE_UINT,G_TYPE_INVALID);
+
+ /* Register marshaller for Text Channel interface signal SendError */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+
+ /* Register marshaller for IceSignalling interface signal
+ NewIceSessionHandler */
+
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_INVALID);
+
+}
+
+
+/* We initialize the list of signatures here, so that we can use
+ * it to add them for new interface instances later.*/
+
+/* FIXME: This should be replaced by a more automatic way of doing
+ * this. The reason for using a set of function pointers is that there is no
+ * apparent cleaner way of doing this, unless DBusGProxy gains a non-varargs
+ * version of dbus_g_proxy_add_signal...
+ */
+
+
+static void _tp_chan_init_interface_signal_signatures(GData **signal_sigs)
+{
+ g_datalist_init(signal_sigs);
+
+
+ /* Create and store contact search iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK,
+ (gpointer)tp_chan_set_contactsearch_signatures);
+
+ /* Store streamed media iface signal signatures */
+ g_datalist_id_set_data(signal_sigs,
+ TELEPATHY_CHAN_IFACE_STREAMED_QUARK,
+ (gpointer)tp_chan_set_streamedmedia_signatures);
+ /* Store roomlist signal iface signal parameters */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_ROOMLIST_QUARK,
+ (gpointer)tp_chan_set_roomlist_signatures);
+ /* Store text iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_TEXT_QUARK,
+ (gpointer)tp_chan_set_text_signatures);
+ /* Store DTMF iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_DTMF_QUARK,
+ (gpointer)tp_chan_set_dtmf_signatures);
+ /* Store group iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_GROUP_QUARK,
+ (gpointer)tp_chan_set_group_signatures);
+ /* Store hold iface signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_HOLD_QUARK,
+ (gpointer)tp_chan_set_hold_signatures);
+ /* Store password iface signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CHAN_IFACE_PASSWORD_QUARK,
+ (gpointer)tp_chan_set_password_signatures);
+}
+
+static void tp_chan_init(GTypeInstance *instance, gpointer g_class)
+{
+ TpChan *self = TELEPATHY_CHAN(instance);
+ self->type = NULL;
+ self->first_run = TRUE;
+}
+
+
+static void tp_chan_dispose(GObject *obj)
+{
+ TpChan *self = TELEPATHY_CHAN(obj);
+
+ if (self->first_run)
+ {
+ self->first_run = FALSE;
+ synthesize_closed(self);
+ g_datalist_clear(&(self->interface_list));
+ }
+
+ /* Chain up to the parent class dispose */
+ if (G_OBJECT_CLASS(parent_class)->dispose)
+ {
+ G_OBJECT_CLASS(parent_class)->dispose(obj);
+ }
+
+}
+
+
+static void tp_chan_finalize(GObject *obj)
+{
+ TpChan *self = TELEPATHY_CHAN(obj);
+
+ if (self->type)
+ {
+ g_free(self->type);
+ }
+
+ if (G_OBJECT_CLASS(parent_class)->finalize)
+ {
+ G_OBJECT_CLASS(parent_class)->finalize(obj);
+ }
+}
+
+
+static void tp_chan_class_init(TpChanClass *klass)
+{
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent(klass);
+
+ obj->set_property = parent_class->set_property;
+ obj->get_property = parent_class->get_property;
+ obj->dispose = tp_chan_dispose;
+ obj->finalize = tp_chan_finalize;
+ _tp_chan_register_signal_marshallers();
+ _tp_chan_register_interface_signal_marshallers();
+ _tp_chan_init_interface_signal_signatures(&(klass->iface_signal_sigs));
+}
+
+
+GType tp_chan_get_type(void)
+{
+#ifndef EMULATOR
+ static GType type1 = 0;
+#endif
+
+ if (type1 == 0)
+ {
+ static const GTypeInfo info =
+ {
+ sizeof(TpChanClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)tp_chan_class_init,
+ NULL,
+ NULL,
+ sizeof(TpChan),
+ 0,
+ (GInstanceInitFunc)tp_chan_init
+ };
+ type1 = g_type_register_static(DBUS_TYPE_G_PROXY,
+ "TpChan", &info, 0);
+ }
+ return type1;
+}
+
+
+
+/* Public functions begin */
+
+GQuark tp_get_chan_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret1 = 0;
+#endif
+
+ if (ret1 == 0)
+ {
+ ret1 = g_quark_from_static_string(TP_IFACE_CHANNEL_INTERFACE);
+ }
+
+ return ret1;
+}
+
+GQuark tp_get_chan_contactlist_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret2 = 0;
+#endif
+
+ if (ret2 == 0)
+ {
+ ret2 = g_quark_from_static_string(TP_IFACE_CHANNEL_TYPE_CONTACT_LIST);
+ }
+
+ return ret2;
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark tp_get_chan_contactsearch_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret3 = 0;
+#endif
+
+ if (ret3 == 0)
+ {
+ ret3 = g_quark_from_static_string(TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
+ }
+
+ return ret3;
+}
+
+
+GQuark tp_get_chan_streamed_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret4 = 0;
+#endif
+
+ if (ret4 == 0)
+ {
+ ret4 = g_quark_from_static_string(TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
+ }
+
+ return ret4;
+}
+
+
+GQuark tp_get_chan_roomlist_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret5 = 0;
+#endif
+
+ if (ret5 == 0)
+ {
+ ret5 = g_quark_from_static_string(TP_IFACE_CHANNEL_TYPE_ROOM_LIST);
+ }
+
+ return ret5;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark tp_get_chan_text_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret6 = 0;
+#endif
+
+ if (ret6 == 0)
+ {
+ ret6 = g_quark_from_static_string(TP_IFACE_CHANNEL_TYPE_TEXT);
+ }
+
+ return ret6;
+}
+
+
+GQuark tp_get_chan_dtmf_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret7 = 0;
+#endif
+
+ if (ret7 == 0)
+ {
+ ret7 = g_quark_from_static_string(TP_IFACE_CHANNEL_INTERFACE_DTMF);
+ }
+
+ return ret7;
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark tp_get_chan_group_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret8 = 0;
+#endif
+
+ if (ret8 == 0)
+ {
+ ret8 = g_quark_from_static_string(TP_IFACE_CHANNEL_INTERFACE_GROUP);
+ }
+
+ return ret8;
+}
+
+
+GQuark tp_get_chan_hold_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret9 = 0;
+#endif
+
+ if (ret9 == 0)
+ {
+ ret9 = g_quark_from_static_string(TP_IFACE_CHANNEL_INTERFACE_HOLD);
+ }
+
+ return ret9;
+}
+
+
+GQuark tp_get_chan_password_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret10 = 0;
+#endif
+
+ if (ret10 == 0)
+ {
+ ret10 = g_quark_from_static_string(TP_IFACE_CHANNEL_INTERFACE_PASSWORD);
+ }
+
+ return ret10;
+}
+
+GQuark tp_get_chan_transfer_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret11 = 0;
+#endif
+
+ if (ret11 == 0)
+ {
+ ret11 = g_quark_from_static_string(TP_IFACE_CHANNEL_INTERFACE_TRANSFER);
+ }
+
+ return ret11;
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+TpChan *tp_chan_new(DBusGConnection *connection, const gchar *bus_name,
+ const gchar *object_path, const gchar *type,
+ guint handle_type, guint handle)
+{
+ GError *error = NULL;
+ gchar *unique_name;
+ gchar **interfaces;
+ TpChan *chan;
+ g_return_val_if_fail(connection != NULL, NULL);
+ g_return_val_if_fail(bus_name != NULL, NULL);
+ g_return_val_if_fail(object_path != NULL, NULL);
+ g_return_val_if_fail(type != NULL, NULL);
+
+ if (!dbus_g_proxy_call (tp_get_bus_proxy (),
+ "GetNameOwner", &error, G_TYPE_STRING, bus_name,
+ G_TYPE_INVALID, G_TYPE_STRING, &unique_name,
+ G_TYPE_INVALID))
+ {
+ g_warning("tp_chan_new: getting unique name failed: %s", error->message);
+ g_error_free(error);
+ return NULL;
+ }
+
+ /* Create the channel object */
+ chan = g_object_new(TELEPATHY_CHAN_TYPE,
+ "name", unique_name, "path", object_path,
+ "interface", TP_IFACE_CHANNEL_INTERFACE,
+ "connection", connection, NULL);
+
+ g_free(unique_name);
+
+ dbus_g_proxy_add_signal(DBUS_G_PROXY(chan), "Closed", G_TYPE_INVALID);
+
+ g_datalist_init(&(chan->interface_list));
+
+ /* Store interface information for the channel */
+ if (tp_chan_get_interfaces(DBUS_G_PROXY(chan), &interfaces, &error))
+ {
+ tp_chan_local_set_interfaces(chan, interfaces);
+
+ /* Free the strings used for interface object creation */
+ g_strfreev(interfaces);
+ }
+ else
+ {
+ g_warning("GetInterfaces for channel failed: %s\n", error->message);
+ g_error_free(error);
+ }
+
+ /* Store necessary information for this object */
+ chan->type = g_strdup(type);
+ chan->handle_type = handle_type;
+ chan->handle = handle;
+
+ return chan;
+}
+
+
+void tp_chan_local_set_interfaces(TpChan *self, gchar **interfaces)
+{
+ gchar **temp_ifaces;
+ gchar *chan_type = NULL;
+ GError *error = NULL;
+ GData **sig_list = &(TELEPATHY_CHAN_GET_CLASS(self)->iface_signal_sigs);
+ void (*signature_setter_func)(DBusGProxy *proxy);
+ DBusGConnection *connection;
+ /*const*/ gchar *name, *path;
+
+ if (interfaces == NULL)
+ {
+ return;
+ }
+
+ /* Create and store proxy objects corresponding to the
+ interfaces */
+
+ g_object_get (G_OBJECT(self),
+ "connection", &connection,
+ "name", &name,
+ "path", &path,
+ NULL);
+
+ g_debug ("%s: %p, %s, %s", G_STRFUNC, connection, name, path);
+
+ for (temp_ifaces = interfaces; *temp_ifaces; temp_ifaces++)
+ {
+ GQuark key = g_quark_from_string(*temp_ifaces);
+ DBusGProxy *if_proxy;
+
+ if (key == TELEPATHY_PROPS_IFACE_QUARK)
+ {
+ if_proxy = DBUS_G_PROXY (tp_props_iface_new (connection, name, path));
+ }
+ else
+ {
+ if_proxy = dbus_g_proxy_new_for_name (connection, name,
+ path, *temp_ifaces);
+
+ if (if_proxy != NULL)
+ {
+ /* Does the interface have signals? If yes, add their signatures
+ for the interface instance by calling the
+ corresponding setter function */
+
+ signature_setter_func =
+ g_datalist_id_get_data(sig_list, key);
+
+ if (signature_setter_func != NULL)
+ {
+ (*signature_setter_func)(if_proxy);
+ }
+ }
+ }
+ if (if_proxy != NULL)
+ {
+ g_datalist_id_set_data_full(&(self->interface_list), key,
+ if_proxy, g_object_unref);
+ }
+ }
+
+ /* Finally, add the channel type interface */
+
+ if (!tp_chan_get_channel_type(DBUS_G_PROXY(self), &chan_type, &error))
+ {
+ g_warning("GetChannelType failed: %s\n", error->message);
+ g_error_free(error);
+ }
+ else
+ {
+ DBusGProxy *chan_proxy =
+ dbus_g_proxy_new_from_proxy(DBUS_G_PROXY(self), chan_type, NULL);
+
+ g_datalist_id_set_data(&(self->interface_list),
+ g_quark_from_string(chan_type), chan_proxy);
+
+ /* If the particular channel type interface has signals defined,
+ call the corresponding setter function */
+
+ signature_setter_func =
+ g_datalist_id_get_data(sig_list, g_quark_from_string(chan_type));
+
+ if (signature_setter_func != NULL)
+ {
+ (*signature_setter_func)(chan_proxy);
+ }
+
+ g_free(chan_type);
+ }
+
+ g_free (name);
+ g_free (path);
+ dbus_g_connection_unref (connection);
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+DBusGProxy *tp_chan_get_interface(TpChan *self, GQuark iface_quark)
+{
+ DBusGProxy *iface_proxy = NULL;
+
+ iface_proxy = (DBusGProxy *)g_datalist_id_get_data(&(self->interface_list),
+ iface_quark);
+ return iface_proxy;
+}
+
+static void synthesize_closed(TpChan *chan)
+{
+ DBusMessage *msg = NULL;
+ GArray *closed_signal_types = g_array_new(FALSE, FALSE, sizeof(GType));
+
+ if (!closed_signal_types)
+ {
+ g_warning("%s: Could not allocate the type array for Closed signal",
+ G_STRFUNC);
+ return;
+ }
+
+ msg = dbus_message_new_signal(dbus_g_proxy_get_path(DBUS_G_PROXY(chan)),
+ TP_IFACE_CHANNEL_INTERFACE, "Closed");
+ if (!msg)
+ {
+ g_warning("%s: Could not create the synthetic Closed signal message.",
+ G_STRFUNC);
+ g_array_free(closed_signal_types, FALSE);
+ return;
+ }
+ g_signal_emit_by_name(DBUS_G_PROXY(chan),
+ TP_IFACE_CHAN_SIGNAL_CLOSED_SYNTHESIZED, msg,
+ closed_signal_types);
+ g_array_free(closed_signal_types, FALSE);
+ dbus_message_unref(msg);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-conn-ifaces-signal-setters.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,75 @@
+/* tp-conn-ifaces-signal-setters.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "tp-conn-ifaces-signal-setters.h"
+
+void tp_conn_set_aliasing_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "AliasesChanged",
+ dbus_g_type_get_struct ("GValueArray",
+ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID),
+ G_TYPE_INVALID);
+}
+
+void tp_conn_set_capabilities_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "CapabilitiesChanged",
+ dbus_g_type_get_struct ("GValueArray",
+ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_INVALID),
+ G_TYPE_INVALID);
+}
+
+void tp_conn_set_contactinfo_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "GotContactInfo",
+ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+}
+void tp_conn_set_forwarding_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "ForwardingChanged",
+ G_TYPE_UINT, G_TYPE_INVALID);
+}
+void tp_conn_set_presence_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "PresenceUpdate",
+ dbus_g_type_get_map ("GHashTable", G_TYPE_UINT,
+ (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT,
+ (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
+ (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
+ G_TYPE_VALUE)))), G_TYPE_INVALID))), G_TYPE_INVALID);
+}
+void tp_conn_set_privacy_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "PrivacyModeChanged",
+ G_TYPE_STRING, G_TYPE_INVALID);
+}
+void tp_conn_set_renaming_signatures(DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "Renamed",
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+}
+void tp_conn_set_avatar_signatures(DBusGProxy *proxy)
+{
+ //dbus_g_proxy_add_signal( proxy, "AvatarUpdated", )
+ dbus_g_proxy_add_signal(proxy, "AvatarUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "AvatarRetrieved", G_TYPE_UINT, G_TYPE_STRING, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_STRING,G_TYPE_INVALID);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-conn-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,148 @@
+/* tp-conn-signals-marshal.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:OBJECT,STRING,UINT,UINT,BOOLEAN (tp-conn-signals-marshal.list:1) */
+void
+tp_conn_signals_marshal_VOID__OBJECT_STRING_UINT_UINT_BOOLEAN (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__OBJECT_STRING_UINT_UINT_BOOLEAN) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ guint arg_3,
+ guint arg_4,
+ gboolean arg_5,
+ gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_STRING_UINT_UINT_BOOLEAN callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 6);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__OBJECT_STRING_UINT_UINT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_object (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_uint (param_values + 4),
+ g_marshal_value_peek_boolean (param_values + 5),
+ data2);
+}
+
+/* VOID:UINT,UINT (tp-conn-signals-marshal.list:2) */
+void
+tp_conn_signals_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
+/* VOID:BOXED (tp-conn-signals-marshal.list:3) */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-conn.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,734 @@
+/* tp-conn.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <string.h>
+#include "tp-conn.h"
+#include "tp-helpers.h"
+#include "tp-connmgr.h"
+#include "tp-props-iface.h"
+
+
+
+#ifdef EMULATOR
+#include "libtelepathy_wsd_solution.h"
+#endif
+
+#ifdef EMULATOR
+
+ GET_STATIC_VAR_FROM_TLS(parent_class,tp_conn,GObjectClass *)
+ #define parent_class (*GET_WSD_VAR_NAME(parent_class,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(type1,tp_conn,GType)
+ #define type1 (*GET_WSD_VAR_NAME(type1,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret1,tp_conn,GQuark)
+ #define ret1 (*GET_WSD_VAR_NAME(ret1,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret2,tp_conn,GQuark)
+ #define ret2 (*GET_WSD_VAR_NAME(ret2,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret3,tp_conn,GQuark)
+ #define ret3 (*GET_WSD_VAR_NAME(ret3,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret4,tp_conn,GQuark)
+ #define ret4 (*GET_WSD_VAR_NAME(ret4,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret5,tp_conn,GQuark)
+ #define ret5 (*GET_WSD_VAR_NAME(ret5,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret6,tp_conn,GQuark)
+ #define ret6 (*GET_WSD_VAR_NAME(ret6,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret7,tp_conn,GQuark)
+ #define ret7 (*GET_WSD_VAR_NAME(ret7,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret8,tp_conn,GQuark)
+ #define ret8 (*GET_WSD_VAR_NAME(ret8,tp_conn,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret9,tp_conn,GQuark)
+ #define ret9 (*GET_WSD_VAR_NAME(ret9,tp_conn,s)())
+
+#else
+ static GObjectClass *parent_class = NULL;
+#endif
+
+
+
+static gboolean tp_conn_status_change_handler(DBusGProxy *proxy,
+ guint status, guint reason,
+ gpointer user_data);
+
+static void _tp_conn_connect_req_handler(DBusGProxy *proxy,
+ GError *error, gpointer user_data);
+
+static void _tp_conn_register_signal_marshallers()
+{
+ /* Register marshaller for NewChannel signal */
+ dbus_g_object_register_marshaller(tp_conn_signals_marshal_VOID__OBJECT_STRING_UINT_UINT_BOOLEAN, G_TYPE_NONE, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+ /* Register marshaller for StatusChanged signal */
+ dbus_g_object_register_marshaller(tp_conn_signals_marshal_VOID__UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+static void _tp_conn_register_interface_signal_marshallers()
+{
+ /* Register marshaller for Aliasing interface signal AliasUpdate and
+ ContactInfo interface signal GotContactInfo*/
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+ /* Register marshaller for Forwarding interface signal ForwardingChanged */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INVALID);
+ /* Register marshaller for Presence interface signal PresenceUpdate */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__BOXED, G_TYPE_NONE, G_TYPE_BOXED, G_TYPE_INVALID);
+ /* Register marshaller for Privacy interface signal PrivacyModeChanged */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
+ /* Register marshaller for Renaming interface signal Renamed */
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+}
+
+
+/* We initialize the list of signatures here, so that we can use
+ * it to add them for new interface instances later.
+ */
+
+/* FIXME: This should be replaced by a more automatic way of doing
+ * this. The reason for using a set of function pointers is that there is no
+ * apparent cleaner way of doing this, unless DBusGProxy gains a non-varargs
+ * version of dbus_g_proxy_add_signal...
+ */
+
+static void _tp_conn_init_interface_signal_signatures(GData **signal_sigs)
+{
+ g_datalist_init(signal_sigs);
+
+ /* Create and store aliasing iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_ALIASING_QUARK,
+ (gpointer)&tp_conn_set_aliasing_signatures);
+ /* Create and store capabilities iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_CAPABILITIES_QUARK,
+ (gpointer)&tp_conn_set_capabilities_signatures);
+ /* Create and store contactinfo iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_CONTACTINFO_QUARK,
+ (gpointer)&tp_conn_set_contactinfo_signatures);
+ /* Create and store forwarding iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_FORWARDING_QUARK,
+ (gpointer)&tp_conn_set_forwarding_signatures);
+ /* Create and store presence iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_PRESENCE_QUARK,
+ (gpointer)&tp_conn_set_presence_signatures);
+ /* Create and store privacy iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_PRIVACY_QUARK,
+ (gpointer)&tp_conn_set_privacy_signatures);
+ /* Create and store renaming iface signal signatures */
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_RENAMING_QUARK,
+ (gpointer)&tp_conn_set_renaming_signatures);
+ g_datalist_id_set_data(signal_sigs, TELEPATHY_CONN_IFACE_AVATAR_QUARK,
+ (gpointer)&tp_conn_set_avatar_signatures);
+}
+
+static void synthesize_status_changed(TpConn *conn);
+
+static void tp_conn_init(GTypeInstance *instance, gpointer g_class)
+{
+ TpConn *self = TELEPATHY_CONN(instance);
+
+ self->first_run = TRUE;
+}
+
+
+static void tp_conn_dispose(GObject *obj)
+{
+ TpConn *self = TELEPATHY_CONN(obj);
+
+ if (self->first_run == TRUE)
+ {
+ self->first_run = FALSE;
+ synthesize_status_changed(self);
+ g_datalist_clear(&(self->interface_list));
+ }
+
+ /* Call parent class dispose method */
+ if (G_OBJECT_CLASS(parent_class)->dispose)
+ {
+ G_OBJECT_CLASS(parent_class)->dispose(obj);
+ }
+
+}
+
+
+static void tp_conn_finalize(GObject *obj)
+{
+ if (G_OBJECT_CLASS(parent_class)->finalize)
+ {
+ G_OBJECT_CLASS(parent_class)->finalize(obj);
+ }
+
+}
+
+
+static void tp_conn_class_init(TpConnClass *klass)
+{
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent(klass);
+
+ obj->set_property = parent_class->set_property;
+ obj->get_property = parent_class->get_property;
+
+ obj->dispose = tp_conn_dispose;
+ obj->finalize = tp_conn_finalize;
+ _tp_conn_register_signal_marshallers();
+ _tp_conn_register_interface_signal_marshallers();
+ _tp_conn_init_interface_signal_signatures(&(klass->iface_signal_sigs));
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GType tp_conn_get_type(void)
+{
+#ifndef EMULATOR
+ static GType type1 = 0;
+#endif
+
+ if (type1 == 0)
+ {
+ static const GTypeInfo info =
+ {
+ sizeof(TpConnClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)tp_conn_class_init,
+ NULL,
+ NULL,
+ sizeof(TpConn),
+ 0,
+ (GInstanceInitFunc)tp_conn_init
+
+ };
+ type1 = g_type_register_static(DBUS_TYPE_G_PROXY,
+ "TpConn", &info, 0);
+ }
+ return type1;
+}
+
+/* The interface name getters */
+
+GQuark tp_get_conn_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret1 = 0;
+#endif
+
+ if (ret1 == 0)
+ {
+ /* FIXME: The naming conventions should be unified */
+ ret1 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE);
+ }
+
+ return ret1;
+}
+
+GQuark tp_get_conn_aliasing_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret2 = 0;
+#endif
+
+ if (ret2 == 0)
+ {
+ ret2 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_ALIASING);
+ }
+
+ return ret2;
+}
+
+GQuark tp_get_conn_capabilities_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret3 = 0;
+#endif
+
+ if (ret3 == 0)
+ {
+ ret3 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_CAPABILITIES);
+ }
+
+ return ret3;
+}
+
+GQuark tp_get_conn_contactinfo_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret4 = 0;
+#endif
+
+ if (ret4 == 0)
+ {
+ ret4 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_CONTACT_INFO);
+ }
+
+ return ret4;
+}
+
+GQuark tp_get_conn_forwarding_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret5 = 0;
+#endif
+
+ if (ret5 == 0)
+ {
+ ret5 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_FORWARDING);
+ }
+
+ return ret5;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark tp_get_conn_presence_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret6 = 0;
+#endif
+
+ if (ret6 == 0)
+ {
+ ret6 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_PRESENCE);
+ }
+
+ return ret6;
+}
+
+
+GQuark tp_get_conn_privacy_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret7 = 0;
+#endif
+
+ if (ret7 == 0)
+ {
+ ret7 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_PRIVACY);
+ }
+
+ return ret7;
+}
+
+
+
+GQuark tp_get_conn_renaming_interface()
+{
+#ifndef EMULATOR
+ static GQuark ret8 = 0;
+#endif
+
+ if (ret8 == 0)
+ {
+ ret8 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_RENAMING);
+ }
+
+ return ret8;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark tp_get_conn_avatar_interface(void)
+ {
+#ifndef EMULATOR
+ static GQuark ret9 = 0;
+#endif
+
+ if (ret9 == 0)
+ {
+ ret9 = g_quark_from_static_string(TP_IFACE_CONN_INTERFACE_AVATAR);
+ }
+
+ return ret9;
+ }
+
+TpConn *
+tp_conn_new_without_connect (DBusGConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path,
+ guint *status,
+ GError **error)
+{
+ gchar *unique_name;
+ gchar **interfaces;
+ guint conn_status = TP_CONN_STATUS_DISCONNECTED;
+ TpConn *obj;
+ GError *err = NULL;
+
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (bus_name != NULL, NULL);
+ g_return_val_if_fail (object_path, NULL);
+
+ /* Create the proxy object for this connection. It will be used to
+ perform the actual method calls over D-BUS. */
+
+ if (!dbus_g_proxy_call (tp_get_bus_proxy (), "GetNameOwner", error,
+ G_TYPE_STRING, bus_name, G_TYPE_INVALID,
+ G_TYPE_STRING, &unique_name, G_TYPE_INVALID))
+ {
+ return NULL;
+ }
+
+ obj = g_object_new (TELEPATHY_CONN_TYPE,
+ "name", unique_name,
+ "path", object_path,
+ "interface", TP_IFACE_CONN_INTERFACE,//TP_IFACE_CONNECTION,
+ "connection", connection,
+ NULL);
+ g_free (unique_name);
+
+ g_datalist_init (&(obj->interface_list));
+
+ //ADD_SIGNALS_FOR_CONNECTION (DBUS_G_PROXY (obj)); //commenting this bcoz header file not found
+ //equivalent of above stmt
+ dbus_g_proxy_add_signal (DBUS_G_PROXY (obj), "NewChannel",\
+ DBUS_TYPE_G_OBJECT_PATH,\
+ G_TYPE_STRING,\
+ G_TYPE_UINT,\
+ G_TYPE_UINT,\
+ G_TYPE_BOOLEAN,\
+ G_TYPE_INVALID);\
+ dbus_g_proxy_add_signal (DBUS_G_PROXY (obj), "StatusChanged",\
+ G_TYPE_UINT,\
+ G_TYPE_UINT,\
+ G_TYPE_INVALID);
+
+ /* Check if the connection is already connected. If so, we can
+ * already perform GetInterfaces(). */
+
+ if (!tp_conn_get_status (DBUS_G_PROXY (obj), &conn_status, &err))
+ {
+ if (err != NULL)
+ g_propagate_error (error, err);
+
+ g_object_unref (obj);
+ return NULL;
+ }
+
+ if (conn_status == TP_CONN_STATUS_CONNECTED)
+ {
+ if (!tp_conn_get_interfaces (DBUS_G_PROXY (obj), &interfaces, &err))
+ {
+ if (err != NULL)
+ g_propagate_error (error, err);
+
+ g_object_unref (obj);
+ return NULL;
+ }
+
+ /* Initialize the interface objects for this TpConn object */
+ tp_conn_local_set_interfaces (obj, interfaces);
+
+ g_strfreev (interfaces);
+ }
+ else
+ {
+ /* Not connected yet, so this is really a new connection. Thus, we
+ have to hook up to StatusChanged signal to perform the
+ GetInterfaces when it goes Connected */
+
+ dbus_g_proxy_connect_signal (DBUS_G_PROXY (obj), "StatusChanged",
+ G_CALLBACK (tp_conn_status_change_handler), NULL, NULL);
+ }
+
+ if (status != NULL)
+ *status = conn_status;
+ return obj;
+}
+
+
+TpConn *
+tp_conn_new (DBusGConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path)
+{
+ GError *error = NULL;
+ guint status;
+ TpConn *obj;
+
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (bus_name != NULL, NULL);
+ g_return_val_if_fail (object_path, NULL);
+
+ obj = tp_conn_new_without_connect (connection, bus_name, object_path,
+ &status, &error);
+
+ if (obj == NULL)
+ {
+ /* either GetNameOwner, GetStatus or GetInterfaces failed */
+ if (error != NULL)
+ {
+ g_warning ("Failed to create connection for %s %s: %s", bus_name,
+ object_path, error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ g_warning ("Failed to create connection for %s %s: error is NULL",
+ bus_name, object_path);
+ }
+
+ return NULL;
+ }
+
+ if (status != TP_CONN_STATUS_CONNECTED)
+ {
+ tp_conn_connect_async (DBUS_G_PROXY (obj), _tp_conn_connect_req_handler,
+ NULL);
+ }
+
+ return obj;
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+TpChan *tp_conn_new_channel(DBusGConnection *connection,
+ TpConn *tp_conn, const gchar *bus_name,
+ gchar *type, guint handle_type,
+ guint handle, gboolean supress_handler)
+{
+ GError *error = NULL;
+ gchar *chan_object_path = NULL;
+ TpChan *new_chan = NULL;
+
+ g_return_val_if_fail(connection, NULL);
+ g_return_val_if_fail(TELEPATHY_IS_CONN(tp_conn), NULL);
+ g_return_val_if_fail(bus_name, NULL);
+ g_return_val_if_fail(type, NULL);
+
+ /* Request a new channel to be created by using the proxy object.
+ We also retrieve the object path for it here. */
+
+ if (!tp_conn_request_channel(DBUS_G_PROXY(tp_conn),
+ type, handle_type, handle, supress_handler,
+ &chan_object_path, &error))
+ {
+ g_warning("RequestChannel() failed: %s\n", error -> message);
+
+ g_error_free(error);
+ return NULL;
+ }
+
+
+ /* Create the object to represent the channel */
+
+ new_chan = tp_chan_new(connection, bus_name, chan_object_path, type,
+ handle_type, handle);
+
+
+ g_free(chan_object_path);
+
+
+
+ return new_chan;
+}
+
+
+void tp_conn_local_set_interfaces(TpConn *self, gchar **interfaces)
+{
+ gchar **temp_ifaces = NULL;
+ const gchar *bus_name = dbus_g_proxy_get_bus_name(DBUS_G_PROXY(self));
+ const gchar *object_path = dbus_g_proxy_get_path(DBUS_G_PROXY(self));
+
+ DBusGConnection *connection = tp_get_bus ();
+
+ if (interfaces == NULL || connection == NULL)
+ {
+ return;
+ }
+
+ /* Create and store the proxy objects for the connection interfaces. */
+ for (temp_ifaces = interfaces; *temp_ifaces; temp_ifaces++)
+ {
+ DBusGProxy *if_proxy;
+ GQuark key = g_quark_from_string(*temp_ifaces);
+
+ if (key == TELEPATHY_PROPS_IFACE_QUARK)
+ {
+ if_proxy = DBUS_G_PROXY (tp_props_iface_new (connection,
+ bus_name, object_path));
+ }
+ else
+ {
+ if_proxy = dbus_g_proxy_new_for_name(connection, bus_name, object_path,
+ *temp_ifaces);
+ if (if_proxy != NULL)
+ {
+ GData *sig_list = TELEPATHY_CONN_GET_CLASS(self)->iface_signal_sigs;
+ void (*signature_setter_func)();
+
+ /* Does the interface have signals? If yes, add their signatures
+ for the interface instance */
+ signature_setter_func =
+ g_datalist_id_get_data(&sig_list, key);
+
+ if (signature_setter_func != NULL)
+ {
+ signature_setter_func(if_proxy);
+ }
+ }
+ }
+
+ if (if_proxy != NULL)
+ {
+ g_datalist_id_set_data_full(&(self->interface_list),
+ key, if_proxy, g_object_unref);
+ }
+
+ }
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+DBusGProxy *
+tp_conn_get_interface (TpConn *self,
+ GQuark iface_quark)
+{
+ DBusGProxy *iface_proxy = NULL;
+
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (iface_quark != 0, NULL);
+
+ iface_proxy = (DBusGProxy *) g_datalist_id_get_data (
+ &(self->interface_list), iface_quark);
+
+ return iface_proxy;
+}
+
+void
+_tp_conn_connect_req_handler (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
+{
+ /* The interfaces for the TpConn are set on the StatusChanged
+ handler when we get connected. Just print errors (if any)
+ here. */
+
+ if (error)
+ {
+ g_warning ("Could not perform Connect() for the connection, because: %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+}
+
+static gboolean
+tp_conn_status_change_handler (DBusGProxy *proxy,
+ guint status,
+ guint reason,
+ gpointer user_data)
+{
+ gchar **interfaces = NULL;
+ GError *error = NULL;
+ TpConn *tp_conn = (TpConn *) proxy;
+
+ /* If the connection is up, we can get the list of interfaces */
+ /* FIXME: At some point, we should switch to doing this asynchronously */
+
+ if (status == TP_CONN_STATUS_CONNECTED)
+ {
+ if (!tp_conn_get_interfaces (DBUS_G_PROXY (proxy), &interfaces, &error))
+ {
+ g_warning ("GetInterfaces failed: %s\n", error->message);
+ g_error_free (error);
+ return TRUE;
+ }
+
+ /* Initialize the interface objects for this TpConn object */
+
+ tp_conn_local_set_interfaces (tp_conn, interfaces);
+
+ g_strfreev (interfaces);
+
+ dbus_g_proxy_disconnect_signal (proxy, "StatusChanged",
+ G_CALLBACK (tp_conn_status_change_handler), NULL);
+ }
+
+ return TRUE;
+}
+
+
+static void synthesize_status_changed(TpConn *conn)
+{
+
+ DBusMessageIter iter;
+ DBusMessage *msg = NULL;
+ guint value;
+ GType uint_type = G_TYPE_UINT;
+ GArray *statuschanged_signal_types = g_array_new(FALSE, FALSE,
+ sizeof(GType));
+
+
+ if (!statuschanged_signal_types)
+ {
+ g_warning("%s: Could not allocate type array for StatusChanged",
+ G_STRFUNC);
+ return;
+ }
+
+ msg = dbus_message_new_signal(dbus_g_proxy_get_path(DBUS_G_PROXY(conn)),
+ TP_IFACE_CONN_INTERFACE, "StatusChanged");
+
+ if (!msg)
+ {
+ g_warning("%s: Could not allocate message for StatusChanged signal",
+ G_STRFUNC);
+ g_array_free(statuschanged_signal_types, FALSE);
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ value = TP_CONN_STATUS_DISCONNECTED;
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &value);
+ value = TP_CONN_STATUS_REASON_NONE_SPECIFIED;
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &value);
+
+ /* TODO: It might be worth considering to setup/remove the array in
+ base_init/base_deinit to make it persist for the whole class */
+
+ if (statuschanged_signal_types)
+ {
+ g_array_insert_val(statuschanged_signal_types, 0, uint_type);
+ g_array_insert_val(statuschanged_signal_types, 1, uint_type);
+ }
+ else
+ {
+ g_warning("%s: Could not allocate array for StatusChanged types",
+ G_STRFUNC);
+ dbus_message_unref(msg);
+ return;
+ }
+
+ g_signal_emit_by_name(DBUS_G_PROXY(conn),
+ TP_IFACE_CONN_SIGNAL_STATUSCHANGED_SYNTHESIZED, msg,
+ statuschanged_signal_types);
+ g_array_free(statuschanged_signal_types, TRUE);
+ dbus_message_unref(msg);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-connmgr-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:STRING,OBJECT,STRING (tp-connmgr-signals-marshal.list:1) */
+void
+tp_connmgr_signals_marshal_VOID__STRING_OBJECT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_OBJECT_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_OBJECT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_OBJECT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_object (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-connmgr.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,217 @@
+/* tp-connmgr.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "tp-connmgr.h"
+#include "tp-connmgr-signals-marshal.h"
+#include "tp-conn.h"
+#include "tp-helpers.h"
+
+#ifdef EMULATOR
+#include "libtelepathy_wsd_solution.h"
+#endif
+
+#ifdef EMULATOR
+
+ GET_STATIC_VAR_FROM_TLS(parent_class,tp_connmgr,GObjectClass *)
+ #define parent_class (*GET_WSD_VAR_NAME(parent_class,tp_connmgr,s)())
+
+ GET_STATIC_VAR_FROM_TLS(type1,tp_connmgr,GType)
+ #define type1 (*GET_WSD_VAR_NAME(type1,tp_connmgr,s)())
+#else
+ static GObjectClass *parent_class = NULL;
+#endif
+
+
+static void _tp_connmgr_register_signal_marshallers()
+{
+ /* Register marshaller for the NewConnection signal */
+ dbus_g_object_register_marshaller(tp_connmgr_signals_marshal_VOID__STRING_OBJECT_STRING, G_TYPE_NONE, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_INVALID);
+}
+
+static void tp_connmgr_dispose(GObject *obj)
+{
+ TpConnMgr *self = TELEPATHY_CONNMGR(obj);
+
+ if (self->first_run)
+ {
+ self->first_run = FALSE;
+ }
+
+ /* Call the parent dispose method */
+ if (G_OBJECT_CLASS(parent_class)->dispose)
+ {
+ G_OBJECT_CLASS(parent_class)->dispose(obj);
+ }
+
+}
+
+
+static void tp_connmgr_finalize(GObject *obj)
+{
+ if(G_OBJECT_CLASS(parent_class)->finalize)
+ {
+ G_OBJECT_CLASS(parent_class)->finalize(obj);
+ }
+}
+
+
+static void tp_connmgr_init(GTypeInstance *instance, gpointer g_class)
+{
+ TpConnMgr *self = TELEPATHY_CONNMGR(instance);
+
+ self->first_run = TRUE;
+}
+
+
+static void tp_connmgr_class_init(TpConnMgrClass *klass)
+{
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent(klass);
+
+ obj->set_property = parent_class->set_property;
+ obj->get_property = parent_class->get_property;
+
+ obj->dispose = tp_connmgr_dispose;
+ obj->finalize = tp_connmgr_finalize;
+
+ _tp_connmgr_register_signal_marshallers();
+}
+
+
+GType tp_connmgr_get_type(void)
+{
+#ifndef EMULATOR
+ static GType type1 = 0;
+#endif
+
+ if (type1 == 0)
+ {
+ static const GTypeInfo info =
+ {
+ sizeof(TpConnMgrClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)tp_connmgr_class_init,
+ NULL,
+ NULL,
+ sizeof(TpConnMgr),
+ 0,
+ (GInstanceInitFunc)tp_connmgr_init
+
+ };
+ type1 = g_type_register_static(DBUS_TYPE_G_PROXY,
+ "TpConnMgr", &info, 0);
+ }
+ return type1;
+}
+
+
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+TpConnMgr *tp_connmgr_new(DBusGConnection *connection,
+ const char *bus_name,
+ const char *object_path,
+ const char *interface_name)
+{
+ TpConnMgr *obj;
+ g_return_val_if_fail(connection != NULL, NULL);
+ g_return_val_if_fail(bus_name != NULL, NULL);
+ g_return_val_if_fail(object_path, NULL);
+ g_return_val_if_fail(interface_name, NULL);
+
+ obj = g_object_new(TELEPATHY_CONNMGR_TYPE,
+ "name", bus_name,
+ "path", object_path,
+ "interface", interface_name,
+ "connection", connection, NULL);
+
+ dbus_g_proxy_add_signal(DBUS_G_PROXY(obj),
+ "NewConnection",
+ G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH,
+ G_TYPE_STRING, G_TYPE_INVALID);
+
+ return obj;
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+TpConn *tp_connmgr_new_connection(TpConnMgr *self,
+ GHashTable *connection_parameters,
+ gchar *protocol)
+{
+ GError *error = NULL;
+ TpConn *tp_conn_obj = NULL;
+ DBusGConnection *connection = tp_get_bus ();
+ gchar *bus_name = NULL, *object_path = NULL;
+ g_return_val_if_fail(TELEPATHY_IS_CONNMGR(self), NULL);
+ g_return_val_if_fail(connection_parameters != NULL, NULL);
+
+ /* Create the actual connection and acquire service and path
+ information that the TpConn object will need */
+
+ if (!tp_connmgr_request_connection(DBUS_G_PROXY(self), protocol,
+ connection_parameters, &bus_name,
+ &object_path, &error))
+ {
+ g_warning("Connect() failed: %s\n", error -> message);
+ g_error_free(error);
+ return NULL;
+ }
+
+ if (bus_name == NULL || object_path == NULL)
+ {
+ return NULL;
+ }
+
+ /* Create the TpConn object */
+
+ tp_conn_obj = tp_conn_new(connection, bus_name, object_path);
+
+ return tp_conn_obj;
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+gboolean tp_connmgr_list_protocols(TpConnMgr *self, char *** proto)
+{
+ GError *error = NULL;
+
+ return dbus_g_proxy_call (DBUS_G_PROXY(self), "ListProtocols", &error, G_TYPE_INVALID, G_TYPE_STRV, proto, G_TYPE_INVALID);
+}
+
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+gboolean
+tp_connmgr_get_parameters (TpConnMgr *self, const char * IN_proto, GPtrArray** OUT_arg1)
+
+{
+ return dbus_g_proxy_call (DBUS_G_PROXY(self), "GetParameters", NULL, G_TYPE_STRING, IN_proto, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID)), OUT_arg1, G_TYPE_INVALID);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-helpers.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,292 @@
+/*
+ * tp-helpers.c - Source for various helper functions
+ * for telepathy implementation
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdlib.h>
+#include "tp-helpers.h"
+
+
+#define CM_CONFS_DIR "/usr/share/telepathy/managers/"
+#define CM_CONF_SUFFIX ".manager"
+#define CM_CONF_GROUP "ConnectionManager"
+#define FILE_SEPARATOR ','
+#define PROTO "Proto "
+
+
+#ifdef EMULATOR
+#include "libtelepathy_wsd_solution.h"
+#endif
+
+#ifdef EMULATOR
+
+ GET_STATIC_VAR_FROM_TLS(bus_proxy,tp_helpers,DBusGProxy *)
+ #define bus_proxy (*GET_WSD_VAR_NAME(bus_proxy,tp_helpers,s)())
+
+ GET_STATIC_VAR_FROM_TLS(bus1,tp_helpers,DBusGConnection *)
+ #define bus1 (*GET_WSD_VAR_NAME(bus1,tp_helpers,s)())
+
+#endif
+
+static void _list_builder(gpointer key, gpointer value, gpointer data);
+
+DBusGConnection *
+tp_get_bus ()
+{
+#ifndef EMULATOR
+ static DBusGConnection *bus1 = NULL;
+#endif
+
+
+ if (bus1 == NULL)
+ {
+ GError *error = NULL;
+
+ bus1 = dbus_g_bus_get (/*DBUS_BUS_STARTER*/DBUS_BUS_SESSION, &error);
+
+ if (bus1 == NULL)
+ g_error ("Failed to connect to starter bus: %s", error->message);
+ }
+
+ return bus1;
+}
+
+DBusGProxy *
+tp_get_bus_proxy ()
+{
+#ifndef EMULATOR
+ static DBusGProxy *bus_proxy = NULL;
+#endif
+
+ if (bus_proxy == NULL)
+ {
+ DBusGConnection *bus = tp_get_bus ();
+
+ bus_proxy = dbus_g_proxy_new_for_name (bus,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ if (bus_proxy == NULL)
+ g_error ("Failed to get proxy object for bus.");
+ }
+
+ return bus_proxy;
+}
+
+GSList *
+tp_hash_to_key_value_list(GHashTable *hash)
+{
+ GSList *ret = NULL;
+ g_hash_table_foreach(hash, _list_builder, &ret);
+ return ret;
+}
+
+void
+tp_key_value_list_free(GSList *list)
+{
+ GSList *iter;
+
+ for (iter = list; iter; iter = g_slist_next(iter))
+ {
+ g_free(iter->data);
+ }
+ g_slist_free(list);
+}
+
+static void _list_builder(gpointer key, gpointer value, gpointer data)
+{
+ GSList **list = (GSList **)data;
+ TpKeyValue *kv = g_new0(TpKeyValue, 1);
+ kv->key = key;
+ kv->value = value;
+ *list = g_slist_prepend(*list, kv);
+}
+
+GSList *tp_connmgr_list_cms(void)
+{
+ GError *error = NULL;
+ GDir *dir;
+ const gchar *filename;
+ gchar **name;
+ gchar *absolute_filepath;
+ GSList *cms = NULL;
+
+
+ /* Read the configuration file directory */
+ if ((dir = g_dir_open(CM_CONFS_DIR, 0, &error)) == NULL)
+ {
+ g_printerr("Error opening directory %s: %s", CM_CONFS_DIR,
+ error->message);
+ return NULL;
+ }
+
+ while ((filename = g_dir_read_name(dir)) != NULL)
+ /* Skip the file if it doesn't contain the required file suffix */
+ if (g_str_has_suffix(filename, CM_CONF_SUFFIX))
+ {
+ absolute_filepath = g_strconcat(CM_CONFS_DIR, filename, NULL);
+ name = g_strsplit(filename, ".", 0);
+ cms = g_slist_append(cms, *name);
+ }
+
+ return cms;
+}
+
+TpConnMgrInfo *tp_connmgr_get_info(gchar *cm)
+{
+ GError *error = NULL;
+ GKeyFile *file;
+ gsize len;
+ gchar *absolute_filepath;
+ gchar **protocols;
+ TpConnMgrInfo *cm_info = (TpConnMgrInfo *)malloc(sizeof(TpConnMgrInfo));
+ cm_info->protocol_info = g_hash_table_new(g_str_hash, g_str_equal);
+
+ absolute_filepath = g_strconcat(CM_CONFS_DIR, cm, CM_CONF_SUFFIX, NULL);
+
+ file = g_key_file_new();
+ if (!g_key_file_load_from_file
+ (file, absolute_filepath, G_KEY_FILE_NONE, &error))
+ {
+ /* handle error */
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ return NULL;
+ }
+ g_key_file_set_list_separator(file, FILE_SEPARATOR);
+
+ cm_info->name = g_key_file_get_string(file, CM_CONF_GROUP,
+ "Name", &error);
+ if (!(cm_info->name))
+ {
+ /* handle error and free dynamic memory */
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ g_key_file_free(file);
+ g_free(absolute_filepath);
+ free(cm_info);
+ return NULL;
+ }
+ cm_info->bus_name = g_key_file_get_string(file, CM_CONF_GROUP,
+ "BusName", &error);
+ if (!(cm_info->bus_name))
+ {
+ /* handle error and free dynamic memory */
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ g_key_file_free(file);
+ g_free(absolute_filepath);
+ g_free(cm_info->name);
+ free(cm_info);
+ return NULL;
+ }
+ cm_info->object_path = g_key_file_get_string(file,CM_CONF_GROUP,
+ "ObjectPath", &error);
+ if (!(cm_info->object_path))
+ {
+ /* handle error and free dynamic memory */
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ g_key_file_free(file);
+ g_free(absolute_filepath);
+ g_free(cm_info->name);
+ g_free(cm_info->bus_name);
+ free(cm_info);
+ return NULL;
+ }
+ cm_info->protocols = g_key_file_get_string_list(file, CM_CONF_GROUP,
+ "Protos", &len, &error);
+ if (!(cm_info->protocols))
+ {
+ /* handle error and free dynamic memory */
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ g_key_file_free(file);
+ g_free(absolute_filepath);
+ g_free(cm_info->name);
+ g_free(cm_info->bus_name);
+ g_free(cm_info->object_path);
+ free(cm_info);
+ return NULL;
+ }
+
+ for(protocols=cm_info->protocols; *protocols; protocols++)
+ {
+ gchar **keys;
+ gchar *key_value;
+ gchar *proto_group = g_strconcat(PROTO, *protocols, NULL);
+ TpConnMgrProtInfo *cm_prot_info =
+ (TpConnMgrProtInfo *)malloc(sizeof(TpConnMgrProtInfo));
+ cm_prot_info->default_params = g_hash_table_new(g_str_hash, g_str_equal);
+
+ cm_prot_info->mandatory_params = g_key_file_get_string_list(file,
+ proto_group, "MandatoryParams", &len, &error);
+ if (!(cm_prot_info->mandatory_params))
+ {
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ }
+ cm_prot_info->optional_params = g_key_file_get_string_list(file,
+ proto_group, "OptionalParams", &len, &error);
+ if (!(cm_prot_info->optional_params))
+ {
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ }
+
+ keys = g_key_file_get_keys (file, proto_group, &len, &error);
+ if (!(keys))
+ {
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ }
+ else
+ {
+ for(; *keys; keys++)
+ {
+ if(g_str_has_prefix(*keys, "default"))
+ {
+ key_value = g_key_file_get_string(file, proto_group,
+ *keys, &error);
+ if (!(key_value))
+ {
+ g_printerr("%s", error->message);
+ g_error_free(error);
+ }
+ else
+ g_hash_table_insert(cm_prot_info->default_params,
+ g_strdup(*keys), key_value);
+ }
+ }
+ }
+
+
+ g_hash_table_insert(cm_info->protocol_info, g_strdup(*protocols),
+ cm_prot_info);
+
+ }
+
+ g_key_file_free(file);
+ g_free(absolute_filepath);
+ return cm_info;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-ifaces-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,591 @@
+/*
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:UINT,STRING (tp-ifaces-signals-marshal.list:3) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_STRING) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+}
+
+/* VOID:UINT,BOXED,BOXED (tp-ifaces-signals-marshal.list:5) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_BOXED_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_BOXED_BOXED) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_BOXED_BOXED callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_BOXED_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_boxed (param_values + 3),
+ data2);
+}
+
+/* VOID:STRING (tp-ifaces-signals-marshal.list:7) */
+
+/* VOID:INT,BOXED (tp-ifaces-signals-marshal.list:11) */
+void
+tp_ifaces_signals_marshal_VOID__INT_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
+ gint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__INT_BOXED callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__INT_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_int (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ data2);
+}
+
+
+/* VOID:STRING,BOXED (tp-ifaces-signals-marshal.list:11) */
+//Added for search
+void
+tp_ifaces_signals_marshal_VOID__UINT_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_BOXED) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_BOXED callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ data2);
+}
+
+/* VOID:UINT (tp-ifaces-signals-marshal.list:13) */
+
+/* VOID:UINT,STRING,STRING (tp-ifaces-signals-marshal.list:15) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_STRING_STRING) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_STRING_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
+/* VOID:UINT,UINT,UINT (tp-ifaces-signals-marshal.list:17) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ data2);
+}
+
+/* VOID:BOOLEAN (tp-ifaces-signals-marshal.list:19) */
+
+/* VOID:UINT,UINT,UINT,UINT,UINT,STRING (tp-ifaces-signals-marshal.list:21) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT_UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ guint arg_4,
+ guint arg_5,
+ gpointer arg_6,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT_UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 7);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT_UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_uint (param_values + 4),
+ g_marshal_value_peek_uint (param_values + 5),
+ g_marshal_value_peek_string (param_values + 6),
+ data2);
+}
+
+/* VOID:UINT,UINT,STRING (tp-ifaces-signals-marshal.list:23) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
+/* VOID:UINT,UINT (tp-ifaces-signals-marshal.list:27) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
+/* VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT (tp-ifaces-signals-marshal.list:29) */
+void
+tp_ifaces_signals_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer arg_5,
+ guint arg_6,
+ guint arg_7,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 8);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_boxed (param_values + 3),
+ g_marshal_value_peek_boxed (param_values + 4),
+ g_marshal_value_peek_boxed (param_values + 5),
+ g_marshal_value_peek_uint (param_values + 6),
+ g_marshal_value_peek_uint (param_values + 7),
+ data2);
+}
+
+/* VOID:BOXED (tp-ifaces-signals-marshal.list:33) */
+
+/* VOID:UINT,UINT,UINT,STRING (tp-ifaces-signals-marshal.list:35) */
+void
+tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_string (param_values + 4),
+ data2);
+}
+
+/* VOID:OBJECT,STRING (tp-ifaces-signals-marshal.list:37) */
+void
+tp_ifaces_signals_marshal_VOID__OBJECT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__OBJECT_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__OBJECT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_object (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+}
+
+void
+tp_ifaces_signals_marshal_VOID__UINT_STRING_BOXED_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_STRING_BOXED_STRING) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_STRING_BOXED_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_STRING_BOXED_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_boxed (param_values + 3),
+ g_marshal_value_peek_string (param_values + 4),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/src/tp-props-iface.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,653 @@
+/* tp-props-iface.c
+ *
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <dbus/dbus-glib.h>
+#include <string.h>
+#include "tp-interfaces.h"
+#include "tp-ifaces-signals-marshal.h"
+#include "tp-props-iface-gen.h"
+#include "tp-props-iface.h"
+
+#ifdef EMULATOR
+#include "libtelepathy_wsd_solution.h"
+#endif
+
+
+#define TP_TYPE_PROPERTY_DESCRIPTION (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_STRING, \
+ G_TYPE_UINT, \
+ G_TYPE_INVALID))
+
+#define TP_TYPE_PROPERTY_CHANGE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_VALUE, \
+ G_TYPE_INVALID))
+
+#define TP_TYPE_PROPERTY_FLAGS_CHANGE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_INVALID))
+
+
+
+
+/*signal enum*/
+enum
+{
+ PROPERTIES_READY,
+ PROPERTY_CHANGED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_TP_PROPS_IFACE
+#endif
+
+};
+
+#ifndef EMULATOR
+ static guint signals[LAST_SIGNAL] = {0};
+#endif
+
+/* looking up properties is linear time on the grounds that number of properties
+ * will always be small, so this will be more cache-friendly
+ */
+typedef struct _PropertyMapping PropertyMapping;
+struct _PropertyMapping
+{
+ guint user_id;
+ guint32 server_id;
+ gchar *name;
+ GValue *value;
+ guint32 flags;
+};
+
+typedef struct _TpPropsPrivate TpPropsPrivate;
+
+struct _TpPropsPrivate
+{
+ gboolean properties_ready;
+
+ int mappings_len;
+ PropertyMapping *mappings;
+};
+
+#ifndef EMULATOR
+ static GObjectClass *parent_class = NULL;
+#endif
+
+
+#ifdef EMULATOR
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,tp_props_iface,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,tp_props_iface, s)())
+
+ GET_STATIC_VAR_FROM_TLS(parent_class,tp_props_iface,GObjectClass *)
+ #define parent_class (*GET_WSD_VAR_NAME(parent_class,tp_props_iface,s)())
+
+ GET_STATIC_VAR_FROM_TLS(type1,tp_props_iface,GType)
+ #define type1 (*GET_WSD_VAR_NAME(type1,tp_props_iface,s)())
+
+ GET_STATIC_VAR_FROM_TLS(ret,tp_props_iface,GQuark)
+ #define ret (*GET_WSD_VAR_NAME(ret,tp_props_iface,s)())
+
+#endif
+
+
+#define PRIV(o) ((TpPropsPrivate*)(o->priv))
+
+static void properties_listed_cb (DBusGProxy *proxy, GPtrArray *properties, GError *error, gpointer user_data);
+
+static void tp_props_iface_init(GTypeInstance *instance, gpointer g_class)
+{
+ TpPropsIface *self = TELEPATHY_PROPS_IFACE(instance);
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
+ TELEPATHY_PROPS_IFACE_TYPE, TpPropsPrivate);
+
+}
+
+static GObject *
+tp_props_iface_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+
+ obj = G_OBJECT_CLASS (parent_class)->
+ constructor (type, n_props, props);
+
+ dbus_g_proxy_add_signal(DBUS_G_PROXY(obj), "PropertiesChanged",
+ dbus_g_type_get_collection ("GPtrArray", TP_TYPE_PROPERTY_CHANGE),
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(DBUS_G_PROXY(obj), "PropertyFlagsChanged",
+ dbus_g_type_get_collection ("GPtrArray", TP_TYPE_PROPERTY_FLAGS_CHANGE),
+ G_TYPE_INVALID);
+
+ return obj;
+}
+
+static void tp_props_iface_dispose(GObject *obj)
+{
+
+ /* Call parent class dispose method */
+ if (G_OBJECT_CLASS(parent_class)->dispose)
+ {
+ G_OBJECT_CLASS(parent_class)->dispose(obj);
+ }
+
+}
+
+
+static void tp_props_iface_finalize(GObject *obj)
+{
+ TpPropsIface *self = TELEPATHY_PROPS_IFACE(obj);
+ int i;
+ for (i=0; i < PRIV(self)->mappings_len; i++)
+ {
+ if (PRIV(self)->mappings[i].value)
+ {
+ g_value_unset (PRIV(self)->mappings[i].value);
+ g_free (PRIV(self)->mappings[i].value);
+ }
+ if (PRIV(self)->mappings[i].name)
+ g_free (PRIV(self)->mappings[i].name);
+ }
+
+ g_free (PRIV(self)->mappings);
+
+ if (G_OBJECT_CLASS(parent_class)->finalize)
+ {
+ G_OBJECT_CLASS(parent_class)->finalize(obj);
+ }
+}
+
+
+static void tp_props_iface_class_init(TpPropsIfaceClass *klass)
+{
+ GObjectClass *obj = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent(klass);
+
+ obj->set_property = parent_class->set_property;
+ obj->get_property = parent_class->get_property;
+
+ obj->constructor = tp_props_iface_constructor;
+ obj->dispose = tp_props_iface_dispose;
+ obj->finalize = tp_props_iface_finalize;
+
+ g_type_class_add_private (klass, sizeof (TpPropsPrivate));
+ /**
+ * TpPropsIface::properties-ready:
+ * @self: #TpPropsIface that emmitted the signal
+ * @property_id: property that changed
+ * @change_flags: #TpPropsChanged for what changed on the property
+ *
+ * This signal is emitted when the properties 1st become avaible for
+ * reading or writing.
+ */
+
+ signals[PROPERTIES_READY] =
+ g_signal_new ("properties-ready",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+
+
+ /**
+ * TpPropsIface::properties-changed:
+ * @self: #TpPropsIface that emmitted the signal
+ * @property_id: property that changed
+ * @change_flags: #TpPropsChanged for what changed on the property
+ *
+ * This signal is emitted when a property changes.
+ */
+
+ signals[PROPERTY_CHANGED] =
+ g_signal_new ("properties-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ tp_ifaces_signals_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+
+ /* register marshaller for PropertiesChanged and PropertyFlagsChanged*/
+ dbus_g_object_register_marshaller(tp_ifaces_signals_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GType tp_props_iface_get_type(void)
+{
+#ifndef EMULATOR
+ static GType type1 = 0;
+#endif
+
+ if (type1 == 0)
+ {
+ static const GTypeInfo info =
+ {
+ sizeof(TpPropsIfaceClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)tp_props_iface_class_init,
+ NULL,
+ NULL,
+ sizeof(TpPropsIface),
+ 0,
+ (GInstanceInitFunc)tp_props_iface_init
+ };
+ type1 = g_type_register_static(DBUS_TYPE_G_PROXY,
+ "TpPropsIface", &info, 0);
+ }
+ return type1;
+}
+
+/* The interface name getters */
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark
+tp_get_props_interface (void)
+{
+#ifndef EMULATOR
+ static GQuark ret = 0;
+#endif
+
+ if (ret == 0)
+ {
+ ret = g_quark_from_static_string(TP_IFACE_PROPERTIES);
+ }
+
+ return ret;
+}
+
+TpPropsIface *
+tp_props_iface_new (DBusGConnection *connection,
+ const char *name,
+ const char *path_name)
+{
+ /* The properties are order dependant in dbus <= 0.61. Thanks dbus*/
+ return g_object_new (TELEPATHY_PROPS_IFACE_TYPE,
+ "name", name,
+ "path", path_name,
+ "interface",TP_IFACE_PROPERTIES,
+ "connection", connection,
+ NULL);
+}
+
+static void properties_changed_cb (DBusGProxy *proxy, GPtrArray *properties, gpointer user_data);
+static void property_flags_changed_cb (DBusGProxy *proxy, GPtrArray *properties, gpointer user_data);
+
+/**
+ * tp_props_iface_set_mapping:
+ * @iface: #TpPropsIface on which to set mapping
+ * @first_name: First name in list to set a mapping for
+ *
+ * Set a mapping between propery names and your chosen ID's for these
+ * names. Takes a list of property name, id pairs, terminated by NULL.
+ *
+ * Typically the user will define an enum of properties that they're
+ * interested in, and set a mapping like:
+ * tp_props_iface_set_mapping (props, "foo", FOO,
+ * "bar", BAR,
+ * "baz", BAZ,
+ * NULL);
+ * the user should bind to the
+ * <link linkend="TpPropsIface-properties-ready">properties-ready signal</link>
+ * before calling this. Property queries will only be possible *after* this
+ * signal has been emitted.
+ */
+void tp_props_iface_set_mapping (TpPropsIface *self,
+ const gchar *first_property_name,
+ ...)
+{
+ va_list var_args;
+ const gchar *name = first_property_name;
+ guint id;
+ GArray *array;
+ PropertyMapping map = {0,0,NULL,NULL,0};
+
+ g_return_if_fail (TELEPATHY_IS_PROPS_IFACE (self));
+ g_return_if_fail (PRIV(self)->mappings == NULL);
+
+ va_start (var_args, first_property_name);
+
+ array = g_array_new (FALSE, FALSE, sizeof (PropertyMapping));
+
+ while (name)
+ {
+ id = va_arg (var_args, guint);
+ map.user_id = id;
+ map.name = g_strdup (name);
+ g_array_append_val (array, map);
+ name = va_arg (var_args, gchar *);
+ }
+
+ va_end (var_args);
+
+ PRIV (self)->mappings_len = array->len;
+ PRIV (self)->mappings = (PropertyMapping*) g_array_free (array, FALSE);
+
+ dbus_g_proxy_connect_signal (DBUS_G_PROXY (self), "PropertiesChanged",
+ G_CALLBACK(properties_changed_cb), self, NULL);
+ dbus_g_proxy_connect_signal (DBUS_G_PROXY (self), "PropertyFlagsChanged",
+ G_CALLBACK(property_flags_changed_cb),
+ self, NULL);
+
+ tp_props_iface_list_properties_async (DBUS_G_PROXY (self),
+ properties_listed_cb, self);
+}
+
+/**
+ * tp_props_iface_get_value:
+ * @self: #TpPropsIface on which to get a property value
+ * @prop_id: Identifier for property as set in #tp_props_iface_set_mapping
+ * @value: GValue to return the property's value in.
+ *
+ * Get the value of a property on this interface
+ */
+gboolean tp_props_iface_get_value (TpPropsIface* self, guint prop_id,
+ GValue *return_value)
+{
+ int i;
+
+ if (!PRIV (self)->properties_ready)
+ return FALSE;
+
+ for (i = 0; i < PRIV (self)->mappings_len; i++)
+ {
+ if (PRIV (self)->mappings[i].user_id == prop_id)
+ {
+ if (PRIV (self)->mappings[i].value)
+ {
+ g_value_copy (PRIV (self)->mappings[i].value, return_value);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+/* dummy callback handler for async calling calls with no return values */
+static void
+dummy_callback (DBusGProxy *proxy, GError *error, gpointer user_data)
+{
+ if (error)
+ {
+ g_warning ("%s calling %s", error->message, (char*)user_data);
+ g_error_free (error);
+ }
+}
+
+/**
+ * tp_props_iface_set_value:
+ * @self: #TpPropsIface on which to set a property value
+ * @prop_id: Identifier for property as set in #tp_props_iface_set_mapping
+ * @value: GValue to use to set the property's value
+ *
+ * Set the value of a property on this interface
+ */
+gboolean tp_props_iface_set_value (TpPropsIface* self, guint prop_id,
+ const GValue *value)
+{
+ /*TODO add option for an error callback*/
+ int i;
+ GPtrArray *props;
+
+ if (!PRIV(self)->properties_ready)
+ return FALSE;
+
+ for (i=0; i < PRIV(self)->mappings_len; i++)
+ {
+ if (PRIV(self)->mappings[i].user_id == prop_id)
+ {
+ GValue prop = {0,};
+ g_value_init (&prop, TP_TYPE_PROPERTY_CHANGE);
+ g_value_take_boxed (&prop,
+ dbus_g_type_specialized_construct (TP_TYPE_PROPERTY_CHANGE));
+
+ dbus_g_type_struct_set (&prop,
+ 0, PRIV(self)->mappings[i].server_id,
+ 1, value,
+ G_MAXUINT);
+
+ props = g_ptr_array_sized_new (1);
+ g_ptr_array_add (props, g_value_get_boxed (&prop));
+ tp_props_iface_set_properties_async (DBUS_G_PROXY(self), props,
+ dummy_callback, "SetProperties");
+ g_value_unset (&prop);
+ g_ptr_array_free (props, TRUE);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+static void
+set_properties_values (TpPropsIface *self, GPtrArray *properties)
+{
+ int i,j;
+
+ for (i = 0; i < properties->len; i++)
+ {
+ GValue property = {0};
+ guint32 id;
+ GValue *value;
+
+ g_value_init (&property, TP_TYPE_PROPERTY_CHANGE);
+ g_value_set_static_boxed (&property, g_ptr_array_index (properties, i));
+ dbus_g_type_struct_get (&property, 0, &id, G_MAXUINT);
+
+ for (j = 0; j < PRIV(self)->mappings_len; j++)
+ {
+ PropertyMapping *mapping = &(PRIV (self)->mappings[j]);
+
+ if (mapping->server_id == id)
+ {
+ dbus_g_type_struct_get (&property, 1, &value, G_MAXUINT);
+ g_assert (value);
+
+ if (mapping->value)
+ {
+ g_value_unset (mapping->value);
+ g_free (mapping->value);
+ }
+
+ mapping->value = value;
+ value = NULL; /* just to be on the safe side... */
+
+ if (PRIV (self)->properties_ready)
+ g_signal_emit (self, signals[PROPERTY_CHANGED], 0,
+ mapping->user_id, TP_PROPS_CHANGED_VALUE);
+
+ break;
+ }
+ }
+ }
+
+}
+
+static void
+properties_changed_cb (DBusGProxy *proxy, GPtrArray *properties,
+ gpointer user_data)
+{
+ TpPropsIface *self = TELEPATHY_PROPS_IFACE (user_data);
+ if (!PRIV(self)->properties_ready)
+ return;
+ set_properties_values (self, properties);
+}
+
+static void
+properties_got_cb (DBusGProxy *proxy, GPtrArray *properties, GError *error, gpointer user_data)
+{
+ TpPropsIface *self = TELEPATHY_PROPS_IFACE (user_data);
+
+ if (error)
+ {
+ g_debug ("getting properties failed: %s (%s)", error->message,
+ dbus_g_error_get_name (error));
+ g_error_free (error);
+ return;
+ }
+
+ set_properties_values (self, properties);
+
+ if (!PRIV (self)->properties_ready)
+ {
+ PRIV (self)->properties_ready = TRUE;
+ g_signal_emit (self, signals[PROPERTIES_READY], 0);
+ }
+}
+
+static void
+property_flags_changed_cb (DBusGProxy *proxy, GPtrArray *properties,
+ gpointer user_data)
+{
+ TpPropsIface *self = TELEPATHY_PROPS_IFACE (user_data);
+ GArray *get_props;
+ int i, j;
+
+ if (!PRIV(self)->properties_ready)
+ return;
+
+ get_props = g_array_sized_new (FALSE, FALSE, sizeof (guint32),
+ properties->len);
+
+ for (i = 0; i < properties->len; i++)
+ {
+ GValue property = {0};
+ guint32 id, flags;
+
+ g_value_init (&property, TP_TYPE_PROPERTY_CHANGE);
+ g_value_set_static_boxed (&property, g_ptr_array_index (properties, i));
+ dbus_g_type_struct_get (&property, 0, &id, G_MAXUINT);
+
+ for (j = 0; j < PRIV (self)->mappings_len; j++)
+ {
+ PropertyMapping *mapping = &(PRIV (self)->mappings[j]);
+
+ if (mapping->server_id == id)
+ {
+ dbus_g_type_struct_get (&property, 1, &flags, G_MAXUINT);
+
+ if (!(mapping->flags & TP_PROPERTY_FLAG_READ) &&
+ flags & TP_PROPERTY_FLAG_READ)
+ /* property has become readable; fetch it */
+ g_array_append_val (get_props, mapping->server_id);
+
+ mapping->flags = flags;
+ g_signal_emit (self, signals[PROPERTY_CHANGED], 0,
+ mapping->user_id, TP_PROPS_CHANGED_FLAGS);
+ break;
+ }
+ }
+ }
+
+ tp_props_iface_get_properties_async (DBUS_G_PROXY (self), get_props,
+ properties_got_cb, self);
+ g_array_free (get_props, TRUE);
+}
+
+static void
+properties_listed_cb (DBusGProxy *proxy, GPtrArray *properties, GError *error, gpointer user_data)
+{
+ TpPropsIface *self = TELEPATHY_PROPS_IFACE (user_data);
+ int i,j;
+ guint32 id, flags;
+ gchar *name;
+ GArray *get_props;
+
+ if (error)
+ {
+ g_debug ("listing properties failed: %s (%s)", error->message,
+ dbus_g_error_get_name (error));
+ g_error_free (error);
+ return;
+ }
+
+ for (i = 0; i < properties->len; i++)
+ {
+ GValue property = {0};
+ g_value_init (&property, TP_TYPE_PROPERTY_DESCRIPTION);
+ g_value_set_static_boxed (&property, g_ptr_array_index (properties, i));
+
+ dbus_g_type_struct_get (&property,
+ 0, &id,
+ 1, &name,
+ 3, &flags,
+ G_MAXUINT);
+
+ for (j = 0; j < PRIV (self)->mappings_len; j++)
+ {
+ if (0 == strcmp (PRIV (self)->mappings[j].name, name))
+ {
+ PRIV (self)->mappings[j].server_id = id;
+ PRIV (self)->mappings[j].flags = flags;
+ }
+ }
+
+ g_free (name);
+ }
+
+ get_props = g_array_sized_new (FALSE, FALSE, sizeof (guint32),
+ properties->len);
+
+ for (i = 0; i < PRIV(self)->mappings_len; i++)
+ {
+ PropertyMapping *mapping = &(PRIV(self)->mappings[i]);
+
+ if (mapping->flags & TP_PROPERTY_FLAG_READ)
+ g_array_append_val (get_props, mapping->server_id);
+ }
+
+ tp_props_iface_get_properties_async (DBUS_G_PROXY (self), get_props,
+ properties_got_cb, self);
+ g_array_free (get_props, TRUE);
+}
+
+void
+tp_props_interface_set_signatures (DBusGProxy *proxy)
+{
+ dbus_g_proxy_add_signal(proxy, "PropertiesChanged",
+ dbus_g_type_get_collection ("GPtrArray",
+ dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT,
+ G_TYPE_VALUE, G_TYPE_INVALID)),
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(proxy, "PropertyFlagsChanged",
+ dbus_g_type_get_collection ("GPtrArray",
+ dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_INVALID)),
+ G_TYPE_INVALID);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/bmarm/telepathygabbletest.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1 @@
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/bmarm/telepathygabbletestu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1 @@
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/bwins/telepathygabbletest.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1 @@
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/bwins/telepathygabbletestu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,7 @@
+EXPORTS
+ ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &)
+ tp_chan_type_text_send_async @ 2 NONAME
+ tp_chan_type_search_async @ 3 NONAME
+ tp_chan_type_search_get_search_keys_async @ 4 NONAME
+ tp_chan_type_search_get_search_state_async @ 5 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/conf/telepathygabbletest.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,409 @@
+// Definitions
+[Define]
+SERVER_GIZMO chat.gizmoproject.com
+SSL_FLAG_GIZMO 0
+USERNAME_GIZMO testlmnokia@chat.gizmoproject.com
+PASSWORD_GIZMO loudmouth
+RESOURCE mytptestresource_another1
+PROXY_SERVER 172.16.42.135
+//PROXY_SERVER 172.16.9.181
+//PROXY_SERVER 172.16.9.103
+PROXY_PORT 8080
+PORT 443
+//PORT_INVALID 4430
+
+//EMPTYCONTACT Emptycontact@chat.gizmoproject.com
+//EMPTYPASSWORD test
+
+
+//KEY-VALUES for search with gizmo
+KEY_FIRST_INVALID xmpp_user_invalid
+VALUE_FIRST_INVALID rak*
+
+KEY_ANY_INVALID first_name_invalid
+VALUE_ANY rakesh
+KEY_FIRST first_name
+VALUE_FIRST rakesh
+VALUE_FIRST_WILDCHAR_1 r*
+VALUE_FIRST_WILDCHAR_2 *r*
+KEY_LAST last_name
+VALUE_LAST b
+KEY_CITY city
+VALUE_CITY moneteau
+KEY_COUNTRY country
+VALUE_COUNTRY india
+KEY_STATE state
+VALUE_STATE SP
+KEY_ACCOUNTNAME xmpp_user
+VALUE_ACCOUNTNAME rakeshongizmo
+KEY_EMAIL email_address
+VALUE_EMAIL r*@chat.gizmoproject.com
+VALUE_ALL_KEYS a
+VALUE_FIRST_NAME_MAX abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx
+VALUE_FIRST_SPECIAL_CHAR a_b&c#2^!abc
+
+//own name as the receipient
+OWN_RECIPIENT_GIZMO testlmnokia@chat.gizmoproject.com
+
+//invalied username
+USERNAME_INVALID_GIZMO abcd_ad@chat.gizmoproject.com
+USERNAME_SPL_CHRS_GIZMO abcd_2@chat.gizmoproject.com
+
+//invalid passwd
+PASSWORD_INVALID abcd_gh1_2_pwd
+
+//invalid server
+BADSERVER talktalk.gooooogle.com
+
+
+//contact not there in the contact list
+RECIPIENT_NOT_CONTACT_GTALK usernotincontactlist@gmail.com
+RECIPIENT_ALREADYADDED_GTALK testcm6@gmail.com
+
+//RECIPIENT testlmnokia@chat.gizmoproject.com
+RECIPIENT testcm6@gmail.com
+//RECIPIENT voting@chat.gizmoproject.com
+
+//contact in the friend list
+RECIPIENT_FRIEND testgb123@gmail.com
+RECIPIENT_INVALID a_b@chat.gizmoproject.com
+RECIPIENT_SPL_CHRS a$$b@chat.gizmoproject.com
+
+MESSAGE Hello
+MESSAGE_SPL_CHARS ab$$&&()!@#%*~`?<>,./\[]{}1234
+REPEATED_MESSAGE ThisIsTestForRepeatedMessage
+MESSAGE_EMOTICONS :-)
+
+
+//GTalk Server Settings
+SERVER_GTALK talk.google.com
+SSL_FLAG_GTALK 1
+USERNAME_GTALK testgb123@gmail.com
+PASSWORD_GTALK testgb1234
+OWN_RECIPIENT_GTALK testgb123@gmail.com
+OWN_RECIPIENT_GTALK_WITH_RESOURCE testgb123@gmail.com/mytptestresource_another1
+RECIPIENT_INVALID_GTALK a_b@gmail.com
+DELETE_INVALID_GTALK usernotincontactlist_123@gmail.com
+RECIPIENT_GTALK testcm6@gmail.com
+RECIPIENT_GTALK_SEND_MSG testcm6@gmail.com
+//RECIPIENT_GTALK_SEND_MSG lalita.kapur@gmail.com
+RECIPIENT_OFFLINE_GTALK userIDWithZeroContact@gmail.com
+
+//TODO: Check the Max/Min length of userid
+//min len - 6 chars in gtalk
+//max len - 30 chars in gtalk
+MAXLENGTH_USERID abcd123456abcd123456abcd123456@gmail.com
+MINLENGTH_USERID ab123d@gmail.com
+MAXMINLEN_PWD nokia123
+USERNAMEWITHZEROCONTACT UserWithZeroContact@gmail.com
+USERNAMEWITHZEROCONTACT_PWD UserWithZeroContact123
+USERNAME_INVALID_GTALK abcd_ad@gmail.com
+USERNAME_SPL_CHRS_GTALK abcd_2@gmail.com
+RECIPIENT_SPL_CHRS_GTALK a$$b@gmail.com
+
+USERNAMEWITHZEROCONTACT_GTALK userIDWithZeroContact@gmail.com
+PWDWITHZEROCONTACT_GTALK userIDWithZeroContact123
+
+USERALREADYDELETED_GTALK UserAlreadyDeleted@gmail.com
+
+[Enddefine]
+
+// Login related test cases
+[Test]
+title Login Test
+create TelepathyGabbleTest TgObj
+TgObj LoginTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+// Logout related test cases
+[Test]
+title Logout Test
+create TelepathyGabbleTest TgObj
+TgObj LogoutTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with invalid userid
+[Test]
+title LoginInvalidUserid Test
+create TelepathyGabbleTest TgObj
+TgObj LoginInvalidUseridTest SERVER_GTALK USERNAME_INVALID_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with invalid passwd
+[Test]
+title LoginInvalidPasswd Test
+create TelepathyGabbleTest TgObj
+TgObj LoginInvalidPasswdTest SERVER_GTALK USERNAME_GTALK PASSWORD_INVALID RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with invalid userid and passwd test
+[Test]
+title LoginInvalidUseridPasswd Test
+create TelepathyGabbleTest TgObj
+TgObj LoginInvalidUseridPasswdTest SERVER_GTALK USERNAME_INVALID_GTALK PASSWORD_INVALID RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with blank userid and correct passwd
+[Test]
+title LoginblankUserid Test
+create TelepathyGabbleTest TgObj
+TgObj LoginblankUseridTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with correct userid and blank passwd
+[Test]
+title LoginblankPasswd Test
+create TelepathyGabbleTest TgObj
+TgObj LoginblankPasswdTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//login with blank userid and blank passwd
+[Test]
+title LoginblankUseridblankPasswd Test
+create TelepathyGabbleTest TgObj
+TgObj LoginblankUseridblankPasswdTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with maxlength userid
+[Test]
+title LoginWithMaxLengthUserID Test
+create TelepathyGabbleTest TgObj
+TgObj LoginWithMaxLengthUserIDTest SERVER_GTALK MAXLENGTH_USERID MAXMINLEN_PWD RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with minlength userid
+[Test]
+title LoginWithMinLengthUserID Test
+create TelepathyGabbleTest TgObj
+TgObj LoginWithMinLengthUserIDTest SERVER_GTALK MINLENGTH_USERID MAXMINLEN_PWD RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//login with special chars in the user name
+[Test]
+title LoginUseridWithSplChrs Test
+create TelepathyGabbleTest TgObj
+TgObj LoginUseridWithSplChrsTest SERVER_GTALK USERNAME_SPL_CHRS_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Cancel login test
+[Test]
+title LoginCancel Test
+create TelepathyGabbleTest TgObj
+TgObj LoginCancelTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+// Send Message related test case
+[Test]
+title SendMesasge Test
+create TelepathyGabbleTest TgObj
+TgObj SendMessageTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+// Send Message to a contact with Max Length UserId
+// Check if this will pass or not
+[Test]
+title SendMesasgeToMaxLengthUserID Test
+create TelepathyGabbleTest TgObj
+TgObj SendMesasgeToMaxLengthUserIDTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK MAXLENGTH_USERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//Send Message to offline contact
+[Test]
+title SendMesasgetoofflinecontact Test
+create TelepathyGabbleTest TgObj
+TgObj SendMesasgetoofflinecontactTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_OFFLINE_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+// Send Message 400 characters related test case
+[Test]
+title SendMesasgeWith400 Test
+create TelepathyGabbleTest TgObj
+TgObj SendMessageWith400Test SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+// Send Message blank characters related test case
+[Test]
+title SendMesasgeBlank Test
+create TelepathyGabbleTest TgObj
+TgObj SendMesasgeBlankTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+
+// SendMesasgeToBlankUserIdTest
+[Test]
+title SendMesasgeToBlankUserIdTest Test
+create TelepathyGabbleTest TgObj
+TgObj SendMesasgeToBlankUserIdTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//SendMessage special
+[Test]
+title SendMesasgeSplChars Test
+create TelepathyGabbleTest TgObj
+TgObj SendMesasgeSplCharsTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG MESSAGE_SPL_CHARS RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//SendMessage emoticons
+[Test]
+title SendMesasgeEmoticons Test
+create TelepathyGabbleTest TgObj
+TgObj SendMesasgeEmoticonsTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG MESSAGE_EMOTICONS RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Send Repeated Messages
+[Test]
+title SendMessageRepeated Test
+create TelepathyGabbleTest TgObj
+TgObj SendMessageRepeatedTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK_SEND_MSG REPEATED_MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//SendMessage to user who is not a contact
+[Test]
+title SendMessagetoUserNotInContactList Test
+create TelepathyGabbleTest TgObj
+TgObj SendMessagetoUserNotInContactListTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_NOT_CONTACT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//SendMessage to Invalid user_id
+[Test]
+title SendMessagetoinvalidUserid Test
+create TelepathyGabbleTest TgObj
+TgObj SendMessagetoinvalidUseridTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_INVALID_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//Add Contact test
+[Test]
+title AddContact Test
+create TelepathyGabbleTest TgObj
+TgObj AddContactTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Add Contact with Max length UserId test
+[Test]
+title AddContactWithMaxLengthUserId Test
+create TelepathyGabbleTest TgObj
+TgObj AddContactWithMaxLengthUserIdTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK MAXLENGTH_USERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Add Contact with blank userid
+[Test]
+title AddContactWithBlankUserId Test
+create TelepathyGabbleTest TgObj
+TgObj AddContactWithBlankUserIdTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//Add Invalid Contact test
+[Test]
+title AddContactinvalid Test
+create TelepathyGabbleTest TgObj
+TgObj AddContactinvalidTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_INVALID_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Add Invalid Contact with special characters test
+[Test]
+title AddContactinvalidWithSplChars Test
+create TelepathyGabbleTest TgObj
+TgObj AddContactinvalidWithSplCharsTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_SPL_CHRS_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Add AlreadyAddedContact test
+[Test]
+title AddContactAlreadyInRoster Test
+create TelepathyGabbleTest TgObj
+TgObj AddContactAlreadyInRosterTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_ALREADYADDED_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Remove Contact test
+[Test]
+title RemoveContact Test
+create TelepathyGabbleTest TgObj
+TgObj RemoveContactTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Remove Contact with Max Length UserID test
+[Test]
+title RemoveContactWithMaxLengthUserID Test
+create TelepathyGabbleTest TgObj
+TgObj RemoveContactWithMaxLengthUserIDTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK MAXLENGTH_USERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Remove an unexisting contact_id from the contactlist
+[Test]
+title RemoveInvalidContact Test
+create TelepathyGabbleTest TgObj
+TgObj RemoveInvalidContactTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK DELETE_INVALID_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Remove Contact With BlankUserId from the contactlist
+[Test]
+title RemoveContactWithBlankUserId Test
+create TelepathyGabbleTest TgObj
+TgObj RemoveContactWithBlankUserIdTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Remove a contact_id which is already deleted from the contactlist
+[Test]
+title RemoveContactAlreadyRemoved Test
+create TelepathyGabbleTest TgObj
+TgObj RemoveContactAlreadyRemovedTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK USERALREADYDELETED_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Fetch Contacts test
+[Test]
+title FetchContacts Test
+create TelepathyGabbleTest TgObj
+TgObj FetchContactsTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//FetchEmptyContactList test
+[Test]
+title FetchEmptyContactList Test
+create TelepathyGabbleTest TgObj
+TgObj FetchZeroContactTest SERVER_GTALK USERNAMEWITHZEROCONTACT_GTALK PWDWITHZEROCONTACT_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/conf/telepathygabbletest_mannual.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,426 @@
+// Definitions
+[Define]
+SERVER_GIZMO chat.gizmoproject.com
+SSL_FLAG_GIZMO 0
+USERNAME_GIZMO testlmnokia@chat.gizmoproject.com
+PASSWORD_GIZMO loudmouth
+RESOURCE mytptestresource_another1
+PROXY_SERVER 172.16.42.135
+//PROXY_SERVER 172.16.9.181
+//PROXY_SERVER 172.16.9.103
+PROXY_PORT 8080
+PORT 443
+//PORT_INVALID 4430
+
+//EMPTYCONTACT Emptycontact@chat.gizmoproject.com
+//EMPTYPASSWORD test
+
+
+//KEY-VALUES for search with gizmo
+KEY_FIRST_INVALID xmpp_user_invalid
+VALUE_FIRST_INVALID rak*
+
+KEY_ANY_INVALID first_name_invalid
+VALUE_ANY rakesh
+KEY_FIRST first_name
+VALUE_FIRST rakesh
+VALUE_FIRST_WILDCHAR_1 r*
+VALUE_FIRST_WILDCHAR_2 *r*
+KEY_LAST last_name
+VALUE_LAST b
+KEY_CITY city
+VALUE_CITY moneteau
+KEY_COUNTRY country
+VALUE_COUNTRY india
+KEY_STATE state
+VALUE_STATE SP
+KEY_ACCOUNTNAME xmpp_user
+VALUE_ACCOUNTNAME rakeshongizmo
+KEY_EMAIL email_address
+VALUE_EMAIL r*@chat.gizmoproject.com
+VALUE_ALL_KEYS a
+VALUE_FIRST_NAME_MAX abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx
+VALUE_FIRST_SPECIAL_CHAR a_b&c#2^!abc
+VALUE_FIRST_MULTIPLE bh
+VALUE_FIRST_STRING lk
+VALUE_SECOND_STRING lkmn
+
+
+
+
+SERVER_YUKON chat.ovi.com
+SSL_FLAG_YUKON 1
+USERNAME_YUKON nikumb@ovi.com
+PASSWORD_YUKON pinkearth
+RESOURCE_YUKON mytptestresource_yukon
+
+PORT_YUKON 5222
+
+KEY_FULLNAME_YUKON fn
+VALUE_FULLNAME_YUKON shrikumar
+
+KEY_FIRST_YUKON first
+VALUE_FIRST_YUKON a
+
+
+
+
+
+//own name as the receipient
+OWN_RECIPIENT_GIZMO testlmnokia@chat.gizmoproject.com
+
+//invalied username
+USERNAME_INVALID_GIZMO abcd_ad@chat.gizmoproject.com
+USERNAME_SPL_CHRS_GIZMO abcd_2@chat.gizmoproject.com
+
+//invalid passwd
+PASSWORD_INVALID abcd_gh1_2_pwd
+
+//invalid server
+BADSERVER talktalk.gooooogle.com
+
+
+//contact not there in the contact list
+RECIPIENT_NOT_CONTACT_GTALK usernotincontactlist@gmail.com
+RECIPIENT_ALREADYADDED_GTALK testcm6@gmail.com
+
+//RECIPIENT testlmnokia@chat.gizmoproject.com
+RECIPIENT testcm6@gmail.com
+//RECIPIENT voting@chat.gizmoproject.com
+
+//contact in the friend list
+RECIPIENT_FRIEND testgb123@gmail.com
+RECIPIENT_INVALID a_b@chat.gizmoproject.com
+RECIPIENT_SPL_CHRS a$$b@chat.gizmoproject.com
+
+MESSAGE Hello
+MESSAGE_SPL_CHARS ab$$&&()!@#%*~`?<>,./\[]{}1234
+REPEATED_MESSAGE ThisIsTestForRepeatedMessage
+MESSAGE_EMOTICONS :-)
+
+
+//GTalk Server Settings
+SERVER_GTALK talk.google.com
+SSL_FLAG_GTALK 1
+USERNAME_GTALK testgb123@gmail.com
+PASSWORD_GTALK testgb1234
+OWN_RECIPIENT_GTALK testgb123@gmail.com
+OWN_RECIPIENT_GTALK_WITH_RESOURCE testgb123@gmail.com/mytptestresource_another1
+RECIPIENT_INVALID_GTALK a_b@gmail.com
+DELETE_INVALID_GTALK usernotincontactlist_123@gmail.com
+RECIPIENT_GTALK testcm6@gmail.com
+RECIPIENT_GTALK_SEND_MSG testcm6@gmail.com
+//RECIPIENT_GTALK_SEND_MSG lalita.kapur@gmail.com
+RECIPIENT_OFFLINE_GTALK userIDWithZeroContact@gmail.com
+
+//TODO: Check the Max/Min length of userid
+//min len - 6 chars in gtalk
+//max len - 30 chars in gtalk
+MAXLENGTH_USERID abcd123456abcd123456abcd123456@gmail.com
+MINLENGTH_USERID ab123d@gmail.com
+MAXMINLEN_PWD nokia123
+USERNAMEWITHZEROCONTACT UserWithZeroContact@gmail.com
+USERNAMEWITHZEROCONTACT_PWD UserWithZeroContact123
+USERNAME_INVALID_GTALK abcd_ad@gmail.com
+USERNAME_SPL_CHRS_GTALK abcd_2@gmail.com
+RECIPIENT_SPL_CHRS_GTALK a$$b@gmail.com
+
+USERNAMEWITHZEROCONTACT_GTALK userIDWithZeroContact@gmail.com
+PWDWITHZEROCONTACT_GTALK userIDWithZeroContact123
+
+USERALREADYDELETED_GTALK UserAlreadyDeleted@gmail.com
+
+[Enddefine]
+
+
+// Login related test cases
+// test case for bad server - getting hung, no callback comes,don't run
+//[Test]
+//title LoginWithBadServer Test
+//create TelepathyGabbleTest TgObj
+//TgObj LoginBadServerTest BADSERVER USERNAME_GTALK PASSWORD_GTALK RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+//delete TgObj
+//[Endtest]
+
+
+//Recieve Message test
+[Test]
+title ReceiveMesasge Test
+create TelepathyGabbleTest TgObj
+TgObj ReceiveMessageTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO OWN_RECIPIENT_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+//TgObj ReceiveMessageTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK OWN_RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//Recieve MaxLengthMessage test
+[Test]
+title ReceiveMaxLengthMessage Test
+create TelepathyGabbleTest TgObj
+TgObj ReceiveMessageMaxLengthTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO OWN_RECIPIENT_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+//TgObj ReceiveMessageMaxLengthTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK OWN_RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+
+//Recieve Message special characters test
+[Test]
+title ReceiveMessageWithSplChrs Test
+create TelepathyGabbleTest TgObj
+//TgObj ReceiveMessageWithSplChrsTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK OWN_RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+TgObj ReceiveMessageWithSplChrsTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO OWN_RECIPIENT_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Recieve Message emoticons test
+[Test]
+title ReceiveMessageWithEmoticons Test
+create TelepathyGabbleTest TgObj
+//TgObj ReceiveMessageWithEmoticonsTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK OWN_RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+TgObj ReceiveMessageWithEmoticonsTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO OWN_RECIPIENT_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Receive RepeatedMessages test
+[Test]
+title ReceiveRepeatedMessages Test
+create TelepathyGabbleTest TgObj
+//TgObj ReceiveRepeatedMessageTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK OWN_RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+TgObj ReceiveRepeatedMessageTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO OWN_RECIPIENT_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+
+//Recieve BlankMessage test
+[Test]
+title ReceiveBlankMesasge Test
+create TelepathyGabbleTest TgObj
+TgObj ReceiveMessageBlankTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO OWN_RECIPIENT_GIZMO MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+//TgObj ReceiveMessageBlankTest SERVER_GTALK USERNAME_GTALK PASSWORD_GTALK OWN_RECIPIENT_GTALK MESSAGE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GTALK
+delete TgObj
+[Endtest]
+
+//Search FirstName test
+[Test]
+title Search FirstName Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search LastName test
+[Test]
+title Search LastName Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_LAST VALUE_LAST RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search City test
+[Test]
+title Search City Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_CITY VALUE_CITY RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search Country test
+[Test]
+title Search Country Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_COUNTRY VALUE_COUNTRY RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search State test
+[Test]
+title Search State Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_STATE VALUE_STATE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search AccountName test
+[Test]
+title Search AccountName Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_ACCOUNTNAME VALUE_ACCOUNTNAME RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search Email test
+[Test]
+title Search Email Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_EMAIL VALUE_EMAIL RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search FirstNameWithWildChar* test
+[Test]
+title Search FirstNameWithWildChar* Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_WILDCHAR_1 RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search FirstNameWith*string* test
+[Test]
+title Search FirstNameWith*string* Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_WILDCHAR_2 RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search GetSearchKeys test
+//KEY_FIRST, VALUE_FIRST params will not be used for GetSearchKeys
+[Test]
+title Search GetSearchKeys Test
+create TelepathyGabbleTest TgObj
+TgObj GetSearchKeysTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//SearchWithAllKeys test
+//KEY_FIRST will not be used for SearchWithAllKeysTest
+//All the keys will be searched for value VALUE_ALL_KEYS
+[Test]
+title Search WithAllKeys Test
+create TelepathyGabbleTest TgObj
+TgObj SearchWithAllKeysTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_ALL_KEYS RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchAnyKeyInvalid Test
+[Test]
+title Search AnyKeyInvalid Test
+create TelepathyGabbleTest TgObj
+TgObj SearchInvalidKeyTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_ANY_INVALID VALUE_ANY RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchFirstKeyInvalid Test
+[Test]
+title Search FirstKeyInvalid Test
+create TelepathyGabbleTest TgObj
+TgObj SearchInvalidKeyTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST_INVALID VALUE_FIRST_INVALID RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchTwoInvalidKeys Test
+[Test]
+title Search SearchTwoInvalidKeysTest
+create TelepathyGabbleTest TgObj
+TgObj SearchTwoInvalidKeysTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST_INVALID VALUE_FIRST RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO KEY_ANY_INVALID VALUE_ANY
+delete TgObj
+[Endtest]
+
+//Search SearchNoKeyValue Test
+[Test]
+title Search NoKeyValue Test
+create TelepathyGabbleTest TgObj
+TgObj SearchNoKeyValueTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_ANY_INVALID VALUE_ANY RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchMaxLenSearchString Test
+[Test]
+title SearchMaxLenSearchString Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_NAME_MAX PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchSpecialCharSearchString Test
+[Test]
+title SearchSpecialCharSearchString Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_SPECIAL_CHAR PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchNoResults Test
+//Passed strings for key_first and value_first will not be used
+[Test]
+title SearchNoResults Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search SearchBlankString Test
+//Passed strings for key_first and value_first will not be used
+[Test]
+title SearchBlankString Test
+create TelepathyGabbleTest TgObj
+TgObj SearchBlankStringTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+//Search Twice Test
+[Test]
+title SearchTwiceTest
+create TelepathyGabbleTest TgObj
+TgObj SearchTwiceTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_MULTIPLE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+
+//Search SearchTwiceWithDiffStrings Test
+[Test]
+title SearchTwiceWithDiffStrings Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTwiceWithDiffStringsTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_STRING RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO KEY_FIRST VALUE_SECOND_STRING
+delete TgObj
+[Endtest]
+
+
+//Search FiveTimes Test
+[Test]
+title SearchFiveTimesTest
+create TelepathyGabbleTest TgObj
+TgObj SearchFiveTimesTest SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_FIRST_MULTIPLE RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+
+//SearchAfterGetSearchKeys test
+//KEY_FIRST will not be used for SearchAfterGetSearchKeys
+//All the keys will be searched for value VALUE_ALL_KEYS
+[Test]
+title SearchAfterGetSearchKeys Test
+create TelepathyGabbleTest TgObj
+TgObj SearchAfterGetSearchKeys SERVER_GIZMO USERNAME_GIZMO PASSWORD_GIZMO KEY_FIRST VALUE_ALL_KEYS RESOURCE PROXY_SERVER PROXY_PORT PORT SSL_FLAG_GIZMO
+delete TgObj
+[Endtest]
+
+
+//Search related test cases with yukon
+
+
+//Search GetSearchKeys test
+//KEY_FIRST_YUKON, VALUE_FIRST_YUKON params will not be used for GetSearchKeys
+[Test]
+title Search Yukon GetSearchKeys Test
+create TelepathyGabbleTest TgObj
+TgObj GetSearchKeysTest SERVER_YUKON USERNAME_YUKON PASSWORD_YUKON KEY_FIRST_YUKON VALUE_FIRST_YUKON RESOURCE_YUKON PROXY_SERVER PROXY_PORT PORT_YUKON SSL_FLAG_YUKON
+delete TgObj
+[Endtest]
+
+
+//Search FirstName test
+[Test]
+title Search Yukon FirstName Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_YUKON USERNAME_YUKON PASSWORD_YUKON KEY_FIRST_YUKON VALUE_FIRST_YUKON RESOURCE_YUKON PROXY_SERVER PROXY_PORT PORT_YUKON SSL_FLAG_YUKON
+delete TgObj
+[Endtest]
+
+
+//Search FullName test
+[Test]
+title Search Yukon FullName Test
+create TelepathyGabbleTest TgObj
+TgObj SearchTest SERVER_YUKON USERNAME_YUKON PASSWORD_YUKON KEY_FULLNAME_YUKON VALUE_FULLNAME_YUKON RESOURCE_YUKON PROXY_SERVER PROXY_PORT PORT_YUKON SSL_FLAG_YUKON
+delete TgObj
+[Endtest]
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/eabi/telepathygabbletest.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1 @@
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/eabi/telepathygabbletestu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+ _ZTI9CTestData @ 2 NONAME ; #<TI>#
+ _ZTV9CTestData @ 3 NONAME ; #<VT>#
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Contanis the MMP file name
+*
+*/
+
+
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example:
+/*
+/agnmodel/inc/AGMCOMON.H
+*/
+
+PRJ_TESTMMPFILES
+// NOTE: If using ARS requirements .mmp file operation should be done under this.
+// 'abld test build'
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+/agnmodel/group/agnmodel.mmp
+#if defined(MARM)
+/agnmodel/group/agsvexe.mmp
+#endif
+*/
+telepathygabbletest.mmp
+
+// End of File
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/group/telepathygabbletest.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MMP FILE
+*
+*/
+
+
+
+#if defined(__S60_)
+ // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition
+ #include <platform_paths.hrh>
+#endif
+
+TARGET telepathygabbletest.dll
+TARGETTYPE dll
+UID 0x1000008D 0x101FB3E3
+
+CAPABILITY ALL -TCB
+//CAPABILITY NetworkServices
+
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID 0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+// SECUREID 0x00000000
+
+#ifdef WINSCW
+MACRO EMULATOR
+#endif
+
+
+EPOCHEAPSIZE 0x6000 0x1A000
+/*#ifndef WINSCW
+// Allow global writeable static data
+EPOCALLOWDLLDATA
+#endif*/
+
+DEFFILE telepathygabbletest.def
+//VENDORID 0x101FB657
+//SECUREID 0x102073DB
+
+//User Include Path
+USERINCLUDE ../inc
+
+
+
+
+MACRO SYMBIAN
+
+
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_BOOST_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+OS_LAYER_LIBUTILITY_SYSTEMINCLUDE
+
+USERINCLUDE ../../inc
+//
+
+
+SOURCEPATH ../src
+//utils file
+SOURCE telepathygabbleutils.cpp
+//login , logout
+SOURCE telepathygabblelogintest.cpp
+//send message
+SOURCE telepathygabblesendmessage.cpp
+
+//Add Delete Contact related
+SOURCE telepathygabbleadddeletecontact.cpp
+//Fetch contact related
+SOURCE telepathygabblefetchcontacts.cpp
+
+SOURCE telepathygabblesearch.cpp
+//Presence Related
+//SOURCE telepathy-presence.c
+//SOURCE telepathygabblepresencetest.cpp
+//stif related
+SOURCE telepathygabbletest.cpp
+SOURCE telepathygabbletestblocks.cpp
+SOURCE telepathygabbletestdata.cpp
+
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+LIBRARY stiftestengine.lib
+
+// Library dependencies
+#ifdef GCCE
+STATICLIBRARY libcrt0_gcce.lib
+#else
+STATICLIBRARY libcrt0.lib
+#endif
+
+LIBRARY libc.lib
+LIBRARY libpthread.lib
+LIBRARY libm.lib
+LIBRARY libglib.lib
+LIBRARY libgobject.lib
+LIBRARY libssl.lib
+LIBRARY libcrypto.lib
+LIBRARY libdbus-glib.lib
+LIBRARY libdbus.lib
+LIBRARY libtelepathy.lib
+
+LANG SC
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/group/telepathygabbletest.pkg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,34 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the License "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: telepathygabbletest.pkg
+;
+&EN
+
+;Header
+#{"telepathygabbletest"}, (0x101FB3E5), 1, 0, 0, TYPE=SA
+
+
+;Localised VendorID
+%{"Nokia"}
+
+;VendorID
+:"Nokia"
+
+(0x101F7961), 0, 0, 0, {"Series60ProductID"}
+
+;CFG File
+"\epoc32\winscw\c\testframework\telepathygabbletest.cfg" - "c:\testframework\telepathygabbletest.cfg"
+
+;test dll
+"\EPOC32\RELEASE\ARMV5\urel\telepathygabbletest.dll"-"!:\sys\bin\telepathygabbletest.dll"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathy-presence.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Presence related Test Cases.
+*
+*/
+
+
+
+#ifndef __TELEPATHY_PRESENCE_H__
+#define __TELEPATHY_PRESENCE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TELEPATHY_TYPE_PRESENCE (telepathy_presence_get_type ())
+#define TELEPATHY_PRESENCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TELEPATHY_TYPE_PRESENCE, TelepathyPresence))
+#define TELEPATHY_PRESENCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TELEPATHY_TYPE_PRESENCE, TelepathyPresenceClass))
+#define TELEPATHY_IS_PRESENCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TELEPATHY_TYPE_PRESENCE))
+#define TELEPATHY_IS_PRESENCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TELEPATHY_TYPE_PRESENCE))
+#define TELEPATHY_PRESENCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TELEPATHY_TYPE_PRESENCE, TelepathyPresenceClass))
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct _TelepathyPresence TelepathyPresence;
+typedef struct _TelepathyPresenceClass TelepathyPresenceClass;
+
+#ifdef __cplusplus
+}
+#endif
+
+struct _TelepathyPresence {
+ GObject parent;
+};
+
+struct _TelepathyPresenceClass {
+ GObjectClass parent_class;
+};
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+typedef enum {
+ TELEPATHY_PRESENCE_STATE_AVAILABLE,
+ TELEPATHY_PRESENCE_STATE_BUSY,
+ TELEPATHY_PRESENCE_STATE_AWAY,
+ TELEPATHY_PRESENCE_STATE_EXT_AWAY,
+ TELEPATHY_PRESENCE_STATE_HIDDEN, /* When you appear offline to others */
+ TELEPATHY_PRESENCE_STATE_UNAVAILABLE,
+} TelepathyPresenceState;
+
+#ifdef __cplusplus
+}
+#endif
+GType telepathy_presence_get_type (void) G_GNUC_CONST;
+
+TelepathyPresence * telepathy_presence_new (void);
+TelepathyPresence * telepathy_presence_new_full (TelepathyPresenceState state,
+ const gchar *status);
+
+const gchar * telepathy_presence_get_resource (TelepathyPresence *presence);
+TelepathyPresenceState telepathy_presence_get_state (TelepathyPresence *presence);
+const gchar * telepathy_presence_get_status (TelepathyPresence *presence);
+gint telepathy_presence_get_priority (TelepathyPresence *presence);
+
+void telepathy_presence_set_resource (TelepathyPresence *presence,
+ const gchar *resource);
+void telepathy_presence_set_state (TelepathyPresence *presence,
+ TelepathyPresenceState state);
+void telepathy_presence_set_status (TelepathyPresence *presence,
+ const gchar *status);
+void telepathy_presence_set_priority (TelepathyPresence *presence,
+ gint priority);
+gboolean telepathy_presence_resource_equal (gconstpointer a,
+ gconstpointer b);
+gint telepathy_presence_sort_func (gconstpointer a,
+ gconstpointer b);
+
+/*static*/ const gchar *telepathy_presence_state_to_str (TelepathyPresenceState presence_state);
+
+
+
+G_END_DECLS
+
+#endif /* __TELEPATHY_PRESENCE_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabbleadddeletecontact.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class declaration for Contact Managemnet Test Cases.
+*
+*/
+
+
+
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include <pthread.h>
+//for the global data
+#include "telepathygabbletestdata.h"
+
+#define VERBOSE
+
+
+// FORWARD DECLARATION
+class CTestData;
+
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS(CTelepathyGabbleAddDeleteContact) : public CBase
+ {
+
+ private:
+ /*
+ * C++ default constructor.
+ */
+
+ CTelepathyGabbleAddDeleteContact();
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabbleAddDeleteContact* NewL();
+
+ /**
+ * Destructor.
+ */
+ ~CTelepathyGabbleAddDeleteContact();
+
+
+ public: // Member functions
+
+ TInt add_contact ( const gchar *contact_id, const gchar *message,
+ CTestData* aTestData );
+ TInt remove_contact ( const gchar *contact_id, const gchar *message,
+ CTestData* aTestData );
+
+ public : //Callback functions
+
+ static void add_contact_cb( DBusGProxy *proxy, GError *error, gpointer userdata );
+ static void remove_contact_cb( DBusGProxy *proxy, GError *error, gpointer userdata );
+
+ static void roster_members_changed_cb (DBusGProxy *group_iface,
+ gchar *message,
+ GArray *added,
+ GArray *removed,
+ GArray *local_pending,
+ GArray *remote_pending,
+ guint actor,
+ guint reason,
+ gpointer userdata);
+ };
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabblefetchcontacts.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class declaration for Fetch Test Cases.
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <glib.h>
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include <pthread.h>
+//for the global data
+#include "telepathygabbletestdata.h"
+
+
+const guint KMaxContactFetchCount = 500;
+
+
+// FORWARD DECLARATION
+class CTelepathyGabbleLoginTest;
+
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS(CTelepathyGabbleFetchContacts) : public CBase
+ {
+
+ private:
+ /**
+ * C++ default constructor.
+ */
+
+ CTelepathyGabbleFetchContacts();
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabbleFetchContacts* NewL();
+
+ /**
+ * Destructor.
+ */
+ ~CTelepathyGabbleFetchContacts();
+
+ public: // Member functions
+ TInt test_request_roster ( CTestData* aTestData );
+
+ public : //Callback functions
+
+ static void get_roster_member_cb( DBusGProxy *proxy,GArray* current_members, GArray* local_pending_members, GArray* remote_pending_members, GError *error, gpointer userdata );
+ static void inspect_handles_cb( DBusGProxy *proxy,char **handles_names, GError *error, gpointer userdata ) ;
+
+
+
+
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabblelogintest.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class declaration for Login Test Cases.
+*
+*/
+
+
+
+
+
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include <pthread.h>
+
+#define VERBOSE
+
+#include "telepathygabbletestdata.h"
+
+
+#define CONNMGR_NAME "telepathy-gabble"
+#define CONNMGR_BUS "org.freedesktop.Telepathy.ConnectionManager.gabble"
+#define CONNMGR_PATH "/org/freedesktop/Telepathy/ConnectionManager/gabble"
+#define CHANNEL_BUS "org.freedesktop.Telepathy.Channel.Type.Text"
+#define CHANNEL_PATH "/org/freedesktop/Telepathy/Channel/Type/Text"
+#define PROTOCOL "jabber"
+
+
+
+//forward decalration
+class CTestData;
+
+//class declaration
+NONSHARABLE_CLASS(CTelepathyGabbleLoginTest) : public CBase
+ {
+
+ private:
+ /**
+ * C++ default constructor.
+ */
+
+ CTelepathyGabbleLoginTest();
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabbleLoginTest* NewL();
+
+ /**
+ * Destructor.
+ */
+ ~CTelepathyGabbleLoginTest();
+
+
+
+ public: // Member functions
+
+ //Login and Logout functions
+ TInt action_login(char* username,char* password,
+ char* server,char* resource,char* ssl_flag,
+ char *port,char *proxy_server, char *proxy_port,
+ CTestData* aTestData);
+
+ TInt action_logout( CTestData* aTestData );
+
+ TInt action_cancel(char* username,char* password,
+ char* server, char* resource,char* ssl_flag,
+ char *port,char *proxy_server, char *proxy_port,
+ CTestData* aTestData );
+
+
+ public : //Callback functions
+ //Callback function for the status change
+
+ static gboolean status_changed_cb(DBusGProxy *proxy,
+ guint status, guint reason,
+ gpointer user_data);
+
+ //Callback for the creation of a new channel on succeccful login.
+ static void new_channel_handler(DBusGProxy *proxy, const char *object_path,
+ const char *channel_type, guint handle_type,
+ guint channel_handle, gboolean suppress_handler,
+ gpointer user_data);
+
+
+ //Init the text_channel
+ static void text_channel_init ( TpChan *text_chan );
+
+
+ };
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabblepresencetest.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class declaration for Presence Test Cases.
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <glib.h>
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+#include <dbus/dbus-glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include "tp-conn-iface-presence-gen.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include "telepathy-presence.h"
+
+// FORWARD DECLARATION
+class CTestData;
+
+
+#define VERBOSE
+
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS(CTelepathyGabblePresenceTest) : public CBase
+ {
+
+ private:
+ /**
+ * C++ default constructor.
+ */
+
+ CTelepathyGabblePresenceTest();
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabblePresenceTest* NewL();
+
+ /**
+ * Destructor.
+ */
+ ~CTelepathyGabblePresenceTest();
+ public: //members
+
+ TpConn *iTpConn;
+
+ public :
+
+ //presence related functions
+
+ static TelepathyPresenceState telepathy_presence_state_from_str (const gchar *str);
+ void telepathy_contacts_send_presence (DBusGProxy *pres_iface,
+ TelepathyPresence *presence/*, CTestData *aTestData*/);
+
+
+ static void telepathy_presences_foreach (gpointer *key,gpointer *value,
+ TelepathyPresence **presence);
+
+
+ //Callback functions
+ static void telepathy_presence_handle_foreach (gpointer *key,gpointer *value);
+
+ void telepathy_presence_handler(DBusGProxy *proxy,GHashTable *handle_hash);
+
+
+ };
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabblesearch.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class declaration for Search
+*
+*/
+
+
+
+
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-search-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+#include <pthread.h>
+
+
+// FORWARD DECLARATION
+class CTestData;
+
+
+#define VERBOSE
+
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS(CTelepathyGabbleSearch) : public CBase
+ {
+ public:
+
+ struct Search_UserData
+ {
+ GHashTable* data_to_search;
+ CTestData* testData;
+ };
+
+ private:
+ /**
+ * C++ default constructor.
+ */
+
+ CTelepathyGabbleSearch();
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabbleSearch* NewL();
+
+ /**
+ * Destructor.
+ */
+ ~CTelepathyGabbleSearch();
+
+
+
+ public: // Member functions
+
+
+ TInt SearchL( GHashTable *aDataToSearch, CTestData* aTestData );
+
+ TInt GetSearchKeysL( CTestData* aTestData );
+
+ void SearchAgainL( GHashTable *aDataToSearch, CTestData* aTestData );
+
+ CTestData* GetTestData();
+
+ void DoSearchL(GHashTable *aDataToSearch,CTestData *testData);
+
+ void CloseChannel( CTestData* aTestdata );
+
+ public : //Callback functions
+
+ static void search_chan_closed_cb ( DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data
+ );
+ static void search_result_received_cb ( DBusGProxy *proxy,
+ guint contact_handle,
+ GHashTable *values,
+ gpointer user_data
+ );
+ static void search_state_changed_cb ( DBusGProxy *proxy,
+ guint search_state,
+ gpointer user_data
+ );
+
+
+ static void searchreply_cb( DBusGProxy *proxy, GError *error, gpointer user_data );
+
+ //static void setfield_foreach (gpointer key, gpointer value, gpointer user_data);
+
+ static void do_search_reply( DBusGProxy *proxy, char *chan_object_path,
+ GError *error, gpointer user_data );
+ static void getsearchkeys_cb( DBusGProxy *proxy, gchar * instr,
+ gchar ** keys, GError *error, gpointer user_data );
+ private:
+
+ CTestData *iTestData;
+ };
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabblesendmessage.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class declaration for SendMessage.
+*
+*/
+
+
+
+
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+#include <pthread.h>
+
+
+// FORWARD DECLARATION
+class CTestData;
+
+
+#define VERBOSE
+
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS(CTelepathyGabbleSendRecvMessage) : public CBase
+ {
+
+ private:
+ /**
+ * C++ default constructor.
+ */
+
+ CTelepathyGabbleSendRecvMessage();
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabbleSendRecvMessage* NewL();
+
+ /**
+ * Destructor.
+ */
+ ~CTelepathyGabbleSendRecvMessage();
+
+
+
+ public: // Member functions
+
+ // Member function to send the message.
+ TInt SendMessage( const char *contact_id, const char *message,
+ CTestData* aTestData );
+
+ TInt ReceiveMessage(const char *contact_id, const char *message,
+ CTestData* aTestData );
+
+
+ public : //Callback functions
+
+ //Callback function for sendmessage
+ static void sendmessage_cb( DBusGProxy *proxy, GError *error, gpointer userdata );
+
+
+ //Callback for receive message
+ static void receivedMessage_cb ( DBusGProxy *proxy,guint message_id,
+ guint timestamp,guint from_handle,
+ guint message_type,guint message_flags,
+ gchar *message_body,gpointer user_data );
+
+
+ static void SendError_cb ( DBusGProxy *proxy,
+ guint error,
+ guint timestamp,
+ guint message_type,
+ gchar *message_body,
+ gpointer user_data ) ;
+
+
+ //Callback for the text_channel_find for a particular contact_id.
+ static gboolean text_channels_find_func(gchar *key,TpChan *text_channel, guint *contact_handle);
+
+
+ };
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabbletest.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,238 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: For Stif fw related functions.
+*
+*/
+
+
+
+
+
+#ifndef TELEPATHYGABBLETEST_H
+#define TELEPATHYGABBLETEST_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <glib.h>
+
+
+
+// Logging path
+_LIT( KTelepathyGabbleTestLogPath, "\\logs\\testframework\\TelepathyGabbleTest\\" );
+// Log file
+_LIT( KTelepathyGabbleTestLogFile, "TelepathyGabbleTest.txt" );
+_LIT( KTelepathyGabbleTestLogFileWithTitle, "TelepathyGabbleTest_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+class CTelepathyGabbleTest;
+
+class CTelepathyGabbleLoginTest;
+class CTelepathyGabbleSendRecvMessage;
+class CTelepathyGabbleAddDeleteContact;
+class CTelepathyGabbleFetchContacts;
+class CTelepathyGabbleSearch;
+class CTestData;
+
+
+// CLASS DECLARATION
+
+/**
+* CTelepathyGabbleTest test class for STIF Test Framework TestScripter.
+* ?other_description_lines
+*
+* @lib ?library
+* @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CTelepathyGabbleTest) : public CScriptBase
+ {
+ public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static CTelepathyGabbleTest* NewL( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * Destructor.
+ */
+ virtual ~CTelepathyGabbleTest();
+
+ public: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+
+ public: // Functions from base classes
+
+ /**
+ * From CScriptBase Runs a script line.
+ * @since ?Series60_version
+ * @param aItem Script line containing method name and parameters
+ * @return Symbian OS error code
+ */
+ virtual TInt RunMethodL( CStifItemParser& aItem );
+
+ protected: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ protected: // Functions from base classes
+
+
+ private:
+
+ /**
+ * C++ default constructor.
+ */
+ CTelepathyGabbleTest( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ // Prohibit copy constructor if not deriving from CBase.
+ // ?classname( const ?classname& );
+ // Prohibit assigment operator if not deriving from CBase.
+ // ?classname& operator=( const ?classname& );
+
+ /**
+ * Frees all resources allocated from test methods.
+ * @since ?Series60_version
+ */
+ void Delete();
+
+ /**
+ * Test methods are listed below.
+ */
+
+ /**
+ * Example test method.
+ * @since ?Series60_version
+ * @param aItem Script line containing parameters.
+ * @return Symbian OS error code.
+ */
+ //virtual TInt ExampleL( CStifItemParser& aItem );
+ //ADD NEW METHOD DEC HERE
+ //[TestMethods] - Do not remove
+
+
+ //Login
+ virtual TInt LoginTestL( CStifItemParser& aItem );
+
+ //Logout
+ virtual TInt LogoutTestL(CStifItemParser& aItem );
+
+ //Login related other test cases
+
+ virtual TInt LoginInvalidUseridTestL( CStifItemParser& aItem );
+ virtual TInt LoginInvalidPasswdTestL( CStifItemParser& aItem );
+ virtual TInt LoginInvalidUseridPasswdTestL( CStifItemParser& aItem );
+ virtual TInt LoginblankUseridTestL( CStifItemParser& aItem ) ;
+ virtual TInt LoginblankPasswdTestL( CStifItemParser& aItem );
+ virtual TInt LoginblankUseridblankPasswdTestL( CStifItemParser& aItem );
+ virtual TInt LoginCancelTestL( CStifItemParser& aItem );
+
+
+
+ //Send Message
+ virtual TInt SendMessageTestL(CStifItemParser& aItem );
+ virtual TInt SendMessageWith400TestL(CStifItemParser& aItem );
+ virtual TInt SendMesasgeBlankTestL( CStifItemParser& aItem );
+ virtual TInt SendMesasgeToBlankUserIdTestL( CStifItemParser& aItem );
+ virtual TInt SendMessageRepeatedTestL( CStifItemParser& aItem );
+ virtual TInt SendMessagetoinvalidUseridTestL( CStifItemParser& aItem );
+
+
+ //Receive Message
+ virtual TInt ReceiveMessageTestL(CStifItemParser& aItem);
+ virtual TInt ReceiveMessageMaxLengthTestL(CStifItemParser& aItem);
+ virtual TInt ReceiveMessageBlankTestL(CStifItemParser& aItem);
+ virtual TInt ReceiveRepeatedMessageTestL(CStifItemParser& aItem);
+
+
+ //Add Contact related test cases
+ virtual TInt AddContactTestL(CStifItemParser& aItem);
+ virtual TInt AddContactWithBlankUserIdTestL(CStifItemParser& aItem);
+ virtual TInt AddContactAlreadyInRosterTestL(CStifItemParser& aItem);
+
+ //Remove Contact related test cases
+ virtual TInt RemoveContactTestL(CStifItemParser& aItem );
+ virtual TInt RemoveInvalidContactTestL( CStifItemParser& aItem );
+ virtual TInt RemoveContactAlreadyRemovedTestL( CStifItemParser& aItem );
+ virtual TInt RemoveContactWithBlankUserIdTestL( CStifItemParser& aItem );
+
+ //Fetch Contact related test cases
+ virtual TInt FetchContactsTestL(CStifItemParser& aItem );
+
+ //Search related test cases
+ virtual TInt SearchTestL(CStifItemParser& aItem );
+ virtual TInt GetSearchKeysTestL(CStifItemParser& aItem );
+ virtual TInt SearchWithAllKeysTestL( CStifItemParser& aItem );
+
+ virtual TInt SearchTwoInvalidKeysTestL( CStifItemParser& aItem );
+ virtual TInt SearchInvalidKeyTestL(CStifItemParser& aItem );
+ virtual TInt SearchNoKeyValueTestL(CStifItemParser& aItem );
+ virtual TInt SearchBlankStringTestL(CStifItemParser& aItem );
+ virtual TInt SearchAfterGetSearchKeysL( CStifItemParser& aItem );
+ virtual TInt SearchTwiceTestL( CStifItemParser& aItem );
+ virtual TInt SearchFiveTimesTestL( CStifItemParser& aItem );
+ virtual TInt SearchTwiceWithDiffStringsTestL( CStifItemParser& aItem );
+
+
+ gchar* GetSearchLabelForGizmoL(gchar* search_key);
+ gchar* GetSearchLabelForYukonL(gchar* search_key);
+ gchar* GetSearchLabelL(gchar* aService,gchar* aSearchKey);
+ /*static gboolean search_hash_remove( gpointer key, gpointer value,
+ gpointer user_data );*/
+
+
+ private: //Some data members
+
+ //Login class object
+ CTelepathyGabbleLoginTest *iLoginObj;
+ //Send Message class object
+ CTelepathyGabbleSendRecvMessage *iSendMsgObj;
+
+ //used for adding/deleting contact
+ CTelepathyGabbleAddDeleteContact *iAddDelContactObj;
+
+ //used for fetching contacts
+ CTelepathyGabbleFetchContacts *iFetchContactObj;
+
+ //used for searching contacts
+ CTelepathyGabbleSearch *iSearchObj;
+ CTestData* iTestData;
+
+ };
+
+#endif // TELEPATHYGABBLETEST_H
+
+// End of File
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabbletestdata.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: test utility for having the global data
+*
+*/
+
+
+
+#ifndef __TELEPATHYGABBLETESTDATA_H__
+#define __TELEPATHYGABBLETESTDATA_H__
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+
+
+
+#include <pthread.h>
+
+#define VERBOSE
+
+
+#define CONNMGR_NAME "telepathy-gabble"
+#define CONNMGR_BUS "org.freedesktop.Telepathy.ConnectionManager.gabble"
+#define CONNMGR_PATH "/org/freedesktop/Telepathy/ConnectionManager/gabble"
+#define CHANNEL_BUS "org.freedesktop.Telepathy.Channel.Type.Text"
+#define CHANNEL_PATH "/org/freedesktop/Telepathy/Channel/Type/Text"
+#define PROTOCOL "jabber"
+
+class CStifLogger;
+
+class CTestData : public CBase
+{
+ public:
+ enum TConnectionState
+ {
+ ECONNECTED =0,
+ EDISCONNECTED,
+ ECONNECTING,
+ };
+ enum TTestType
+ {
+ ELogin = 0,
+ ECancel,
+ ESend,
+ ESendErr,
+ EReceive,
+ ERecvBlank,
+ EGetSearchKeys,
+ ESearch,
+ EOther
+ };
+ enum TSendRecvState
+ {
+ EMessageNotSent =0,
+ EMessageSent,
+ EMessageRecvd,
+ EMessageRecvErr,
+ EMessageSendErr
+ };
+
+ enum TAddDeleteContactStatus
+ {
+ EADD_SUCCESS =0,
+ EADD_FAIL ,
+ EDELETE_SUCCESS,
+ EDELETE_FAIL
+ };
+
+
+ enum TSearchState
+ {
+ ESearchStarted =0,
+ ESearchError ,
+ ESearchCompleted,
+ ESearchKeysFound
+ };
+
+ private:
+ /**
+ * C++ default constructor.
+ */
+
+ CTestData( CStifLogger* aLogger );
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ public: // Constructors and destructor
+ /**
+ * Two-phased constructor.
+ */
+ static CTestData* NewL( CStifLogger* aLogger );
+
+ /**
+ * Destructor.
+ */
+ ~CTestData();
+
+
+
+public://Set funtions
+
+ DBusGProxy* GetGroupSubscribeInterface();
+ DBusGProxy* GetGroupPublishInterface();
+ DBusGProxy* GetGroupKnownInterface();
+ DBusGProxy* GetGroupDenyInterface();
+ GMainLoop* GetMainLoop();
+ GHashTable* GetTextChannelsHT();
+ DBusGConnection* GetDBusConnection();
+ TpConn* GetTpConn();
+ TTestType GetTestType();
+ TInt GetLoginCompleteFlag();
+ TInt GetTotalFetchCount();
+ TInt GetLastIndexInFetch();
+ TConnectionState GetConnectionState();
+ TSendRecvState GetSendRecvMsgState();
+ TAddDeleteContactStatus GetAddDeleteContactStatus();
+ CStifLogger* GetStifLogger();
+ TSearchState GetSearchState();
+
+ void SetGroupSubscribeInterface( DBusGProxy* aGroupSubscribeInterface );
+ void SetGroupPublishInterface( DBusGProxy* aGroupPublishInterface );
+ void SetGroupKnownInterface( DBusGProxy* aGroupKnownInterface );
+ void SetGroupDenyInterface( DBusGProxy* aGroupDenyInterface );
+ void SetTextChannelsHT( GHashTable* aTextChannelHashTable );
+ void IncLoginCompleteFlag();
+ void ResetLoginCompleteFlag();
+ void SetTotalFetchCount( TInt aValue );
+ void SetLastIndexInFetch( TInt aLastIndex );
+ void SetConnectionState( TConnectionState aloginState );
+ void SetTestType( TTestType aTestType );
+ void SetSendRecvMsgState( TSendRecvState aSendRecvState );
+ void SetAddDeleteContactStatus(TAddDeleteContactStatus aAddDeleteContactStatus);
+ void SetTpConn(TpConn* aTpConn);
+ void SetTpConnMgr(TpConnMgr* aTpConnMgr);
+ void SetDBusConnection( DBusGConnection* aDBusConnection );
+ void SetSearchState(TSearchState aSearchState);
+ void SetSearchKeys( gchar **aKeys );
+ gchar** GetSearchKeys( );
+ void SetSearchChan(TpChan* aSearchChan );
+ TpChan* GetSearchChan( );
+
+private://Data members
+
+ GMainLoop *iMainLoop;
+
+ //Hash Table for the text channels.
+ GHashTable *iTextChannelHashTable;
+
+ TpConn *iTpConn;
+
+ TpConnMgr *iTpConnMgr;
+
+ //Global dbus-connection object
+ DBusGConnection *iDBusConnection;
+
+
+ DBusGProxy *iGroupSubscribeInterface; //used for adding a contact
+ DBusGProxy *iGroupKnownInterface; //used for removing a contact
+ DBusGProxy *iGroupPublishInterface; //gives local pending members
+ DBusGProxy *iGroupDenyInterface; //used to deny the contacts.
+
+ TInt iLoginComplete;
+ TInt iTotalFetchCount;
+ TConnectionState iConnectionState;
+ TSendRecvState iSendRecvState;
+ TAddDeleteContactStatus iAddDeleteContactStatus;
+ TSearchState iSearchState;
+ TTestType iTestType;
+
+ CStifLogger *iLogger;
+
+ //Used in Fetch Contacts Test Case
+ TInt iLastIndex;
+ gchar** iSearchKeys;
+
+ TpChan* iSearchChan;
+};//End of class
+
+#endif //__TELEPATHYGABBLETESTDATA_H__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/inc/telepathygabbleutils.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Utility class for telepathy Test Cases.
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <glib.h>
+
+#ifndef DBUS_API_SUBJECT_TO_CHANGE
+#define DBUS_API_SUBJECT_TO_CHANGE
+#endif
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+
+#include <unistd.h>
+
+#include "tp-conn.h"
+#include "tp-connmgr.h"
+#include "tp-chan.h"
+#include "tp-chan-gen.h"
+#include "tp-ch-gen.h"
+#include "tp-chan-iface-group-gen.h"
+#include "tp-chan-type-text-gen.h"
+#include "tp-chan-type-streamed-media-gen.h"
+#include "tp-props-iface.h"
+#include "tp-constants.h"
+#include "tp-interfaces.h"
+
+#include <pthread.h>
+
+// FORWARD DECLARATION
+class CTestData;
+
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS(CTelepathyGabbleUtils)
+ {
+
+
+ public: // static Member functions
+ static guint get_handle_from_contact ( const gchar *contact_id,
+ CTestData* aTestData);
+
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/init/TestFramework.ini Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,44 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Engine_Defaults]
+
+TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment',
+ 'TestCases' or 'FullReport'
+
+CreateTestReport= YES # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT # Possible values: TXT or HTML
+TestReportOutput= FILE # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\telepathygabbletest.cfg
+[End_Module]
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Logger_Defaults]
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathy-presence.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,459 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Presence related Test Cases
+*
+*/
+
+
+
+
+//#include "config.h"
+
+#include <string.h>
+#include "telepathy-presence.h"
+//#include "telepathy-time.h"
+
+//#include <glib/gi18n.h> //below code is replacement of this header
+//+++++++++++++++++++++++++++++++++++++++++++++++++
+#include <glib/gstrfuncs.h>
+
+#define _(String) gettext (String)
+#define Q_(String) g_strip_context ((String), gettext (String))
+#ifdef gettext_noop
+#define N_(String) gettext_noop (String)
+#else
+#define N_(String) (String)
+#endif
+//++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+
+
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TELEPATHY_TYPE_PRESENCE, TelepathyPresencePriv))
+
+
+typedef long TelepathyTime; /* Note: Always in UTC. */
+typedef struct _TelepathyPresencePriv TelepathyPresencePriv;
+
+struct _TelepathyPresencePriv {
+ TelepathyPresenceState state;
+
+ gchar *status;
+ gchar *resource;
+
+ gint priority;
+ TelepathyTime timestamp;
+};
+
+static void presence_finalize (GObject *object);
+static void presence_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void presence_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+enum {
+ PROP_0,
+ PROP_STATE,
+ PROP_STATUS,
+ PROP_RESOURCE,
+ PROP_PRIORITY
+};
+
+G_DEFINE_TYPE (TelepathyPresence, telepathy_presence, G_TYPE_OBJECT);
+
+TelepathyTime
+telepathy_time_get_current (void)
+{
+ return time (NULL);
+}
+
+static void
+telepathy_presence_class_init (TelepathyPresenceClass *class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = presence_finalize;
+ object_class->get_property = presence_get_property;
+ object_class->set_property = presence_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_STATE,
+ g_param_spec_int ("state",
+ "Presence State",
+ "The current state of the presence",
+ TELEPATHY_PRESENCE_STATE_AVAILABLE,
+ TELEPATHY_PRESENCE_STATE_EXT_AWAY,
+ TELEPATHY_PRESENCE_STATE_AVAILABLE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_STATUS,
+ g_param_spec_string ("status",
+ "Presence Status",
+ "Status string set on presence",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_RESOURCE,
+ g_param_spec_string ("resource",
+ "Presence Resource",
+ "Resource that this presence is for",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_PRIORITY,
+ g_param_spec_int ("priority",
+ "Presence Priority",
+ "Priority value of presence",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof (TelepathyPresencePriv));
+}
+
+static void
+telepathy_presence_init (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (presence);
+
+ priv->state = TELEPATHY_PRESENCE_STATE_AVAILABLE;
+
+ priv->status = NULL;
+ priv->resource = NULL;
+
+ priv->priority = 0;
+
+ priv->timestamp = telepathy_time_get_current ();
+}
+
+static void
+presence_finalize (GObject *object)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ g_free (priv->status);
+ g_free (priv->resource);
+
+ (G_OBJECT_CLASS (telepathy_presence_parent_class)->finalize) (object);
+}
+
+static void
+presence_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_STATE:
+ g_value_set_int (value, priv->state);
+ break;
+ case PROP_STATUS:
+ g_value_set_string (value,
+ telepathy_presence_get_status (TELEPATHY_PRESENCE (object)));
+ break;
+ case PROP_RESOURCE:
+ g_value_set_string (value,
+ telepathy_presence_get_resource (TELEPATHY_PRESENCE (object)));
+ break;
+ case PROP_PRIORITY:
+ g_value_set_int (value, priv->priority);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+static void
+presence_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_STATE:
+ priv->state = g_value_get_int (value);
+ break;
+ case PROP_STATUS:
+ telepathy_presence_set_status (TELEPATHY_PRESENCE (object),
+ g_value_get_string (value));
+ break;
+ case PROP_RESOURCE:
+ telepathy_presence_set_resource (TELEPATHY_PRESENCE (object),
+ g_value_get_string (value));
+ break;
+ case PROP_PRIORITY:
+ priv->priority = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+TelepathyPresence *
+telepathy_presence_new (void)
+{
+ return g_object_new (TELEPATHY_TYPE_PRESENCE, NULL);
+}
+
+TelepathyPresence *
+telepathy_presence_new_full (TelepathyPresenceState state,
+ const gchar *status)
+{
+ return g_object_new (TELEPATHY_TYPE_PRESENCE,
+ "state", state,
+ "status", status,
+ NULL);
+}
+
+const gchar *
+telepathy_presence_get_resource (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (presence), NULL);
+
+ priv = GET_PRIV (presence);
+
+ if (priv->resource) {
+ return priv->resource;
+ }
+
+ return NULL;
+}
+
+const gchar *
+telepathy_presence_get_status (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ /*g_return_val_if_fail (TELEPATHY_IS_PRESENCE (presence),
+ _("Offline"));*/
+
+ priv = GET_PRIV (presence);
+
+ return priv->status;
+}
+
+gint
+telepathy_presence_get_priority (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (presence);
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (presence), 0);
+
+ return priv->priority;
+}
+
+void
+telepathy_presence_set_resource (TelepathyPresence *presence,
+ const gchar *resource)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_if_fail (TELEPATHY_IS_PRESENCE (presence));
+ g_return_if_fail (resource != NULL);
+
+ priv = GET_PRIV (presence);
+
+ g_free (priv->resource);
+ priv->resource = g_strdup (resource);
+
+ g_object_notify (G_OBJECT (presence), "resource");
+}
+
+TelepathyPresenceState
+telepathy_presence_get_state (TelepathyPresence *presence)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (presence),
+ TELEPATHY_PRESENCE_STATE_AVAILABLE);
+
+ priv = GET_PRIV (presence);
+
+ return priv->state;
+}
+
+void
+telepathy_presence_set_state (TelepathyPresence *presence,
+ TelepathyPresenceState state)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_if_fail (TELEPATHY_IS_PRESENCE (presence));
+
+ priv = GET_PRIV (presence);
+
+ priv->state = state;
+
+ g_object_notify (G_OBJECT (presence), "state");
+}
+
+void
+telepathy_presence_set_status (TelepathyPresence *presence,
+ const gchar *status)
+{
+ TelepathyPresencePriv *priv;
+
+ priv = GET_PRIV (presence);
+ g_return_if_fail (TELEPATHY_IS_PRESENCE (presence));
+
+ g_free (priv->status);
+
+ if (status) {
+ priv->status = g_strdup (status);
+ } else {
+ priv->status = NULL;
+ }
+
+ g_object_notify (G_OBJECT (presence), "status");
+}
+
+void
+telepathy_presence_set_priority (TelepathyPresence *presence,
+ gint priority)
+{
+ TelepathyPresencePriv *priv;
+
+ g_return_if_fail (TELEPATHY_IS_PRESENCE (presence));
+
+ priv = GET_PRIV (presence);
+
+ priv->priority = priority;
+
+ g_object_notify (G_OBJECT (presence), "priority");
+}
+
+gboolean
+telepathy_presence_resource_equal (gconstpointer a,
+ gconstpointer b)
+{
+ TelepathyPresencePriv *priv1;
+ TelepathyPresencePriv *priv2;
+
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (a), FALSE);
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (b), FALSE);
+
+ priv1 = GET_PRIV (a);
+ priv2 = GET_PRIV (b);
+
+ if (!priv1->resource) {
+ if (!priv2->resource) {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ if (!priv2->resource) {
+ return FALSE;
+ }
+
+ if (strcmp (priv1->resource, priv2->resource) == 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gint
+telepathy_presence_sort_func (gconstpointer a,
+ gconstpointer b)
+{
+ TelepathyPresencePriv *priv_a;
+ TelepathyPresencePriv *priv_b;
+ gint diff;
+
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (a), 0);
+ g_return_val_if_fail (TELEPATHY_IS_PRESENCE (b), 0);
+
+ /* We sort here by priority AND status, in theory, the
+ * priority would be enough for JUST Jabber contacts which
+ * actually abide to the protocol, but for other protocols and
+ * dodgy clients, we will sort by:
+ *
+ * 1. State
+ * 2. Priority
+ * 3. Time it was set (most recent first).
+ */
+
+ priv_a = GET_PRIV (a);
+ priv_b = GET_PRIV (b);
+
+ /* 1. State */
+ diff = priv_a->state - priv_b->state;
+ if (diff != 0) {
+ return diff < 1 ? -1 : +1;
+ }
+
+ /* 2. Priority */
+ diff = priv_a->priority - priv_b->priority;
+ if (diff != 0) {
+ return diff < 1 ? -1 : +1;
+ }
+
+ /* 3. Time (newest first) */
+ diff = priv_b->timestamp - priv_a->timestamp;
+ if (diff != 0) {
+ return diff < 1 ? -1 : +1;
+ }
+
+ /* No real difference, except maybe resource */
+ return 0;
+}
+
+
+/*static*/ const gchar *
+telepathy_presence_state_to_str (TelepathyPresenceState presence_state)
+{
+ switch (presence_state) {
+ case TELEPATHY_PRESENCE_STATE_AVAILABLE:
+ return "available";
+ case TELEPATHY_PRESENCE_STATE_BUSY:
+ return "dnd";
+ case TELEPATHY_PRESENCE_STATE_AWAY:
+ return "away";
+ case TELEPATHY_PRESENCE_STATE_EXT_AWAY:
+ return "xa";
+ case TELEPATHY_PRESENCE_STATE_HIDDEN:
+ return "hidden";
+ case TELEPATHY_PRESENCE_STATE_UNAVAILABLE:
+ return "offline";
+ default:
+ return NULL;
+ }
+
+ return NULL;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabbleadddeletecontact.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,316 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Contact management(add/delete etc) related Test Cases
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+#include <glib.h>
+#include <StifLogger.h>
+
+#include "telepathygabbleutils.h"
+#include "telepathygabbleadddeletecontact.h"
+#include "telepathygabblelogintest.h"
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTelepathyGabbleAddDeleteContact
+// description : constructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleAddDeleteContact::CTelepathyGabbleAddDeleteContact()
+{
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : constructor
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleAddDeleteContact::ConstructL()
+{
+ //do nothing
+}
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : constructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleAddDeleteContact* CTelepathyGabbleAddDeleteContact::NewL()
+{
+ CTelepathyGabbleAddDeleteContact* self = new(ELeave) CTelepathyGabbleAddDeleteContact;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+}
+
+// Destructor
+//-----------------------------------------------------------------------------
+// function_name : ~CTelepathyGabbleAddDeleteContact
+// description : Destructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleAddDeleteContact::~CTelepathyGabbleAddDeleteContact()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : add_contact
+// description : adding a contact
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleAddDeleteContact::add_contact ( const gchar *contact_id,
+ const gchar *message,
+ CTestData* aTestData )
+{
+ guint handle;
+ GArray *handles = NULL;
+ //gpointer userdata = (gpointer)contact_id;
+
+ //first check the contact_id.
+ if( contact_id == NULL )
+ {
+ return CTestData::EADD_FAIL;
+ }
+
+ aTestData->SetAddDeleteContactStatus(CTestData::EADD_FAIL);
+
+ //acess the utils class function to get the contact handle.
+ handle = CTelepathyGabbleUtils::get_handle_from_contact ( contact_id, aTestData );
+
+ if ( handle == KErrNotFound )
+ {
+ return CTestData::EADD_FAIL;
+ }
+
+ handles = g_array_new (FALSE, FALSE, sizeof (guint));
+
+ g_array_append_val (handles, handle);
+
+ DBusGProxy *group_iface_subscribe = aTestData->GetGroupSubscribeInterface();
+ DBusGProxy *group_iface_publish = aTestData->GetGroupPublishInterface();
+ DBusGProxy *group_iface_known = aTestData->GetGroupKnownInterface();
+
+
+ //register the callback, commented for now.
+ dbus_g_proxy_connect_signal (group_iface_subscribe, "MembersChanged",
+ G_CALLBACK (roster_members_changed_cb ),
+ aTestData, NULL);
+
+ dbus_g_proxy_connect_signal (group_iface_publish, "MembersChanged",
+ G_CALLBACK (roster_members_changed_cb ),
+ aTestData, NULL);
+
+
+ dbus_g_proxy_connect_signal (group_iface_known, "MembersChanged",
+ G_CALLBACK (roster_members_changed_cb ),
+ aTestData, NULL);
+
+
+ tp_chan_iface_group_add_members_async ( group_iface_subscribe, handles, message, add_contact_cb, aTestData );
+
+ //Start the main loop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+ g_array_free (handles, TRUE);
+
+ //return the status was updated in the callback.
+ return aTestData->GetAddDeleteContactStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+// function_name : remove_contact
+// description : remove the contact.
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleAddDeleteContact::remove_contact ( const gchar *contact_id,
+ const gchar *message,
+ CTestData* aTestData
+ )
+{
+
+ guint handle;
+ GArray *handles = NULL;
+
+ //first check the contact_id.
+ if( contact_id == NULL )
+ {
+ return CTestData::EDELETE_FAIL;
+ }
+
+ aTestData->SetAddDeleteContactStatus( CTestData::EDELETE_FAIL );
+
+ handle = CTelepathyGabbleUtils::get_handle_from_contact ( contact_id, aTestData);
+
+ if ( handle == KErrNotFound )
+ {
+ return CTestData::EDELETE_FAIL;
+ }
+
+
+ DBusGProxy *group_iface_known = aTestData->GetGroupKnownInterface();
+
+ handles = g_array_new (FALSE, FALSE, sizeof (guint));
+
+ g_array_append_val (handles, handle);
+
+ tp_chan_iface_group_remove_members_async ( group_iface_known, handles, message, remove_contact_cb, aTestData );
+
+ //Start the main loop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+ g_array_free (handles, TRUE);
+
+ return (aTestData->GetAddDeleteContactStatus());
+}
+
+
+//-----------------------------------------------------------------------------
+// function_name : add_contact_cb
+// description :Callback for add contact
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleAddDeleteContact::add_contact_cb( DBusGProxy* /*proxy*/, GError* error, gpointer userdata )
+{
+ CTestData* testdata = static_cast<CTestData*> (userdata);
+ if ( !error )
+ {
+ testdata->SetAddDeleteContactStatus(CTestData::EADD_SUCCESS);
+ }
+ else
+ {
+ testdata->SetAddDeleteContactStatus(CTestData::EADD_FAIL);
+
+ }
+
+ //Quit the main loop
+ g_main_loop_quit(testdata->GetMainLoop());
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : remove_contact_cb
+// description : Callback for remove contact.
+//-----------------------------------------------------------------------------
+
+void CTelepathyGabbleAddDeleteContact::remove_contact_cb( DBusGProxy* proxy, GError *error, gpointer userdata )
+{
+
+ CTestData* testdata = static_cast<CTestData*> (userdata);
+ if ( error )
+ {
+ testdata->GetStifLogger()->Log( _L("CTelepathyGabbleTest::deleting already removed contact,it should give some error \n") );
+ testdata->SetAddDeleteContactStatus( CTestData::EDELETE_FAIL );
+ }
+ else
+ {
+ testdata->GetStifLogger()->Log( _L("CTelepathyGabbleTest::deleted successfully \n") );
+ testdata->SetAddDeleteContactStatus( CTestData::EDELETE_SUCCESS );
+ }
+ //Quit the main loop started in Delete contact.
+ g_main_loop_quit(testdata->GetMainLoop());
+}
+
+//-----------------------------------------------------------------------------
+// function_name : roster_members_changed_cb
+// description : Callback for change in the contacts.
+//-----------------------------------------------------------------------------
+
+void CTelepathyGabbleAddDeleteContact::roster_members_changed_cb (DBusGProxy* /*group_iface*/,
+ gchar* /*message */,
+ GArray *added,
+ GArray *removed,
+ GArray *local_pending,
+ GArray *remote_pending,
+ guint /*actor*/,
+ guint /*reason*/,
+ gpointer userdata)
+{
+
+ gchar **contact_name = NULL;
+
+
+
+ CTestData* atestData = static_cast<CTestData*> (userdata);
+
+ //TInt return_value = KErrNone;
+
+
+
+ if (added->len > 0)
+ {
+
+ //this is not working, use async api later
+ /*tp_conn_inspect_handles( DBUS_G_PROXY(atestData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,added,
+ &contact_name,NULL);*/
+ if(contact_name)
+ {
+ //The contact has been added.
+ // Must verify this against the contact_name for which the request was sent?
+ // This will depend on whether we will hit callback for one contact at a time
+ // or multiple callbacks for all contacts at a single time. ?
+ //return_value = KErrNone;
+ //atestData->SetAddDeleteContactStatus(CTestData::EADD_SUCCESS);
+
+ }
+ }
+ if (removed->len > 0)
+ {
+ /*tp_conn_inspect_handles( DBUS_G_PROXY(atestData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,removed,
+ &contact_name,NULL);*/
+ if(contact_name)
+ {
+ //The contact_name was deleted
+ //Must verify this against the contact_name for which the request was sent?
+ //return_value == KErrNone;
+ }
+ }
+ if (local_pending->len > 0)
+ {
+ /*tp_conn_inspect_handles( DBUS_G_PROXY(atestData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,local_pending,
+ &contact_name,NULL);*/
+ if(contact_name)
+ {
+ //what should be tested here ?
+ //like what is next action expected ?
+ //since the contact is still local_pending, is the test case failed ?
+ //return_value = KErrNone;
+ //atestData->GetAddDeleteContactStatus();
+ }
+
+ }
+ if (remote_pending->len > 0)
+ {
+ /*tp_conn_inspect_handles( DBUS_G_PROXY(atestData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,remote_pending,
+ &contact_name,NULL);*/
+ if(contact_name)
+ {
+ //return_value = KErrNone;
+ //atestData->GetAddDeleteContactStatus();
+ }
+
+ }
+
+ //dont quit from here right now.
+}
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabblefetchcontacts.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,246 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Fetch contacts related Test Cases
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+#include <glib.h>
+
+#include "telepathygabblefetchcontacts.h"
+#include "telepathygabbletestdata.h"
+
+
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTelepathyGabbleFetchContacts
+// description : constructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleFetchContacts::CTelepathyGabbleFetchContacts()
+{
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : constructor
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleFetchContacts::ConstructL()
+{
+ //do nothing
+}
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : constructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleFetchContacts* CTelepathyGabbleFetchContacts::NewL()
+ {
+
+ CTelepathyGabbleFetchContacts* self = new(ELeave) CTelepathyGabbleFetchContacts;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTelepathyGabbleFetchContacts
+// description : Destructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleFetchContacts::~CTelepathyGabbleFetchContacts()
+ {
+
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : test_request_roster
+// description : Function for fetching the contacts.
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleFetchContacts::test_request_roster( CTestData* aTestData )
+{
+
+ DBusGProxy * group_iface_subscribe = aTestData->GetGroupSubscribeInterface();
+
+ tp_chan_iface_group_get_all_members_async(group_iface_subscribe, get_roster_member_cb, aTestData);
+
+ //Run the mainloop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+ //retrun some error code here
+ if ( aTestData->GetTotalFetchCount() != KErrGeneral )
+ {
+ return KErrNone;
+ }
+ else
+ {
+ return KErrGeneral;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// function_name : get_roster_member_cb
+// description : callback for getting the roster member.
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleFetchContacts::get_roster_member_cb( DBusGProxy* /*proxy*/,GArray* current_members, GArray* local_pending_members, GArray* remote_pending_members, GError* /*error*/, gpointer userdata )
+{
+ guint fetch_count=0;
+ guint fetch_loop_count=0;
+ GArray* fetch_members = NULL;
+ guint i;
+ guint total_len =0;
+ CTestData* testData = static_cast<CTestData*> (userdata);
+
+
+ total_len = current_members->len + local_pending_members->len + remote_pending_members->len;
+
+ testData->SetTotalFetchCount(total_len);
+
+ if( !total_len )
+ {
+ g_main_loop_quit(testData->GetMainLoop());
+ return;
+
+ }
+
+ fetch_members = g_array_new (FALSE, FALSE, sizeof (guint32));
+
+
+ if( current_members->len > 0)
+ {
+ fetch_count = 0;
+ fetch_loop_count = (current_members->len) / KMaxContactFetchCount + ( (current_members->len % KMaxContactFetchCount)? 1 : 0);
+
+ for( i=0; i<fetch_loop_count; i++ )
+ {
+
+ g_array_remove_range(fetch_members,0,fetch_count);
+
+ fetch_count = (current_members->len <= KMaxContactFetchCount)? current_members->len : KMaxContactFetchCount;
+
+ g_array_append_vals (fetch_members,current_members->data,fetch_count);
+
+ g_array_remove_range(current_members,0,fetch_count);
+
+ //we will quit the main loop in inspect_handles_cb
+ tp_conn_inspect_handles_async( DBUS_G_PROXY(testData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,fetch_members,
+ inspect_handles_cb,userdata);
+ }
+ }
+
+ if( local_pending_members->len > 0)
+ {
+ fetch_count = 0;
+
+ g_array_remove_range(fetch_members,0,fetch_members->len);
+
+ fetch_loop_count = (local_pending_members->len) / KMaxContactFetchCount + ( (local_pending_members->len % KMaxContactFetchCount)? 1 : 0);
+
+ for( i=0; i<fetch_loop_count; i++ )
+ {
+
+ g_array_remove_range(fetch_members,0,fetch_count);
+
+ fetch_count = (local_pending_members->len <= KMaxContactFetchCount)? local_pending_members->len : KMaxContactFetchCount;
+
+
+ g_array_append_vals (fetch_members,local_pending_members->data,fetch_count);
+
+ g_array_remove_range(local_pending_members,0,fetch_count);
+
+ tp_conn_inspect_handles_async( DBUS_G_PROXY(testData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,fetch_members,
+ inspect_handles_cb,userdata);
+ }
+
+ }
+
+ if( remote_pending_members->len > 0)
+ {
+ fetch_count = 0;
+ g_array_remove_range(fetch_members,0,fetch_members->len);
+ fetch_loop_count = (remote_pending_members->len) / KMaxContactFetchCount + ( (remote_pending_members->len % KMaxContactFetchCount)? 1 : 0);
+
+ for( i=0; i<fetch_loop_count; i++ )
+ {
+
+ g_array_remove_range(fetch_members,0,fetch_count);
+
+ fetch_count = (remote_pending_members->len <= KMaxContactFetchCount)? remote_pending_members->len : KMaxContactFetchCount;
+
+ g_array_append_vals (fetch_members,remote_pending_members->data,fetch_count);
+ g_array_remove_range(remote_pending_members,0,fetch_count);
+ tp_conn_inspect_handles_async( DBUS_G_PROXY(testData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT ,fetch_members,
+ inspect_handles_cb,userdata);
+ }
+
+ }
+ return;
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : inspect_handles_cb
+// description : inspect the handle for the contact, return the contact handle
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleFetchContacts::inspect_handles_cb( DBusGProxy* /*proxy*/,char **handles_names,
+ GError *error, gpointer userdata )
+{
+ CTestData* testData = static_cast<CTestData*> (userdata);
+ TInt last_index = testData->GetLastIndexInFetch();
+ guint total_len = testData->GetTotalFetchCount();
+
+ if(!last_index)
+ {
+ //allmembers_names = g_new0 ( char *, total_len + 1);
+ }
+
+ if(!handles_names || error )
+ {
+ //error condition in inspect_handles_cb
+ testData->SetTotalFetchCount(KErrGeneral);
+ g_main_loop_quit(testData->GetMainLoop());
+ return;
+ }
+
+ for( TInt i=0; handles_names[i]; i++ )
+ {
+
+ //handle_names can be logged to the log file
+ last_index++;
+ }
+
+ testData->SetLastIndexInFetch(last_index);
+
+ if (last_index == total_len )
+ {
+ //inspect_handle_cb for all the contacts has been receieved.
+ //Quit the main loop.
+
+ //Set the flag that inspect_handles_cb has been completed successfully.
+ g_main_loop_quit(testData->GetMainLoop());
+ }
+
+ return ;
+}
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabblelogintest.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,680 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Login-Logout related Test Cases
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <glib.h>
+#include <StifLogger.h>
+
+#include "telepathygabbleutils.h"
+#include "telepathygabblelogintest.h"
+#include "telepathygabbletestdata.h"
+#include "telepathygabbleadddeletecontact.h"
+
+static void test_log_handler1 (
+ const gchar *message
+ )
+{
+ FILE* fp;
+
+ fp = fopen("c:\\tplogs.txt","a");
+ if(fp)
+ {
+ fprintf(fp,message);
+ fprintf(fp,"\n");
+ fclose(fp);
+ }
+
+
+}
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTelepathyGabbleLoginTest
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+
+CTelepathyGabbleLoginTest::CTelepathyGabbleLoginTest()
+ {
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+
+void CTelepathyGabbleLoginTest::ConstructL()
+ {
+
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+CTelepathyGabbleLoginTest* CTelepathyGabbleLoginTest::NewL()
+ {
+
+ CTelepathyGabbleLoginTest* self = new(ELeave) CTelepathyGabbleLoginTest;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTelepathyGabbleLoginTest
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+CTelepathyGabbleLoginTest::~CTelepathyGabbleLoginTest()
+ {
+
+ //class variables
+ //delete conn;
+ //conn = NULL;
+
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : action_login
+// description : login
+// Returns : gboolean
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleLoginTest::action_login(char* username,char* password,
+ char* server, char* resource, char* ssl_flag,
+ char *port, char *proxy_server, char *proxy_port,
+ CTestData* aTestData)
+{
+
+
+ TpConnMgr *connmgr = NULL;
+ GError *error = NULL;
+
+ test_log_handler1(username);
+ test_log_handler1(password);
+ test_log_handler1(server);
+ test_log_handler1(resource);
+ test_log_handler1(ssl_flag);
+ test_log_handler1(port);
+
+
+ GHashTable *connection_parameters = g_hash_table_new(g_str_hash, g_str_equal);
+
+ DBusGConnection *dbus_connection;
+ TpConn *tp_conn;
+
+ //Use the values passed from the cfg file.
+ gchar* def1 = g_strdup(username);
+ gchar* def2 = g_strdup(password);
+
+ gchar* def3 = g_strdup(server);
+ gchar* def4 = g_strdup(resource);
+
+ guint def5 = atoi(port); //443;
+
+ #ifdef __WINSCW__
+ gchar* def6 = g_strdup(proxy_server); //g_strdup("172.16.42.135"); //for emulater
+ guint def7 = atoi(proxy_port); //8080; //for emulater
+ #endif
+
+ GValue *value1 = g_new0(GValue, 1);
+ GValue *value2 = g_new0(GValue, 1);
+ GValue *value3 = g_new0(GValue, 1);
+ GValue *value4 = g_new0(GValue, 1);
+ GValue *value5 = g_new0(GValue, 1);
+
+ #ifdef __WINSCW__
+ GValue *value6 = g_new0(GValue, 1);
+ GValue *value7 = g_new0(GValue, 1);
+ #endif
+
+ GValue *value8 = g_new0(GValue, 1);
+ g_type_init();
+
+
+ // just use system bus and do not bother about others
+ dbus_connection = dbus_g_bus_get( DBUS_BUS_SESSION , &error);
+
+ aTestData->GetStifLogger()->Log( _L("after dbus_g_bus_get") );
+ /* bsr 4 sep: this was null as host parsing failed -> transport was zero -> connectionw as 0 */
+ if (dbus_connection == NULL)
+ {
+ // if we get error as part of above step, connection variable is NULL, so we are here
+ //_dbus_verboseerr("Failed to open connection to bus: %s\n", error->message);
+ //test_log_handler("Found Error in dbus_g_bus_get exiting.\n");
+ aTestData->GetStifLogger()->Log( _L("dbus_connection == NULL") );
+ g_error_free(error);
+ return (aTestData->GetConnectionState());
+ }
+ else
+ {
+ aTestData->SetDBusConnection(dbus_connection);
+ }
+
+ aTestData->GetStifLogger()->Log( _L("b4 tp_connmgr_new") );
+ /* Create a connection manager object */
+ connmgr = tp_connmgr_new(dbus_connection, CONNMGR_BUS, CONNMGR_PATH,
+ /*CONNMGR_BUS*/ TP_IFACE_CONN_MGR_INTERFACE);
+ aTestData->GetStifLogger()->Log( _L("after tp_connmgr_new") );
+ if (connmgr == NULL)
+ {
+ aTestData->GetStifLogger()->Log( _L("connmgr == NULL") );
+ g_error("Failed to create a connection manager, skipping manager startup.");
+ return (aTestData->GetConnectionState());
+ }
+ else
+ {
+ aTestData->SetTpConnMgr(connmgr);
+ }
+
+ g_value_init(value1, G_TYPE_STRING);
+ g_value_set_string (value1, def1);
+ g_hash_table_insert(connection_parameters, (gpointer)"account", (gpointer)value1);
+
+ g_value_init(value2, G_TYPE_STRING);
+ g_value_set_string (value2, def2);
+ g_hash_table_insert(connection_parameters,(gpointer) "password",(gpointer) value2);
+
+ g_value_init(value3, G_TYPE_STRING);
+ g_value_set_string (value3, def3);
+ g_hash_table_insert(connection_parameters,(gpointer) "server",(gpointer)value3 );
+
+ g_value_init(value4, G_TYPE_STRING);
+ g_value_set_string (value4, def4);
+ g_hash_table_insert(connection_parameters, (gpointer)"resource", (gpointer)value4);
+
+
+ g_value_init(value5, G_TYPE_UINT);
+ g_value_set_uint (value5, def5);
+ g_hash_table_insert(connection_parameters, (gpointer)"port", (gpointer)value5);
+
+ //convert the ssl_flag to ascii
+ TInt ssl_bool = atoi(ssl_flag);
+
+ //if (ssl_flag == "1") //def8 ==1
+ if (ssl_bool == 1) //i.e. only for gtalk, not for gizmo
+ {
+ gboolean def8 = TRUE; //for gtalk
+ g_value_init(value8, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value8, def8);
+ g_hash_table_insert(connection_parameters, (gpointer)"old-ssl", (gpointer)value8);
+ }
+
+#ifdef __WINSCW__
+ g_value_init(value6, G_TYPE_STRING);
+ g_value_set_string (value6, def6);
+ g_hash_table_insert(connection_parameters, (gpointer)"https-proxy-server", (gpointer)value6);
+
+
+ g_value_init(value7, G_TYPE_UINT);
+ g_value_set_uint (value7, def7);
+ g_hash_table_insert(connection_parameters, (gpointer)"https-proxy-port",(gpointer) value7);
+#endif
+
+
+ // Create a new actual connection with the connection manager
+ //Ensure that conn is global.
+ // The same conn object is used for logout.
+ aTestData->GetStifLogger()->Log( _L("b4 tp_connmgr_new_connection") );
+ tp_conn = tp_connmgr_new_connection(connmgr,connection_parameters, PROTOCOL);
+ aTestData->GetStifLogger()->Log( _L("after tp_connmgr_new_connection") );
+ if( tp_conn == NULL )
+ {
+ aTestData->GetStifLogger()->Log( _L("tp_conn is null") );
+ return (aTestData->GetConnectionState());
+ }
+ else
+ {
+ aTestData->SetTpConn(tp_conn);
+ }
+
+
+
+ // add a callback for StatusChange signal
+ dbus_g_proxy_connect_signal(DBUS_G_PROXY(tp_conn), "StatusChanged",
+ (G_CALLBACK(status_changed_cb)),
+ aTestData,NULL );
+
+ g_hash_table_destroy(connection_parameters);
+
+ //Run the mainloop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+ //Quit of main loop happened in thecallback.
+ //unref this mainloop
+ // same main loop can be used for all classes,
+ // unref after logout in each test case when logintest object gets destroyed
+ //g_main_loop_unref ( mainloop );
+
+ //After the status_changed_cb , the control back here
+ //Check the value of global variable that was updated
+ //in the callback and return the same.
+
+
+ //Get the connected state for login and return the same.
+ return (aTestData->GetConnectionState());
+}
+
+//-----------------------------------------------------------------------------
+// function_name : action_logout
+// description : Does logout
+// Returns : None
+//-----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleLoginTest::action_logout(CTestData* aTestData)
+{
+ GError *error = NULL;
+
+ //Do the disconnect
+ tp_conn_disconnect (DBUS_G_PROXY( aTestData->GetTpConn()), &error);
+
+ //g_hash_table_destroy(global_data_ptr->Getptrhashtable_textchan());
+
+ //Start the main loop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+
+ //After this see that the callback status_changed_cb
+ //is hit with TP_CONN_STATUS_DISCONNECTED as the status.
+
+ //After the status_changed_cb , the control back here
+ //Check the value of global variable that was updated in the
+ //callback and return the same.
+
+ if (error)
+ {
+ // There is some error
+ g_error_free (error);
+ // Update the global to connected
+ //global_connected = TRUE;
+ }
+ //else global_connected is made FALSE in the status_changed_cb
+
+
+ //return global_connected;
+ //Get the connected state for login and return the same.
+ return (aTestData->GetConnectionState());
+}
+
+//-----------------------------------------------------------------------------
+// function_name : action_cancel
+// description : cancel login
+// Returns : None
+//-----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleLoginTest::action_cancel(char* username,
+ char* password, char* server,char* resource, char* ssl_flag,
+ char *port,char *proxy_server, char *proxy_port,
+ CTestData* aTestData)
+{
+ aTestData->SetTestType(CTestData::ECancel) ;
+ aTestData->GetStifLogger()->Log( _L("inside action_cancel\n") );
+ action_login(username,password,server,resource,ssl_flag,
+ port, proxy_server, proxy_port, aTestData);
+
+ action_logout(aTestData);//Do tp_disconnected.
+
+ return (aTestData->GetConnectionState());
+}
+
+//-----------------------------------------------------------------------------
+// function_name : status_changed_cb
+//-----------------------------------------------------------------------------
+gboolean CTelepathyGabbleLoginTest::status_changed_cb(DBusGProxy* /*proxy*/,
+ guint status, guint reason,
+ gpointer user_data)
+{
+ GHashTable* textChannelsHT = NULL;
+ CTestData* testData = static_cast<CTestData*> (user_data);
+ CStifLogger* logger = testData->GetStifLogger();
+ logger->Log( _L("status_changed_cb\n") );
+
+ if (status == TP_CONN_STATUS_CONNECTED )
+ {
+
+
+ logger->Log( _L("status_changed_cb::connected\n") );
+
+
+ if( testData->GetTestType() != CTestData::ELogin )
+ {
+
+
+ textChannelsHT =
+ g_hash_table_new_full(g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+
+ testData->SetTextChannelsHT(textChannelsHT);
+ //Register the callback for new channel
+ //Commented for now has been put in the SendMessage function,
+ dbus_g_proxy_connect_signal(DBUS_G_PROXY(testData->GetTpConn()), "NewChannel",
+ (G_CALLBACK(new_channel_handler)),
+ user_data,NULL);
+ }
+ else
+ {
+ // if the test case is login related test case, new channel callback not required
+ //so dont register for NewChannel
+ g_main_loop_quit(testData->GetMainLoop());
+ testData->ResetLoginCompleteFlag();
+ }
+ //update the state_of_conenction enum
+ testData->SetConnectionState(CTestData::ECONNECTED );
+
+ }
+ else if (status == TP_CONN_STATUS_CONNECTING)
+ {
+ //if the test case is for cancel disconnect here, meaning cancel the login here.
+ //if cancel test case, do disconnect in connecting state
+ testData->SetConnectionState(CTestData::ECONNECTING);
+ if ( testData->GetTestType() == CTestData::ECancel)
+ {
+ //quit from this callback so that we return to point from where
+ //action_login was called.
+ g_main_loop_quit(testData->GetMainLoop());
+ }
+
+ }
+ else if ( status == TP_CONN_STATUS_DISCONNECTED )
+ {
+
+
+ if ( testData->GetTestType() == CTestData::ECancel)
+ {
+ //this disconnect was initiated from the cancel test case
+ logger->Log( _L("status_changed_cb :cancelled \n") );
+ testData->SetConnectionState(CTestData::EDISCONNECTED);
+ //quit the main loop.
+ g_main_loop_quit(testData->GetMainLoop());
+ }
+ else
+ {
+
+ if(reason == TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED)
+ {
+ // Here disconnect is received as the authentication has failed.
+ //it could be because of invalid user_id or invalid passwd issued
+ //while passing the login parameters.
+ //Here we are checking for TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED since
+ // the gabblelogs show the reason value as 3 if invalid user_id and passwd are given.
+
+ testData->SetConnectionState(CTestData::EDISCONNECTED);
+
+ //Quit the main loop started in action_login.
+ g_main_loop_quit(testData->GetMainLoop());
+
+ }
+ else
+ {
+ //this was initiated in the logout testcase,
+ //update the state_of_connection
+ //LOGOUT AFTER SUCCESSFUL LOGIN
+
+ if( testData->GetConnectionState() != CTestData::EDISCONNECTED )
+ {
+
+ logger->Log( _L("status_changed_cb::not disconnected\n") );
+
+ testData->IncLoginCompleteFlag();
+
+ //currently for all the reasons except TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED
+ //disconencted will come here.
+ //This code can be updated for variuos "reason" values
+ //based on the scenarios and the need for the test cases for those scenarios.
+ }
+
+ if( testData->GetLoginCompleteFlag() && testData->GetConnectionState() == CTestData::EDISCONNECTED )
+ {
+ logger->Log( _L("status_changed_cb::disconnected\n") );
+ testData->ResetLoginCompleteFlag();
+ //Quit the main loop started in action_login.
+ g_main_loop_quit(testData->GetMainLoop());
+
+ }
+ logger->Log( _L("status_changed_cb::before SetConnectionState\n") );
+ testData->SetConnectionState(CTestData::EDISCONNECTED);
+
+ }
+ }
+
+ }
+ logger->Log( _L("status_changed_cb out\n") );
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// function_name : new_channel_handler
+// description : callback function for NewChannel signal
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleLoginTest::new_channel_handler(DBusGProxy* /*proxy*/, const char *object_path,
+ const char *channel_type, guint handle_type,
+ guint channel_handle, gboolean /*suppress_handler*/,
+ gpointer user_data)
+{
+CTestData* testData = static_cast<CTestData*> (user_data);
+CStifLogger* logger = testData->GetStifLogger();
+logger->Log( _L("new_channel_handler\n") );
+
+//Use the class data member new_text_channel.
+TpChan *new_chan;
+
+//Get the new_chan
+new_chan = tp_chan_new(testData->GetDBusConnection(),
+ CONNMGR_BUS, object_path,
+ channel_type, handle_type, channel_handle);
+
+
+//channel_type == TP_IFACE_CHANNEL_TYPE_TEXT
+if ((strcmp(channel_type, TP_IFACE_CHANNEL_TYPE_TEXT) == 0) )
+ {
+ g_hash_table_insert(testData->GetTextChannelsHT(), g_strdup(object_path), new_chan);
+ //test_log_handler( "b4 text_channel_init" );
+ //check for new_chan objects for text channel should be loaclly stored/freed
+ text_channel_init( new_chan );
+ }
+
+
+//channel_type == TP_IFACE_CHANNEL_TYPE_CONTACT_LIST
+if( strcmp( channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && (g_strrstr(object_path, "RosterChannel/subscribe") ) )
+
+ {
+ DBusGProxy* groupInterface = NULL;
+ //Get the group_iface
+ groupInterface =
+ tp_chan_get_interface(new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+
+
+ testData->SetGroupSubscribeInterface(groupInterface);
+
+ //register the callback, commented for now.
+ dbus_g_proxy_connect_signal (groupInterface, "MembersChanged",
+ G_CALLBACK (CTelepathyGabbleAddDeleteContact::roster_members_changed_cb ),
+ NULL, NULL);
+
+ //add_contact("testcm6666@gmail.com",NULL);
+
+ testData->IncLoginCompleteFlag();
+
+ }
+
+if( strcmp( channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && (g_strrstr(object_path, "RosterChannel/publish") ) )
+
+ {
+
+ DBusGProxy* groupInterface = NULL;
+ //Get the group_iface
+ groupInterface ==
+ tp_chan_get_interface(new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+
+ testData->SetGroupPublishInterface(groupInterface);
+
+ dbus_g_proxy_connect_signal (groupInterface, "MembersChanged",
+ G_CALLBACK (CTelepathyGabbleAddDeleteContact::roster_members_changed_cb ),
+ NULL, NULL);
+
+
+
+ //Increment the flag.
+ testData->IncLoginCompleteFlag();
+
+ }
+
+if( strcmp( channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && (g_strrstr(object_path, "RosterChannel/known") ) )
+
+ {
+ DBusGProxy* groupInterface = NULL;
+ //Get the group_iface
+ groupInterface = tp_chan_get_interface(new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+
+
+ //remove_contact( "testcm6666@gmail.com", NULL );
+ testData->SetGroupKnownInterface(groupInterface);
+
+ dbus_g_proxy_connect_signal (groupInterface, "MembersChanged",
+ G_CALLBACK (CTelepathyGabbleAddDeleteContact::roster_members_changed_cb ),
+ NULL, NULL);
+
+
+ //increment the flag
+ testData->IncLoginCompleteFlag();
+
+ }
+
+if( strcmp( channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST ) == 0
+ && (g_strrstr(object_path, "RosterChannel/deny") ) )
+
+ {
+ DBusGProxy* groupInterface = NULL;
+ //Get the group_iface
+ groupInterface = tp_chan_get_interface(new_chan,
+ TELEPATHY_CHAN_IFACE_GROUP_QUARK);
+
+ testData->SetGroupDenyInterface(groupInterface);
+
+ dbus_g_proxy_connect_signal (groupInterface, "MembersChanged",
+ G_CALLBACK (CTelepathyGabbleAddDeleteContact::roster_members_changed_cb ),
+ NULL, NULL);
+
+ //remove_contact( "testcm6666@gmail.com", NULL );
+
+ //increment the flag
+ testData->IncLoginCompleteFlag();
+
+ }
+ //Quit the mainloop started once all the channel-types are recieved.
+ //check the flag.
+
+ if (testData->GetLoginCompleteFlag() == 3)
+ //In case of gizmo, the number of channels is 3.gtalk for deny also we get the callback
+ //we must also store the server name in the login class and check the server name here
+ {
+ //Quit the main loop.
+ testData->ResetLoginCompleteFlag();
+ testData->GetStifLogger()->Log( _L("new_channel_handler::after ResetLoginCompleteFlag\n") );
+ g_main_loop_quit(testData->GetMainLoop());
+
+ }
+
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : text_channel_init
+// description : To get pending messages after login
+//-----------------------------------------------------------------------------
+
+void CTelepathyGabbleLoginTest::text_channel_init ( TpChan *text_chan )
+ {
+ GPtrArray *messages_list ;
+ guint i;
+ GArray *message_ids;
+ DBusGProxy *text_iface;
+
+
+ text_iface = tp_chan_get_interface(text_chan ,
+ TELEPATHY_CHAN_IFACE_TEXT_QUARK);
+
+
+ //check if need to fetch the pending message or simply register for receive only
+ tp_chan_type_text_list_pending_messages(text_iface,
+ FALSE,
+ &messages_list,
+ NULL);
+
+
+ message_ids = g_array_new (FALSE, TRUE, sizeof (guint));
+
+
+ for (i = 0; i < messages_list->len ; i++)
+ {
+ guint message_id;
+ guint timestamp;
+ guint from_handle;
+ guint message_type;
+ guint message_flags;
+ const gchar *message_body;
+ GValueArray *message_struct;
+
+
+
+ message_struct = (GValueArray *) g_ptr_array_index (messages_list, i);
+
+ message_id = g_value_get_uint(g_value_array_get_nth(message_struct, 0));
+
+ timestamp = g_value_get_uint(g_value_array_get_nth(message_struct, 1));
+
+ from_handle = g_value_get_uint(g_value_array_get_nth(message_struct, 2));
+
+ message_type = g_value_get_uint(g_value_array_get_nth(message_struct, 3));
+
+ message_flags = g_value_get_uint(g_value_array_get_nth(message_struct, 4));
+
+ message_body = g_value_get_string(g_value_array_get_nth(message_struct, 5));
+
+ g_array_append_val (message_ids, message_id);
+
+ }
+
+
+ tp_chan_type_text_acknowledge_pending_messages(text_iface, message_ids,
+ NULL);
+
+
+
+}
+
+
+
+//End of file
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabblepresencetest.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,262 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Presence Test Cases
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "telepathygabblepresencetest.h"
+#include "telepathygabbletestdata.h"
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+
+CTelepathyGabblePresenceTest::CTelepathyGabblePresenceTest()
+ {
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+
+void CTelepathyGabblePresenceTest::ConstructL()
+ {
+
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+CTelepathyGabblePresenceTest* CTelepathyGabblePresenceTest::NewL()
+ {
+
+ CTelepathyGabblePresenceTest* self = new(ELeave) CTelepathyGabblePresenceTest;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTelepathyGabblePresenceTest
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+CTelepathyGabblePresenceTest::~CTelepathyGabblePresenceTest()
+{
+
+}
+
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTestData
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+TelepathyPresenceState CTelepathyGabblePresenceTest::telepathy_presence_state_from_str (const gchar *str)
+{
+ char temp[25];
+ strcpy(temp,str);
+ //roster_log_handler("telepathy_telepathy_presence_state_from_str");
+ //roster_log_handler(temp);
+
+ if (strcmp (str, "available") == 0) {
+ return TELEPATHY_PRESENCE_STATE_AVAILABLE;
+ } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
+ return TELEPATHY_PRESENCE_STATE_BUSY;
+ } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
+ return TELEPATHY_PRESENCE_STATE_AWAY;
+ } else if (strcmp (str, "xa") == 0) {
+ return TELEPATHY_PRESENCE_STATE_EXT_AWAY;
+ } else if (strcmp (str, "hidden") == 0) {
+ return TELEPATHY_PRESENCE_STATE_HIDDEN;
+ } else if (strcmp (str, "offline") == 0) {
+ return TELEPATHY_PRESENCE_STATE_UNAVAILABLE;
+ }
+
+ return TELEPATHY_PRESENCE_STATE_AVAILABLE;
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTestData
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+//vinod: gossip_telepathy_contacts_send_presence
+void
+CTelepathyGabblePresenceTest::telepathy_contacts_send_presence (DBusGProxy *pres_iface,
+ TelepathyPresence *presence/*CTestData *aTestData*/)
+{
+ GHashTable *status_ids;
+ GHashTable *status_options;
+ const gchar *status_id;
+ const gchar *message;
+ TelepathyPresenceState presence_state;
+ GError *error = NULL;
+ GValue value_message = {0, };
+
+ //iTpConn = aTestData->GetTpConn();
+
+ //g_return_if_fail (contacts != NULL);
+ //g_return_if_fail (GOSSIP_IS_PRESENCE (presence));
+
+ if (!pres_iface) {
+ return;
+ }
+
+ status_ids = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) g_hash_table_destroy);
+ status_options = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL,
+ (GDestroyNotify) g_value_unset);
+
+ presence_state = telepathy_presence_get_state (presence);
+ status_id = telepathy_presence_state_to_str (presence_state);
+ message = telepathy_presence_get_status (presence);
+
+ if (message) {
+ g_value_init (&value_message, G_TYPE_STRING);
+ g_value_set_string (&value_message, message);
+ g_hash_table_insert (status_options, (gpointer)"message", &value_message);
+ }
+
+ g_hash_table_insert (status_ids,
+ g_strdup (status_id),
+ status_options);
+
+ //Sync way: gossip_debug (DEBUG_DOMAIN, "sending presence...");
+ if (! (DBUS_G_PROXY(pres_iface),
+ status_ids,
+ &error)) {
+ //gossip_debug ("Could not set presence: %s", error->message);
+ //roster_log_handler("Could not set presence\n");
+ g_clear_error (&error);
+ }
+ //Async way
+/*tp_conn_iface_presence_set_status_async(DBUS_G_PROXY(pres_iface),
+ status_ids,
+ ,
+ NULL );
+*/
+ g_hash_table_destroy (status_ids);
+}
+
+//-----------------------------------------------------------------------------
+// function_name : telepathy_presences_foreach
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+void
+CTelepathyGabblePresenceTest::telepathy_presences_foreach (gpointer *key,
+ gpointer *value,
+ TelepathyPresence **presence)
+{
+ TelepathyPresenceState state;
+ const gchar *message;
+ char temp[100];
+
+ *presence = telepathy_presence_new();
+
+ //roster_log_handler("telepathy_presences_foreach");
+// roster_log_handler(key);
+
+ state = telepathy_presence_state_from_str((const gchar *)key);
+
+ telepathy_presence_set_state(*presence, state);
+
+ message = g_value_get_string((GValue *)
+ g_hash_table_lookup((GHashTable *)
+ value, "message"));
+ strcpy(temp,message);
+ //roster_log_handler(temp);
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : telepathy_presence_handle_foreach
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+void
+CTelepathyGabblePresenceTest::telepathy_presence_handle_foreach (gpointer *key,
+ gpointer *value)
+{
+ gint handle_id;
+ GHashTable *presences_hash;
+ GValue *gvalue;
+ gboolean new_item;
+ GObject *contact;
+ GObject *presence;
+ gchar **handle_name;
+ GArray *handles;
+
+ CTestData* atestData;
+
+ handle_id = GPOINTER_TO_INT(key);
+
+ handles = g_array_new (FALSE, FALSE, sizeof (gint));
+ g_array_append_val (handles, handle_id);
+ tp_conn_inspect_handles(DBUS_G_PROXY(atestData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT, handles,
+ &handle_name, NULL);
+
+ gvalue = g_value_array_get_nth((GValueArray *) value, 1);
+
+ presences_hash = (GHashTable *) g_value_get_boxed(gvalue);
+
+ g_hash_table_foreach(presences_hash,
+ (GHFunc) telepathy_presences_foreach, &presence);
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTestData
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+void CTelepathyGabblePresenceTest::telepathy_presence_handler(DBusGProxy *proxy,
+ GHashTable *handle_hash)
+{
+ //GObject *presence;
+ TelepathyPresence *presence;
+ TelepathyPresenceState state;
+ GSList *data = NULL;
+ //vinod: setting the new presence status
+ presence = telepathy_presence_new();
+ //here am hard coding the value, this can be taken from ximpfw
+ state = telepathy_presence_state_from_str("dnd");
+ telepathy_presence_set_state(presence, state);
+ //vinod
+ //roster_log_handler("telepathy_presence_handler callback\n");
+ g_hash_table_foreach(handle_hash, (GHFunc) telepathy_presence_handle_foreach, data);
+
+
+ //vinod: call telepathy_set_presence method here
+ telepathy_contacts_send_presence(proxy, presence);
+
+}
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabblesearch.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,430 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Search Related Test Cases
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+#include <glib.h>
+#include <TestScripterInternal.h>
+#include "telepathygabbleutils.h"
+#include "telepathygabblesearch.h"
+#include "telepathygabbletestdata.h"
+#include "tp-chan.h"
+#include "tp-conn-gen.h"
+
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTelepathyGabbleSearch
+// description : constructor
+//-----------------------------------------------------------------------------
+
+CTelepathyGabbleSearch::CTelepathyGabbleSearch()
+{
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : constructor
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleSearch::ConstructL()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : NewL
+//-----------------------------------------------------------------------------
+CTelepathyGabbleSearch* CTelepathyGabbleSearch::NewL()
+ {
+ CTelepathyGabbleSearch* self = new(ELeave) CTelepathyGabbleSearch;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTelepathyGabbleSearch
+// description : Destructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleSearch::~CTelepathyGabbleSearch()
+ {
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : SearchL
+// description : Used for searching contacts
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleSearch::SearchL( GHashTable *aDataToSearch, CTestData* aTestData )
+{
+ Search_UserData *userData = new(ELeave) Search_UserData;
+
+ userData->data_to_search = aDataToSearch;
+ userData->testData = aTestData;
+
+ iTestData = aTestData;
+
+ if( iTestData->GetSearchChan() )
+ {
+ SearchAgainL( aDataToSearch, iTestData );
+ //Run the mainloop
+ g_main_loop_run (iTestData->GetMainLoop());
+ }
+ else
+ {
+ if (!tp_conn_request_channel_async( DBUS_G_PROXY( aTestData->GetTpConn() ),
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH,
+ TP_CONN_HANDLE_TYPE_NONE, 0, TRUE,
+ do_search_reply,(gpointer) userData ) )
+
+ {
+ return KErrGeneral;
+ }
+ //Run the mainloop
+ g_main_loop_run (iTestData->GetMainLoop());
+ DoSearchL( aDataToSearch, aTestData);
+ }
+
+
+
+
+ if(userData)
+ {
+ delete userData;
+ userData = NULL;
+ }
+
+ //return the Message_sent that was updated in the callback sendmessage_cb
+ return iTestData->GetSearchState();
+}
+
+//-----------------------------------------------------------------------------
+// function_name : SearchAgainL
+// description : Used for searching contacts second or more number of times
+//-----------------------------------------------------------------------------
+
+ void CTelepathyGabbleSearch::SearchAgainL( GHashTable *aDataToSearch, CTestData* aTestData )
+ {
+
+ DBusGProxy *search_iface = NULL;
+ TpChan *search_chan = NULL;
+
+ if(aTestData)
+ {
+ search_chan = aTestData->GetSearchChan();
+ }
+ if ( NULL == search_chan )
+ {
+ return ;
+ }
+ //Get chan interface
+ search_iface = tp_chan_get_interface( search_chan ,
+ TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK );
+
+ if ( NULL == search_iface )
+ {
+ return ;
+ }
+
+ //Call the search on tp
+ tp_chan_type_search_async( search_iface, aDataToSearch, searchreply_cb,
+ aTestData );
+
+
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : GetSearchKeysL
+// description : Used for getting search keys
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleSearch::GetSearchKeysL( CTestData* aTestData )
+{
+ Search_UserData *userData = new(ELeave) Search_UserData;
+
+ userData->data_to_search = NULL;
+ userData->testData = aTestData;
+
+ iTestData = aTestData;
+
+ if (!tp_conn_request_channel_async( DBUS_G_PROXY( aTestData->GetTpConn() ),
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH,
+ TP_CONN_HANDLE_TYPE_NONE, 0, TRUE,
+ do_search_reply,(gpointer) userData ) )
+
+ {
+ return KErrGeneral;
+ }
+
+ //Run the mainloop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+ DoSearchL(NULL,aTestData);
+
+ if(userData)
+ {
+ delete userData;
+ userData = NULL;
+ }
+
+ //return the Message_sent that was updated in the callback sendmessage_cb
+ return iTestData->GetSearchState();
+}
+
+
+void CTelepathyGabbleSearch::do_search_reply( DBusGProxy* /*proxy*/, char *chan_object_path,
+ GError *error, gpointer user_data )
+ {
+ Search_UserData* userData = static_cast<Search_UserData*> (user_data);
+ TpChan *search_chan = NULL;
+
+ TInt search_state = userData->testData->GetSearchState();
+
+
+ /* Create the object to represent the channel */
+ if ( error )
+ {
+ userData->testData->SetSearchState(CTestData::ESearchError);
+ return;
+ }
+ search_chan = tp_chan_new( userData->testData->GetDBusConnection(), CONNMGR_BUS, chan_object_path,
+ TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH, TP_CONN_HANDLE_TYPE_NONE, 0 );
+
+
+ g_free(chan_object_path);
+
+
+ if ( NULL == search_chan )
+ {
+ userData->testData->SetSearchState(CTestData::ESearchError);
+ return ;
+ }
+
+ userData->testData->SetSearchChan( search_chan );
+
+ g_main_loop_quit(userData->testData->GetMainLoop());
+
+
+ }
+
+
+void CTelepathyGabbleSearch::DoSearchL(GHashTable *aDataToSearch,CTestData *testData)
+{
+ DBusGProxy *search_iface = NULL;
+ TInt testType = testData->GetTestType();
+
+ //Get chan interface
+ search_iface = tp_chan_get_interface( testData->GetSearchChan(),
+ TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK );
+
+ if ( NULL == search_iface )
+ {
+ testData->SetSearchState(CTestData::ESearchError);
+ return ;
+ }
+ //Register for the SearchResultReceived signal
+ //ownership of the srch_result->user_data is transfered
+ dbus_g_proxy_connect_signal( search_iface, "SearchResultReceived",
+ G_CALLBACK( search_result_received_cb ),
+ (gpointer)this, NULL );
+
+
+ //Register for the SearchStateChanged signal
+ dbus_g_proxy_connect_signal( search_iface, "SearchStateChanged",
+ G_CALLBACK( search_state_changed_cb ),
+ (gpointer)this, NULL );
+
+ if( testType == CTestData::EGetSearchKeys )
+ {
+ //Call the getsearchkeys on tp
+ tp_chan_type_search_get_search_keys_async(search_iface,getsearchkeys_cb, testData );
+
+ }
+ else if( testType == CTestData::ESearch )
+ {
+ //Call the search on tp
+ tp_chan_type_search_async( search_iface, aDataToSearch,
+ searchreply_cb, testData);
+ }
+
+ g_main_loop_run(testData->GetMainLoop());
+
+}
+void CTelepathyGabbleSearch::getsearchkeys_cb( DBusGProxy* /*proxy*/, gchar* /*instr*/,
+ gchar** keys, GError *error, gpointer user_data )
+{
+CTestData* testData = static_cast<CTestData*> (user_data);
+
+if(!keys || error )
+ {
+ testData->SetSearchState( CTestData::ESearchError );
+ }
+
+if(keys)
+ {
+ testData->GetStifLogger()->Log( _L("getsearchkeys_cb:SearchKeysFound") );
+ testData->SetSearchState( CTestData::ESearchKeysFound );
+ testData->SetSearchKeys(keys);
+ }
+g_main_loop_quit(testData->GetMainLoop());
+
+}
+
+
+
+void CTelepathyGabbleSearch::searchreply_cb( DBusGProxy* /*proxy*/, GError *error, gpointer user_data )
+{
+ CTestData* testData = static_cast<CTestData*> (user_data);
+ TInt testType = testData->GetTestType();
+
+ testData->GetStifLogger()->Log( _L("searchreply_cb") );
+
+ if ( testType == CTestData::ESearch )
+ {
+ if(error)
+ {
+ testData->GetStifLogger()->Log( _L("Error in search") );
+ testData->SetSearchState(CTestData::ESearchError);
+ tp_chan_close_async( DBUS_G_PROXY( testData->GetSearchChan() ), search_chan_closed_cb, testData );
+ }
+ }
+
+}
+
+
+
+
+void CTelepathyGabbleSearch::search_result_received_cb ( DBusGProxy* /*proxy*/,
+ guint /*contact_handle*/,
+ GHashTable *values,
+ gpointer user_data
+ )
+{
+CTelepathyGabbleSearch* search_userData = static_cast<CTelepathyGabbleSearch*> (user_data);
+guint result_count = 0;
+
+//iTestData->GetStifLogger()->Log( _L("search_result_received_cb") );
+search_userData->GetTestData()->GetStifLogger()->Log( _L("search_result_received_cb") );
+
+if(values )
+ result_count = g_hash_table_size(values);
+
+
+//do this later
+/*if(result_count)
+ {
+ g_hash_table_foreach(values,setfield_foreach,NULL);
+ }*/
+
+
+}
+
+void CTelepathyGabbleSearch::search_state_changed_cb ( DBusGProxy* /*proxy*/,
+ guint search_state,
+ gpointer user_data
+ )
+{
+CTelepathyGabbleSearch* search_userData = static_cast<CTelepathyGabbleSearch*> (user_data);
+DBusGProxy *search_iface = NULL;
+GError **err = NULL;
+guint *state = NULL;
+TpChan *search_chan = NULL;
+CTestData* testData = search_userData->GetTestData();
+
+if(search_userData && testData )
+ {
+ testData->GetStifLogger()->Log( _L("search_state_changed_cb") );
+ search_chan = testData->GetSearchChan();
+ }
+
+
+if( search_state == TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER && search_userData && search_chan )
+ {
+ testData->SetSearchState(CTestData::ESearchCompleted);
+ search_iface = tp_chan_get_interface( search_chan,
+ TELEPATHY_CHAN_IFACE_CONTACTSEARCH_QUARK );
+ tp_chan_type_search_get_search_state( search_iface,state,err);
+ g_main_loop_quit(testData->GetMainLoop());
+ }
+
+}
+
+void CTelepathyGabbleSearch::search_chan_closed_cb ( DBusGProxy* /*proxy*/,
+ GError *error,
+ gpointer user_data
+ )
+{
+CTestData* testData = static_cast<CTestData*> (user_data);
+
+testData->GetStifLogger()->Log( _L("search_chan_closed_cb") );
+if(error)
+ {
+ testData->GetStifLogger()->Log( _L("search_chan_closed_cb : Error ") );
+ testData->SetSearchState(CTestData::ESearchError);
+ }
+else
+ {
+
+ TInt testType = testData->GetTestType();
+ if( testType == CTestData::EGetSearchKeys )
+ {
+ testData->SetSearchState(CTestData::ESearchKeysFound);
+ testData->GetStifLogger()->Log( _L("search_chan_closed_cb : SearchKeysFound ") );
+ }
+ else if( testType == CTestData::ESearch )
+ {
+ testData->SetSearchState(CTestData::ESearchCompleted);
+ testData->GetStifLogger()->Log( _L("search_chan_closed_cb : SearchCompleted ") );
+ }
+ }
+g_main_loop_quit(testData->GetMainLoop());
+}
+
+CTestData* CTelepathyGabbleSearch::GetTestData()
+ {
+ return iTestData;
+ }
+
+/*void CTelepathyGabbleSearch::setfield_foreach (gpointer key, gpointer value, gpointer user_data)
+{
+ gchar *k = (gchar *) key;
+ const char *v = g_value_get_string ( (const GValue*)value);
+ CTestData* testdata = static_cast<CTestData*> (user_data);
+
+ //testdata->GetStifLogger()->Log( _L("setfield_foreach") );
+
+}*/
+
+void CTelepathyGabbleSearch::CloseChannel( CTestData* aTestdata )
+ {
+ if( aTestdata->GetSearchChan() )
+ {
+ tp_chan_close_async( DBUS_G_PROXY( aTestdata->GetSearchChan() ), search_chan_closed_cb, aTestdata );
+ }
+ //Run the mainloop
+ g_main_loop_run (aTestdata->GetMainLoop());
+ }
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabblesendmessage.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,350 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Used for Send/Receive Test Cases
+*
+*/
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+#include <glib.h>
+#include <StifLogger.h>
+#include "telepathygabbleutils.h"
+#include "telepathygabblesendmessage.h"
+#include "telepathygabbletestdata.h"
+
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTelepathyGabbleSendRecvMessage
+// description : constructor
+//-----------------------------------------------------------------------------
+
+CTelepathyGabbleSendRecvMessage::CTelepathyGabbleSendRecvMessage()
+{
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : constructor
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleSendRecvMessage::ConstructL()
+{
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : NewL
+//-----------------------------------------------------------------------------
+CTelepathyGabbleSendRecvMessage* CTelepathyGabbleSendRecvMessage::NewL()
+ {
+ CTelepathyGabbleSendRecvMessage* self = new(ELeave) CTelepathyGabbleSendRecvMessage;
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTelepathyGabbleSendRecvMessage
+// description : Destructor
+//-----------------------------------------------------------------------------
+CTelepathyGabbleSendRecvMessage::~CTelepathyGabbleSendRecvMessage()
+ {
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : SendMessage
+// description : To send a message
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleSendRecvMessage::SendMessage( const char *contact_id,
+ const char *message,
+ CTestData* aTestData )
+{
+ TpChan* text_chan = NULL; //for send msg
+
+ TInt contact_handle;
+ GArray *handles = NULL;
+ GError* error = NULL;
+ DBusGProxy *text_iface = NULL;
+
+ gpointer userdata = NULL;
+
+
+ //get the contact handle.
+ contact_handle = CTelepathyGabbleUtils::get_handle_from_contact(contact_id,aTestData);
+
+ if ( contact_handle == KErrNotFound )
+ {
+ return CTestData::EMessageSendErr;
+ }
+
+ text_chan = (TpChan*)g_hash_table_find(
+ aTestData->GetTextChannelsHT(),
+ (GHRFunc) text_channels_find_func,
+ &contact_handle );
+
+ //text_chan for the particular contact does not exist.
+ //New text_chan must be created.
+ if (text_chan == NULL)
+ {
+ text_chan = tp_conn_new_channel(
+ (aTestData->GetDBusConnection()),
+ (aTestData->GetTpConn()),CONNMGR_BUS,TP_IFACE_CHANNEL_TYPE_TEXT,
+ TP_CONN_HANDLE_TYPE_CONTACT,contact_handle, TRUE );
+
+ //Insert the new text_chan to the hash table.
+
+ g_hash_table_insert(
+ (aTestData->GetTextChannelsHT()),
+ g_strdup(dbus_g_proxy_get_path(DBUS_G_PROXY(text_chan))),text_chan);
+
+ }
+
+ text_iface = tp_chan_get_interface(text_chan,TELEPATHY_CHAN_IFACE_TEXT_QUARK);
+
+
+ if( aTestData->GetTestType() == CTestData::ESendErr ||
+ aTestData->GetTestType() == CTestData::EReceive )
+ {
+ //Register the callback to get the error
+ //when the recipeint_id is invalid.
+ dbus_g_proxy_connect_signal(text_iface, "SendError",
+ G_CALLBACK(SendError_cb),
+ aTestData, NULL);
+ }
+
+ if( aTestData->GetTestType() == CTestData::EReceive )
+ {
+ //Register for the receive message callback here.
+ dbus_g_proxy_connect_signal(text_iface, "Received",
+ (G_CALLBACK(receivedMessage_cb)),
+ aTestData, NULL);
+ }
+
+
+
+ //This callback tells whether the message is sent to the server or not.
+
+ tp_chan_type_text_send_async( text_iface, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ message,sendmessage_cb, aTestData);
+
+
+ // user_data = this i.e. the class pointer
+
+ //Run the mainloop
+ g_main_loop_run (aTestData->GetMainLoop());
+
+
+ //return the Message_sent that was updated in the callback sendmessage_cb
+ return aTestData->GetSendRecvMsgState();
+}
+
+//-----------------------------------------------------------------------------
+// function_name : ReceiveMessage
+// description : receive message
+//-----------------------------------------------------------------------------
+TInt CTelepathyGabbleSendRecvMessage::ReceiveMessage( const char *contact_id,
+ const char *message,
+ CTestData* aTestData )
+{
+ TpChan* text_chan = NULL; //for send msg
+ DBusGProxy *text_iface;
+
+ guint contact_handle;
+
+
+
+ //send msg 1
+ //For Automation, Do the send message to yourself
+ //own contact_id received from the cfg file.
+ TInt msg_status = SendMessage(contact_id,message,aTestData);
+ if( msg_status == CTestData::EMessageNotSent )
+ {
+ aTestData->GetStifLogger()->Log( _L("ReceiveMessage: Msg is not sent successfully \n") );
+
+ if( aTestData->GetTestType() == CTestData::ERecvBlank )
+ g_main_loop_quit(aTestData->GetMainLoop());
+
+ return CTestData::EMessageNotSent;
+ }
+
+
+ /*contact_handle = CTelepathyGabbleUtils::get_handle_from_contact(contact_id,aTestData);
+
+ text_chan = (TpChan*)g_hash_table_find(
+ (aTestData->GetTextChannelsHT()),
+ (GHRFunc) text_channels_find_func,
+ &contact_handle );
+ text_iface = tp_chan_get_interface(text_chan ,
+ TELEPATHY_CHAN_IFACE_TEXT_QUARK);
+
+ //Register for the receive message callback here.
+ dbus_g_proxy_connect_signal(text_iface, "Received",
+ (G_CALLBACK(receivedMessage_cb)),
+ aTestData, NULL);
+
+ //send msg 2
+ //Do the send message to yourself
+
+ msg_status == CTestData::EMessageNotSent )
+ {
+ return CTestData::EMessageNotSent;
+ }*/
+ aTestData->GetStifLogger()->Log( _L("after : register receivedMessage_cb \n") );
+ if (aTestData->GetTestType() == CTestData::EReceive &&
+ aTestData->GetSendRecvMsgState() != CTestData::EMessageSendErr )
+ {
+ //there are two callbacks now.
+ //receivedMessage_cb and sendmessage_cb.
+
+ //Run the mainloop again as it was quit in the callback sendmessage_cb.
+ //the message_state is not yet MESSAGE_RECEIVED.
+ //we need to start the main loop again to get the receivedmessage_cb.
+ aTestData->GetStifLogger()->Log( _L("start mainloop if state not as EMESSAGE_RCVD \n") );
+ g_main_loop_run (aTestData->GetMainLoop());
+
+ }
+ return aTestData->GetSendRecvMsgState();
+}
+
+//-----------------------------------------------------------------------------
+// function_name : sendmessage_cb
+// description : Callback for Send Message
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleSendRecvMessage::sendmessage_cb( DBusGProxy* /*proxy*/, GError* /*error*/, gpointer userdata )
+{
+ CTestData* testdata = static_cast<CTestData*> (userdata);
+
+ testdata->GetStifLogger()->Log( _L("inside sendmessage_cb \n") );
+
+ //This is the test case for sending message to invalid userid.
+ if ( testdata->GetTestType() != CTestData::ESendErr )
+
+ {
+
+ testdata->SetSendRecvMsgState(CTestData::EMessageSent);
+ testdata->GetStifLogger()->Log( _L("sendmessage_cb::msg sent successfully \n") );
+
+ //Quit the main loop , just for now
+ g_main_loop_quit(testdata->GetMainLoop());
+ }
+ else if( testdata->GetTestType() == CTestData::ERecvBlank )
+ {
+
+ //Quit the main loop , just for now
+ testdata->GetStifLogger()->Log( _L("sendmessage_cb::test case is for blank msg sending \n") );
+ g_main_loop_quit(testdata->GetMainLoop());
+ }
+
+
+ //otherwise send message error test case, dont quit.
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : receivedMessage_cb
+// description : Callback for receive message
+//-----------------------------------------------------------------------------
+void CTelepathyGabbleSendRecvMessage::receivedMessage_cb ( DBusGProxy* /*proxy*/,
+ guint /* message_id */,
+ guint /* timestamp */,
+ guint /* from_handle */,
+ guint /* message_type */,
+ guint /* message_flags */,
+ gchar * /*message_body */,
+ gpointer user_data )
+{
+ //GArray *message_ids;
+ //GArray *handles = NULL;
+ CTestData* testdata = static_cast<CTestData*> (user_data);
+
+
+ /*message_ids = g_array_new (FALSE, FALSE, sizeof (guint));
+
+ g_array_append_val (message_ids, message_id);
+
+ g_array_free (message_ids, TRUE);
+
+ handles = g_array_new (FALSE, FALSE, sizeof (guint32));
+
+ g_array_append_val (handles, from_handle);
+
+ g_array_free (handles, TRUE);*/
+ testdata->GetStifLogger()->Log( _L("receivedMessage_cb::test case is for receive msg \n") );
+
+ if( testdata->GetTestType() == CTestData::EReceive )
+ {
+ testdata->SetSendRecvMsgState(CTestData::EMessageRecvd);
+
+ //Quit the main loop once the receive message callback is received.
+ g_main_loop_quit(testdata->GetMainLoop());
+
+ }
+
+
+
+}
+
+//-----------------------------------------------------------------------------
+// function_name : text_channels_find_func
+// description : find whether the text channel
+// is existing given the hash table pointer
+//-----------------------------------------------------------------------------
+gboolean CTelepathyGabbleSendRecvMessage::text_channels_find_func( gchar* /*key*/,
+ TpChan *text_channel_ht_ptr,
+ guint *contact_handle)
+{
+ if ((text_channel_ht_ptr->handle == *contact_handle))
+ {
+ return TRUE;
+ }//else
+ return FALSE;
+}
+
+void CTelepathyGabbleSendRecvMessage::SendError_cb ( DBusGProxy* /*proxy*/,
+ guint error,
+ guint /*timestamp*/,
+ guint /*message_type*/,
+ gchar* /*message_body*/,
+ gpointer user_data )
+{
+
+ //Get the testdata
+ CTestData* testdata = static_cast<CTestData*> (user_data);
+
+ FILE* fp;
+
+ fp = fopen("c:\\testlogs.txt","a");
+ if(fp)
+ {
+ fprintf(fp,"error code is %u", error);
+ fprintf(fp,"\n");
+ fclose(fp);
+ }
+
+ testdata->GetStifLogger()->Log( _L("inside SendError_cb \n") );
+
+
+ testdata->SetSendRecvMsgState(CTestData::EMessageSendErr);
+ //quit the main loop
+ g_main_loop_quit(testdata->GetMainLoop());
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabbletest.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: For Stiff framework related functions
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include <StifTestInterface.h>
+#include "telepathygabbletest.h"
+#include <SettingServerClient.h>
+
+
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::CTelepathyGabbleTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTelepathyGabbleTest::CTelepathyGabbleTest(
+ CTestModuleIf& aTestModuleIf ):
+ CScriptBase( aTestModuleIf )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTelepathyGabbleTest::ConstructL()
+ {
+ //Read logger settings to check whether test case name is to be
+ //appended to log file name.
+ RSettingServer settingServer;
+ TInt ret = settingServer.Connect();
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Struct to StifLogger settigs.
+ TLoggerSettings loggerSettings;
+ // Parse StifLogger defaults from STIF initialization file.
+ ret = settingServer.GetLoggerSettings(loggerSettings);
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Close Setting server session
+ settingServer.Close();
+ TFileName logFileName;
+
+ if(loggerSettings.iAddTestCaseTitle)
+ {
+ TName title;
+ TestModuleIf().GetTestCaseTitleL(title);
+ logFileName.Format(KTelepathyGabbleTestLogFileWithTitle, &title);
+ }
+ else
+ {
+ logFileName.Copy(KTelepathyGabbleTestLogFile);
+ }
+ iLog = CStifLogger::NewL( KTelepathyGabbleTestLogPath,
+ logFileName,
+ CStifLogger::ETxt,
+ CStifLogger::EFile,
+ EFalse );
+ iLog->Log( _L("CTelepathyGabbleTest::Constructl after CStifLogger::NewL") );
+ TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksMem );
+
+ TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles );
+ TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksRequests );
+ iLog->Log( _L("CTelepathyGabbleTest::Constructl out") );
+
+
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTelepathyGabbleTest* CTelepathyGabbleTest::NewL(
+ CTestModuleIf& aTestModuleIf )
+ {
+ CTelepathyGabbleTest* self = new (ELeave) CTelepathyGabbleTest( aTestModuleIf );
+
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+
+ return self;
+
+ }
+
+// Destructor
+CTelepathyGabbleTest::~CTelepathyGabbleTest()
+ {
+ iLog->Log( _L("CTelepathyGabbleTest::~CTelepathyGabbleTest in") );
+ // Delete resources allocated from test methods
+ Delete();
+
+ iLog->Log( _L("CTelepathyGabbleTest::~CTelepathyGabbleTest out") );
+ // Delete logger
+ delete iLog;
+
+ }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL(
+ CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+ {
+
+ return ( CScriptBase* ) CTelepathyGabbleTest::NewL( aTestModuleIf );
+
+ }
+
+// -----------------------------------------------------------------------------
+// E32Dll is a DLL entry point function.
+// Returns: KErrNone
+// -----------------------------------------------------------------------------
+//
+#ifndef EKA2 // Hide Dll entry point to EKA2
+GLDEF_C TInt E32Dll(
+ TDllReason /*aReason*/) // Reason code
+ {
+ return(KErrNone);
+
+ }
+#endif // EKA2
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabbletestblocks.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,4599 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Stif Test Cases Test blocks file.
+* RunMethodL mentions all the test cases that will be run.
+*
+*/
+
+
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <StifTestInterface.h>
+#include "telepathygabbletest.h"
+#include "telepathygabbletestdata.h"
+//glib related include files
+#include <glib.h>
+#include <glib/gprintf.h> // for g_stpcpy
+#include <string.h>
+#include <stdlib.h>
+
+#include <glowmem.h>
+
+//Login related file
+#include "telepathygabblelogintest.h"
+//Send Message related file
+#include "telepathygabblesendmessage.h"
+//AddDeleteContact related file
+#include "telepathygabbleadddeletecontact.h"
+//FetchContacts related files
+#include "telepathygabblefetchcontacts.h"
+//Search related files
+#include "telepathygabblesearch.h"
+
+
+const TInt KRepeatedMessageCount=4;
+
+
+
+typedef enum
+{
+ RC_OK,
+ RC_ERROR
+} RC_Code_t;
+
+typedef struct
+{
+ gchar *recipient;
+ gchar *message;
+} MessageData;
+
+typedef struct
+{
+ gchar *proxy_server;
+ gchar *proxy_port;
+}ProxyData;
+
+typedef struct
+{
+ gchar *key;
+ gchar *value;
+}SearchData;
+typedef struct
+{
+ gchar *server;
+ gchar *username;
+ gchar *password;
+ gchar *resource;
+ MessageData *msg_data;
+#ifdef __WINSCW__
+ ProxyData *proxy_data;
+#endif
+ gchar *port;
+ gchar *ssl_flag; //needed for gizmo and gtalk.
+ SearchData *search_data;
+
+} ConnectData;
+
+typedef struct
+{
+ ConnectData *connect_data;
+ GMainLoop *main_loop;
+ RC_Code_t rCode;
+} AuthData;
+
+typedef struct
+{
+ GMainLoop *main_loop;
+ RC_Code_t Test_Success;
+} HandleData;
+
+// Function to read data from the cfg file
+static RC_Code_t read_data ( ConnectData*& connect_data,
+ CStifItemParser& aItem, CStifLogger* aLog );
+
+// Function to free the allocated resources
+static void free_data ( ConnectData*& connect_data, CStifLogger* aLog);
+
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+//-----------------------------------------------------------------------------
+// function_name : read_data
+// description : Reads data from the CFG file
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static RC_Code_t
+read_data ( ConnectData*& connect_data, CStifItemParser& aItem, CStifLogger* aLog )
+ {
+ TPtrC string;
+ TBuf8<KMaxFileName> temp;
+
+ //TBuf8<KMaxChar> temp;
+ MessageData *msg_data = NULL;
+
+ SearchData *search_data = NULL;
+#ifdef __WINSCW__
+ ProxyData *proxy_data = NULL;
+#endif
+
+ connect_data = g_new0 ( ConnectData, 1 );
+ if ( !connect_data )
+ {
+ return RC_ERROR;
+ }
+
+ msg_data = g_new0 ( MessageData, 1 );
+ if ( !msg_data )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+
+ connect_data->msg_data = msg_data;
+
+ search_data = g_new0 ( SearchData, 1 );
+ if ( !search_data )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ connect_data->search_data = search_data;
+
+#ifdef __WINSCW__
+ proxy_data = g_new0 ( ProxyData, 1 );
+ if ( !proxy_data )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ connect_data->proxy_data = proxy_data;
+#endif
+
+ // Read server name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->server = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->server )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->server, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Username
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->username = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->username )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->username, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Password corresponding to Username
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->password = g_new0 ( gchar, temp.Length () );
+ if ( !connect_data->password )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->password, ( gchar *) temp.Ptr() );
+ }
+
+ // Read recipient
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ msg_data->recipient = g_new0 ( gchar, temp.Length() );
+ if ( !msg_data->recipient )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( msg_data->recipient, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Message
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ msg_data->message = g_new0 ( gchar, temp.Length() );
+ if ( !msg_data->message )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( msg_data->message, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read resource identifier
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->resource = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->resource )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->resource, ( gchar * ) temp.Ptr() );
+ }
+
+
+ // Read proxy server and proxy port
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ #ifdef __WINSCW__
+ proxy_data->proxy_server = g_new0 ( gchar, temp.Length() );
+ if ( !proxy_data->proxy_server )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( proxy_data->proxy_server, ( gchar * ) temp.Ptr() );
+ #endif
+ }
+
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ #ifdef __WINSCW__
+ proxy_data->proxy_port = g_new0 ( gchar, temp.Length() );
+ if ( !proxy_data->proxy_port )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( proxy_data->proxy_port, ( gchar * ) temp.Ptr() );
+ #endif
+ }
+
+ /* if ( aItem.GetNextInt ( proxy_port ) == KErrNone )
+ {
+ proxy_data->proxy_port = proxy_port;
+ } */
+
+
+
+ //Read the port
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->port = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->port )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->port, ( gchar * ) temp.Ptr() );
+ }
+
+ //Read the ssl_flag value
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->ssl_flag = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->ssl_flag )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->ssl_flag, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read key
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ search_data->key = g_new0 ( gchar, temp.Length() );
+ if ( !search_data->key )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( search_data->key, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read value
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ search_data->value = g_new0 ( gchar, temp.Length() );
+ if ( !search_data->value )
+ {
+ free_data (connect_data, aLog );
+ return RC_ERROR;
+ }
+ g_stpcpy ( search_data->value, ( gchar * ) temp.Ptr() );
+ }
+
+ return RC_OK;
+ }
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : free_data
+// description : Deallocates all the data
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+free_data ( ConnectData*& connect_data, CStifLogger* aLog )
+ {
+ //iLog->Log( _L("free_data\n") );
+ if ( connect_data )
+ {
+ if ( connect_data->server )
+ {
+ //iLog->Log( _L("free server\n") );
+ g_free ( connect_data->server );
+ connect_data->server = NULL;
+ }
+
+ if ( connect_data->username )
+ {
+ aLog->Log( _L(" free username\n") );
+ g_free ( connect_data->username );
+ connect_data->username = NULL;
+ }
+
+ if ( connect_data->password )
+ {
+ aLog->Log( _L(" free password\n") );
+ g_free ( connect_data->password );
+ connect_data->password = NULL;
+ }
+
+ if ( connect_data->msg_data )
+ {
+ if ( connect_data->msg_data->recipient )
+ {
+ aLog->Log( _L(" free recipient\n") );
+ g_free ( connect_data->msg_data->recipient );
+ connect_data->msg_data->recipient = NULL;
+ }
+ if ( connect_data->msg_data->message )
+ {
+ aLog->Log( _L(" free message\n") );
+ g_free ( connect_data->msg_data->message );
+ connect_data->msg_data->message = NULL;
+ }
+ g_free ( connect_data->msg_data );
+ connect_data->msg_data = NULL;
+ }
+
+ if ( connect_data->resource )
+ {
+ aLog->Log( _L(" free resource\n") );
+ g_free ( connect_data->resource );
+ connect_data->resource = NULL;
+ }
+
+ #ifdef __WINSCW__
+ if ( connect_data->proxy_data )
+ {
+ if ( connect_data->proxy_data->proxy_server )
+ {
+ aLog->Log( _L(" free proxy_server\n") );
+ g_free ( connect_data->proxy_data->proxy_server );
+ connect_data->proxy_data->proxy_server = NULL;
+ }
+ if ( connect_data->proxy_data->proxy_port )
+ {
+ aLog->Log( _L(" free proxy_port\n") );
+ g_free ( connect_data->proxy_data->proxy_port );
+ connect_data->proxy_data->proxy_port = NULL;
+ }
+ g_free ( connect_data->proxy_data );
+ connect_data->proxy_data = NULL;
+ }
+ #endif
+
+ //port free
+ if ( connect_data->port )
+ {
+ aLog->Log( _L(" free port\n") );
+ g_free ( connect_data->port );
+ connect_data->port = NULL;
+ }
+
+ //ssl_flag free
+ if ( connect_data->ssl_flag )
+ {
+ aLog->Log( _L(" free ssl_flag\n") );
+ g_free ( connect_data->ssl_flag );
+ connect_data->ssl_flag = NULL;
+ }
+
+ if ( connect_data->search_data )
+ {
+ if ( connect_data->search_data->key )
+ {
+ aLog->Log( _L(" free key\n") );
+ g_free ( connect_data->search_data->key );
+ connect_data->search_data->key = NULL;
+ }
+ if ( connect_data->search_data->value )
+ {
+ aLog->Log( _L(" free value\n") );
+ g_free ( connect_data->search_data->value );
+ connect_data->search_data->value = NULL;
+ }
+ g_free ( connect_data->search_data );
+ connect_data->search_data = NULL;
+ }
+ aLog->Log( _L(" free connect_data\n") );
+ g_free ( connect_data );
+ connect_data = NULL;
+ }
+ aLog->Log( _L(" free connect_data out\n") );
+ }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::Delete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+//
+void CTelepathyGabbleTest::Delete()
+ {
+ iLog->Log( _L("CTelepathyGabbleTest::Delete in\n") );
+ if (iLoginObj)
+ {
+ iLog->Log( _L("In Delete iLoginObj \n") );
+ delete iLoginObj;
+ iLoginObj = NULL;
+ }
+
+ if (iSendMsgObj)
+ {
+ delete iSendMsgObj;
+ iSendMsgObj = NULL;
+ }
+
+ if (iAddDelContactObj)
+ {
+ delete iAddDelContactObj;
+ iAddDelContactObj = NULL;
+ }
+
+ if (iFetchContactObj)
+ {
+ delete iFetchContactObj;
+ iFetchContactObj = NULL;
+ }
+
+ if (iSearchObj)
+ {
+ delete iSearchObj;
+ iSearchObj = NULL;
+ }
+
+ if (iTestData)
+ {
+ iLog->Log( _L("In Delete iTestData \n") );
+ delete iTestData;
+ iTestData = NULL;
+
+ }
+ iLog->Log( _L("CTelepathyGabbleTest::Delete out\n") );
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CTelepathyGabbleTest::RunMethodL(
+ CStifItemParser& aItem )
+ {
+
+ iLog->Log( _L("CTelepathyGabbleTest::RunMethodL in") );
+
+
+ static TStifFunctionInfo const KFunctions[] =
+ {
+ // Copy this line for every implemented function.
+ // First string is the function name used in TestScripter script file.
+ // Second is the actual implementation member function.
+ //ENTRY( "Example", CTelepathyGabbleTest::ExampleL ),
+ //ADD NEW ENTRY HERE
+ // [test cases entries] - Do not remove
+
+ //Login - Logout related test cases
+ ENTRY("LoginTest", CTelepathyGabbleTest::LoginTestL ),
+ ENTRY("LogoutTest", CTelepathyGabbleTest::LogoutTestL ),
+ ENTRY("LoginInvalidUseridTest", CTelepathyGabbleTest::LoginInvalidUseridTestL ),
+ ENTRY("LoginInvalidPasswdTest", CTelepathyGabbleTest::LoginInvalidPasswdTestL ),
+ ENTRY("LoginInvalidUseridPasswdTest", CTelepathyGabbleTest::LoginInvalidUseridPasswdTestL ),
+ ENTRY("LoginblankUseridTest", CTelepathyGabbleTest::LoginblankUseridTestL ),
+ ENTRY("LoginblankPasswdTest", CTelepathyGabbleTest::LoginblankPasswdTestL ),
+ ENTRY("LoginblankUseridblankPasswdTest", CTelepathyGabbleTest::LoginblankUseridblankPasswdTestL ),
+ ENTRY("LoginWithMaxLengthUserIDTest", CTelepathyGabbleTest::LoginTestL ),
+ ENTRY("LoginWithMinLengthUserIDTest", CTelepathyGabbleTest::LoginTestL ),
+ ENTRY("LoginUseridWithSplChrsTest", CTelepathyGabbleTest::LoginInvalidUseridTestL ),
+ ENTRY("LoginCancelTest", CTelepathyGabbleTest::LoginCancelTestL ),
+
+
+ //Send Message related Test Cases
+ ENTRY("SendMessageTest", CTelepathyGabbleTest::SendMessageTestL ),
+ ENTRY("SendMesasgeToMaxLengthUserIDTest", CTelepathyGabbleTest::SendMessageTestL ),
+ ENTRY("SendMesasgetoofflinecontactTest", CTelepathyGabbleTest::SendMessagetoinvalidUseridTestL ),
+ ENTRY("SendMessageWith400Test", CTelepathyGabbleTest::SendMessageWith400TestL ),
+ ENTRY("SendMesasgeBlankTest", CTelepathyGabbleTest::SendMesasgeBlankTestL ),
+ ENTRY("SendMesasgeToBlankUserIdTest", CTelepathyGabbleTest::SendMesasgeToBlankUserIdTestL ),
+ ENTRY("SendMesasgeSplCharsTest", CTelepathyGabbleTest::SendMessageTestL ),
+ ENTRY("SendMesasgeEmoticonsTest", CTelepathyGabbleTest::SendMessageTestL ),
+ ENTRY("SendMessageRepeatedTest",CTelepathyGabbleTest:: SendMessageRepeatedTestL),
+ ENTRY("SendMessagetoUserNotInContactListTest",CTelepathyGabbleTest:: SendMessageTestL),
+ ENTRY("SendMessagetoinvalidUseridTest",CTelepathyGabbleTest:: SendMessagetoinvalidUseridTestL),
+
+ //Receive Message related Test Cases
+ ENTRY("ReceiveMessageTest", CTelepathyGabbleTest::ReceiveMessageTestL ),
+ ENTRY("ReceiveMessageMaxLengthTest", CTelepathyGabbleTest::ReceiveMessageMaxLengthTestL ),
+ ENTRY("ReceiveMessageWithSplChrsTest", CTelepathyGabbleTest::ReceiveMessageTestL ),
+ ENTRY("ReceiveMessageWithEmoticonsTest", CTelepathyGabbleTest::ReceiveMessageTestL ),
+ ENTRY("ReceiveMessageBlankTest", CTelepathyGabbleTest::ReceiveMessageBlankTestL ),
+ ENTRY("ReceiveRepeatedMessageTest", CTelepathyGabbleTest::ReceiveRepeatedMessageTestL ),
+
+ //Add Contact related test cases
+ ENTRY("AddContactTest", CTelepathyGabbleTest::AddContactTestL ),
+ ENTRY("AddContactWithMaxLengthUserIdTest", CTelepathyGabbleTest::AddContactTestL ),
+ ENTRY("AddContactWithBlankUserIdTest", CTelepathyGabbleTest::AddContactWithBlankUserIdTestL ),
+ ENTRY("AddContactinvalidTest", CTelepathyGabbleTest::AddContactTestL ),
+ ENTRY("AddContactinvalidWithSplCharsTest", CTelepathyGabbleTest::AddContactTestL ),
+ ENTRY("AddContactAlreadyInRosterTest", CTelepathyGabbleTest::AddContactAlreadyInRosterTestL ),
+
+
+ //Remove Contact related test cases
+ ENTRY("RemoveContactTest", CTelepathyGabbleTest::RemoveContactTestL ),
+ ENTRY("RemoveInvalidContactTest", CTelepathyGabbleTest::RemoveInvalidContactTestL),
+ ENTRY("RemoveContactAlreadyRemovedTest", CTelepathyGabbleTest::RemoveInvalidContactTestL ),
+ ENTRY("RemoveContactWithMaxLengthUserIDTest", CTelepathyGabbleTest::RemoveContactTestL ),
+ ENTRY("RemoveContactWithBlankUserIdTest", CTelepathyGabbleTest::RemoveContactWithBlankUserIdTestL ),
+
+ //Fetch Contact related test cases
+ ENTRY("FetchContactsTest", CTelepathyGabbleTest::FetchContactsTestL ),
+ ENTRY("FetchZeroContactTest", CTelepathyGabbleTest::FetchContactsTestL ),
+
+ //Search related test cases
+ ENTRY("SearchTest", CTelepathyGabbleTest::SearchTestL ),
+ ENTRY("GetSearchKeysTest", CTelepathyGabbleTest::GetSearchKeysTestL ),
+ ENTRY("SearchInvalidKeyTest", CTelepathyGabbleTest::SearchInvalidKeyTestL ),
+ ENTRY("SearchNoKeyValueTest", CTelepathyGabbleTest::SearchNoKeyValueTestL ),
+ ENTRY("SearchTwoInvalidKeysTest", CTelepathyGabbleTest::SearchTwoInvalidKeysTestL ),
+ ENTRY("SearchWithAllKeysTest", CTelepathyGabbleTest::SearchWithAllKeysTestL ),
+ ENTRY("SearchBlankStringTest", CTelepathyGabbleTest::SearchBlankStringTestL ),
+ ENTRY("SearchTwiceTest", CTelepathyGabbleTest::SearchTwiceTestL ),
+ ENTRY("SearchTwiceWithDiffStringsTest", CTelepathyGabbleTest::SearchTwiceWithDiffStringsTestL ),
+ ENTRY("SearchFiveTimesTest", CTelepathyGabbleTest::SearchFiveTimesTestL ),
+ ENTRY("SearchAfterGetSearchKeys", CTelepathyGabbleTest::SearchAfterGetSearchKeysL ),
+ };
+
+ const TInt count = sizeof( KFunctions ) /
+ sizeof( TStifFunctionInfo );
+
+ return RunInternalL( KFunctions, count, aItem );
+
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+//
+
+TInt CTelepathyGabbleTest::LoginTestL(
+ CStifItemParser& aItem )
+ {
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ iLog->Log( _L("LoginTestL starting") );
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog) != RC_OK )
+ {
+ //iLog->Log( _L("read_data failed") );
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLog->Log( _L("iTestData created") );
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ iLog->Log( _L("iLoginObj created") );
+
+ iTestData->SetTestType(CTestData::ELogin) ;
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port, iTestData);
+
+
+ iLog->Log( _L("after action_login") );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //Do the logout so that all the resources are deallocated properly
+ login_status = iLoginObj->action_logout(iTestData);
+
+ iLog->Log( _L("after action_logout") );
+
+ free_data (connect_data, iLog);
+
+ iLog->Log( _L("after free_data") );
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ iLog->Log( _L("logout failed") );
+ return KErrGeneral; //logout didnot happen successfully.
+ }
+
+ //we completed login and logout successfully.
+ iLog->Log( _L("login-logout test case passed\n") );
+
+ if (iTestData)
+ { iLog->Log( _L("delete iTestData \n") );
+ delete iTestData;
+ iTestData = NULL;
+
+ }
+ if (iLoginObj)
+ {
+ iLog->Log( _L("delete iLoginObj \n") );
+ delete iLoginObj;
+ iLoginObj = NULL;
+ }
+ return KErrNone;
+ }
+ else
+ {
+ //Login didnot happen successfully.
+ //return from here itself, no need for a logout
+ free_data (connect_data, iLog );
+ iLog->Log( _L("login test case failed") );
+ return KErrGeneral;
+
+ }
+
+ }
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginblankUseridblankPasswdTestL
+// -----------------------------------------------------------------------------
+TInt CTelepathyGabbleTest::LoginblankUseridblankPasswdTestL(
+ CStifItemParser& aItem )
+ {
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data,iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = ""; //make the username as blank
+ passwd = ""; //make the username as blank
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ iTestData->SetTestType(CTestData::ELogin) ;
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername, resource_login, ssl_flag,
+ port,proxy_server, proxy_port,iTestData);
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+ //login_status is disconnected(default state)
+ //which is correct since the username was blank.
+
+ return KErrNone;
+ }
+ else
+ {
+ //There was some error
+ return KErrGeneral;
+ }
+
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginblankUseridTestL
+// -----------------------------------------------------------------------------
+TInt CTelepathyGabbleTest::LoginblankUseridTestL(
+ CStifItemParser& aItem )
+ {
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data,iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = ""; //make the username as blank
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ iTestData->SetTestType(CTestData::ELogin) ;
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername, resource_login, ssl_flag,
+ port,proxy_server, proxy_port,iTestData);
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+ //login_status is disconnected(default state)
+ //which is correct since the username was blank.
+
+ return KErrNone;
+ }
+ else
+ {
+ //There was some error
+ return KErrGeneral;
+ }
+
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginblankPasswdTestL
+// -----------------------------------------------------------------------------
+TInt CTelepathyGabbleTest::LoginblankPasswdTestL(
+CStifItemParser& aItem )
+{
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = ""; //make the passwd as blank.
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ iTestData->SetTestType(CTestData::ELogin) ;
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,iTestData);
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+ //the status is disconnected which is correct since the
+ //login didnot happen with blank passwd.
+ return KErrNone;
+ }
+ else
+ {
+ return KErrGeneral;
+
+ }
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LogoutTestL
+// Test for logout
+// -----------------------------------------------------------------------------
+TInt CTelepathyGabbleTest::LogoutTestL(
+CStifItemParser& aItem )
+{
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ iTestData->SetTestType(CTestData::ELogin);
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status = iLoginObj->action_login(username,passwd,servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,iTestData);
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //If the login variable is ECONNECTED
+ //Do the Logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+
+ //the logout happened succesfully
+ free_data ( connect_data, iLog );
+ return KErrNone;
+ }
+ else
+ {
+ //login_status is still connected, there was a problem
+ //in logging out.
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchAfterGetSearchKeysL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchAfterGetSearchKeysL( CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *value, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ value = connect_data->msg_data->message;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+
+ iTestData->SetTestType(CTestData::EGetSearchKeys);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ TInt search_state = iSearchObj->GetSearchKeysL( iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in finding search keys
+ }
+ else if( search_state == CTestData::ESearchKeysFound)
+ {
+ return_value = KErrNone;
+
+ GHashTable *data_to_search = NULL;
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+ gchar **keys = iTestData->GetSearchKeys();
+
+ iTestData->SetTestType(CTestData::ESearch);
+ for(TInt i=0; i<8 ; i++ )
+ {
+ GValue *gvalue = NULL;
+ gvalue = g_new0(GValue, 1);
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, g_strdup(value) );
+ g_hash_table_insert( data_to_search,keys[i], gvalue);
+
+ }
+
+ search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ else if( search_state == CTestData::ESearchCompleted)
+ {
+ return_value = KErrNone;
+ }
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchWithAllKeysTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchWithAllKeysTestL( CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *value, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ value = connect_data->msg_data->message;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::EGetSearchKeys);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ TInt search_state = iSearchObj->GetSearchKeysL( iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in finding search keys
+ }
+ else if( search_state == CTestData::ESearchKeysFound)
+ {
+ return_value = KErrNone;
+
+ iTestData->SetTestType(CTestData::ESearch);
+ GHashTable *data_to_search = NULL;
+ TInt i = 0;
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+ gchar **keys = iTestData->GetSearchKeys();
+
+ for( i=0; i<7 ; i++ )
+ {
+ GValue *gvalue = NULL;
+ gvalue = g_new0(GValue, 1);
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, g_strdup(value) );
+ g_hash_table_insert( data_to_search, keys[i], gvalue);
+
+ }
+
+ GValue *gvalue1 = NULL;
+ gvalue1 = g_new0(GValue, 1);
+
+ g_value_init(gvalue1, G_TYPE_STRING);
+ g_value_set_string (gvalue1, g_strdup("5") );
+ g_hash_table_insert( data_to_search,keys[i], gvalue1);
+
+ search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ else if( search_state == CTestData::ESearchCompleted)
+ {
+ return_value = KErrNone;
+ }
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+ g_free(keys);
+
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchBlankStringTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchBlankStringTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ iTestData->SetTestType(CTestData::ESearch);
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ GValue *gvalue = NULL;
+
+ char *key, *value;
+
+ key = connect_data->msg_data->recipient;
+ //value = connect_data->msg_data->message;
+ //search for blank string
+ value = "";
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, value );
+ g_hash_table_insert( data_to_search, key, gvalue);
+
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ else if( search_state == CTestData::ESearchCompleted)
+ {
+ return_value = KErrNone;
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ GValue *gvalue = NULL;
+
+ char *key, *value;
+
+ key = connect_data->msg_data->recipient;
+ value = connect_data->msg_data->message;
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, value );
+ g_hash_table_insert( data_to_search, GetSearchLabelL(servername,key), gvalue);
+
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ else if( search_state == CTestData::ESearchCompleted)
+ {
+ return_value = KErrNone;
+ }
+
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchTwoInvalidKeysTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchTwoInvalidKeysTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ GValue *gvalue1, *gvalue2 ;
+
+ char *key1,*key2, *value1, *value2;
+
+ key1 = connect_data->msg_data->recipient;
+ value1 = connect_data->msg_data->message;
+
+ key2 = connect_data->search_data->key;
+ value2 = connect_data->search_data->value;
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue1 = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue1, G_TYPE_STRING);
+ g_value_set_string (gvalue1, value1 );
+ g_hash_table_insert( data_to_search, GetSearchLabelL(servername,key1), gvalue1);
+
+ gvalue2 = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue2, G_TYPE_STRING);
+ g_value_set_string (gvalue2, value2 );
+ g_hash_table_insert( data_to_search, GetSearchLabelL(servername,key2), gvalue2);
+
+
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ //Error in Searching,
+ //as one of the search key passed is wrong
+ return_value = KErrNone;
+ }
+ else
+ {
+ return_value = KErrGeneral;
+ }
+
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchTwiceWithDiffStringsTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchTwiceWithDiffStringsTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search_first = NULL;
+ GHashTable *data_to_search_second = NULL;
+
+ GValue *gvalue1, *gvalue2 ;
+
+ char *key1,*value1, *key2, *value2;
+
+ key1 = connect_data->msg_data->recipient;
+ value1 = connect_data->msg_data->message;
+
+ key2 = connect_data->search_data->key;
+ value2 = connect_data->search_data->value;
+
+ data_to_search_first = g_hash_table_new(g_str_hash,g_str_equal);
+
+ data_to_search_second = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue1 = g_new0(GValue, 1);
+ g_value_init(gvalue1, G_TYPE_STRING);
+ g_value_set_string (gvalue1, value1 );
+ g_hash_table_insert( data_to_search_first, GetSearchLabelL(servername,key1), gvalue1);
+
+ gvalue2 = g_new0(GValue, 1);
+ g_value_init(gvalue2, G_TYPE_STRING);
+ g_value_set_string (gvalue2, value2 );
+ g_hash_table_insert( data_to_search_second, GetSearchLabelL(servername,key2), gvalue2);
+
+
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search_first, iTestData);
+
+ if( search_state == CTestData::ESearchError)
+ {
+ return_value = KErrGeneral;
+ }
+ else
+ {
+ search_state = iSearchObj->SearchL(data_to_search_second, iTestData);
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+
+ }
+
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search_first );
+ g_hash_table_destroy ( data_to_search_second );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchNoKeyValueTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchNoKeyValueTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ //Error in Searching,
+ //as one of the search key passed is wrong
+ return_value = KErrNone;
+ }
+ else
+ {
+ return_value = KErrGeneral;
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchInvalidKeyTest
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchInvalidKeyTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ GValue *gvalue = NULL;
+
+ char *key, *value;
+
+ key = connect_data->msg_data->recipient;
+ value = connect_data->msg_data->message;
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, value );
+ //ivalid search key..label has to be passed so no need to pass label
+ g_hash_table_insert( data_to_search, key, gvalue);
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ //Error in Searching,
+ //as one of the search key passed is wrong
+ return_value = KErrNone;
+ }
+ else
+ {
+ return_value = KErrGeneral;
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::GetSearchKeysTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::GetSearchKeysTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::EGetSearchKeys);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ TInt search_state = iSearchObj->GetSearchKeysL( iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ else if( search_state == CTestData::ESearchKeysFound)
+ {
+ return_value = KErrNone;
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SendMessageTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SendMessageTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+
+ iTestData->SetTestType(CTestData::ESend);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Send a message
+
+ //for sending a message
+ char *recipient_id, *msg;
+
+
+
+ recipient_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+
+
+ //call the SendMessage test case
+ TInt sendmsg_state = iSendMsgObj->SendMessage(recipient_id,msg,iTestData);
+
+ if( sendmsg_state == CTestData::EMessageNotSent )
+ {
+ return_value = KErrGeneral; //Error in Sending message
+ }
+ else if( sendmsg_state == CTestData::EMessageSendErr )
+ {
+ // error was not expected
+ return_value = KErrGeneral;
+ }
+ else if( sendmsg_state == CTestData::EMessageSent )
+ {
+ //If message sent to invalid userid or blank userid, state should EMessageSendErr
+ // This is used in case of SendMessagetoinvalidUseridTestL
+ return_value = KErrNone;
+ }
+
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SendMessageRepeatedTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SendMessageRepeatedTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+
+ iTestData->SetTestType(CTestData::ESend);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Send a message
+
+ //for sending a message
+ char *recipient_id, *msg;
+
+ recipient_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+ //call the SendMessage test case
+ TInt sendmsg_state = CTestData::EMessageNotSent;
+
+ for( TInt cnt =0 ; cnt < KRepeatedMessageCount ; cnt++ )
+ {
+ sendmsg_state = iSendMsgObj->SendMessage(recipient_id,msg,iTestData);
+
+ if( sendmsg_state != CTestData::EMessageSent )
+ {
+ return_value = KErrGeneral; //Error in Sending message
+ break;
+ }
+ }
+
+
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::ReceiveRepeatedMessageTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::ReceiveRepeatedMessageTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::EReceive);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //Get the contact_id and the message.
+ char *recipient_id, *msg;
+
+ recipient_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+
+ //Do the receive message test case
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+ TInt recvmsg_state = CTestData::EMessageNotSent;
+
+ for( TInt cnt =0 ; cnt < KRepeatedMessageCount ; cnt++ )
+ {
+ iTestData->SetSendRecvMsgState(CTestData::EMessageNotSent);
+ recvmsg_state = iSendMsgObj->ReceiveMessage(recipient_id,msg,iTestData);
+
+ if( recvmsg_state != CTestData::EMessageRecvd )
+ {
+ return_value = KErrGeneral;
+ break;
+ }
+ }
+
+ //do the logout and the cleanup
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //login didnot happen successfully
+ return_value = KErrGeneral;
+ }
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::ReceiveMessageTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::ReceiveMessageTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::EReceive);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //Get the contact_id and the message.
+ char *recipient_id, *msg;
+
+ recipient_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ iLog->Log( _L("ReceiveMessageTestL:: Logged In \n") );
+
+ //Do the receive message test case
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+ TInt recvmsg_state = iSendMsgObj->ReceiveMessage(recipient_id,msg,iTestData);
+
+ if( recvmsg_state != CTestData::EMessageRecvd )
+ {
+ iLog->Log( _L("ReceiveMessageTestL:: receive Error \n") );
+ return_value = KErrGeneral;
+ }
+ //do the logout and the cleanup
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ iLog->Log( _L("ReceiveMessageTestL:: Logout Error \n") );
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //login didnot happen successfully
+ return_value = KErrGeneral;
+ }
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::ReceiveMessageBlankTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::ReceiveMessageBlankTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::ERecvBlank);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ iLog->Log( _L("ReceiveMessageBlankTestL:: Logged In \n") );
+ //Get the contact_id and the message.
+ char *recipient_id, *msg;
+
+ recipient_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ //Set the message to blamk string
+ msg = "";
+
+ //Do the receive message test case
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+ TInt recvmsg_state = iSendMsgObj->ReceiveMessage(recipient_id,msg,iTestData);
+
+ if( recvmsg_state == CTestData::EMessageNotSent )
+ {
+ iLog->Log( _L("ReceiveMessageBlankTestL:: EMESSAGE_NOT_SENT \n") );
+ return_value = KErrNone; //Error in Sending message
+ }
+
+ iLog->Log( _L("ReceiveMessageBlankTestL:: b4 action_logout \n") );
+ //do the logout and the cleanup
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ iLog->Log( _L("ReceiveMessageBlankTestL:: logout error \n") );
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //login didnot happen successfully
+ return_value = KErrGeneral;
+ }
+ free_data (connect_data, iLog );
+ return return_value;
+
+ }
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::ReceiveMessageMaxLengthTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::ReceiveMessageMaxLengthTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::EReceive);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //Get the contact_id and the message.
+ char *recipient_id;
+ //char *msg;
+
+ recipient_id = connect_data->msg_data->recipient;
+ // msg = connect_data->msg_data->message; //not required
+
+ //Set the message to maxlength string( with 400 chars)
+ char *max_len_msg = {"abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghij"};
+
+ //Do the receive message test case
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+ TInt recvmsg_state = iSendMsgObj->ReceiveMessage(recipient_id,max_len_msg,iTestData);
+
+ if( recvmsg_state != CTestData::EMessageRecvd )
+ {
+ return_value = KErrGeneral;
+ }
+ //do the logout and the cleanup
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //login didnot happen successfully
+ return_value = KErrGeneral;
+ }
+ free_data (connect_data, iLog );
+ return return_value;
+
+ }
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginCancelTestL
+// Test for Cancelling the login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::LoginCancelTestL(
+ CStifItemParser& aItem )
+ {
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_cancel(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED )
+ {
+ //i.e the login didnot happen successfully
+ //which is correct, since this is a cancel test case.
+ return KErrNone;
+ }
+ return KErrGeneral; //login status must be disconnceted else an error
+ }
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginInvalidUseridTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::LoginInvalidUseridTestL( CStifItemParser& aItem )
+{
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+ //i.e. login didnot happen with invalid user-id and passwd
+ return KErrNone;
+ }
+
+ return KErrGeneral; //login status must be disconnceted else an error
+}
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginInvalidPasswdTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::LoginInvalidPasswdTestL( CStifItemParser& aItem )
+{
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+ //i.e. login didnot happen with invalid user-id and passwd
+ return (KErrNone);
+ }
+
+ return KErrGeneral; //login status must be disconnceted else an error
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::LoginInvalidUseridPasswdTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::LoginInvalidUseridPasswdTestL(
+ CStifItemParser& aItem )
+{
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ free_data (connect_data, iLog );
+
+ if (login_status == CTestData::EDISCONNECTED)
+ {
+ //i.e. login didnot happen with invalid user-id and passwd
+ return KErrNone;
+ }
+
+ return KErrGeneral; //login status must be disconnceted else an error
+}
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SendMessageWith400TestL
+// Test for login.
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SendMessageWith400TestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::ESend);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login( username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Send a message
+
+ //for sending a message
+ char *recipient_id;
+
+ recipient_id = connect_data->msg_data->recipient;
+ //msg = connect_data->msg_data->message;
+ //hardcode the message of 400 characters.
+ //Set the message to maxlength string( with 400 chars)
+ char *msg = {"abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghijklmnopqrstuvwxyzabcd \
+ abcdefghij"};
+
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+ //call the SendMessage test case
+ TInt sendmsg_state = iSendMsgObj->SendMessage(recipient_id,msg,iTestData );
+
+ if( sendmsg_state == CTestData::EMessageNotSent ||
+ sendmsg_state == CTestData::EMessageSendErr )
+ {
+ return_value = KErrGeneral; //Error in Sending message
+ }
+ else if( sendmsg_state == CTestData::EMessageSent )
+ {
+ // EMessageSent was expected
+ return_value = KErrNone;
+ }
+
+
+ //Do the logout.
+ login_status = iLoginObj->action_logout( iTestData );
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SendMesasgeToBlankUserIdTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+TInt CTelepathyGabbleTest::SendMesasgeToBlankUserIdTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::ESendErr);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Send a message
+
+ //for sending a message
+ char *recipient_id, *msg;
+
+ recipient_id = "";//hardcode the recipient for blank.
+
+ msg = connect_data->msg_data->message;
+
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+
+ //call the SendMessage test case
+ TInt sendmsg_state = iSendMsgObj->SendMessage(recipient_id,msg,iTestData);
+
+ if( sendmsg_state == CTestData::EMessageNotSent
+ || sendmsg_state == CTestData::EMessageSent )
+ {
+ return_value = KErrGeneral; //Error in Sending message
+ }
+ else if( sendmsg_state == CTestData::EMessageSendErr )
+ {
+ //If message sent to invalid userid or blank userid, state should EMessageSendErr
+ // This is used in case of SendMessagetoinvalidUseridTestL
+ return_value = KErrNone;
+ }
+
+ //Do the logout.
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SendMesasgeBlankTestL
+// Test for login.
+// -----------------------------------------------------------------------------
+TInt CTelepathyGabbleTest::SendMesasgeBlankTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iTestData->SetTestType(CTestData::ESend);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Send a message
+
+ //for sending a message
+ char *recipient_id, *msg;
+
+ recipient_id = connect_data->msg_data->recipient;
+ //msg = connect_data->msg_data->message;
+ //hardcode the message for blank.
+ msg = "";
+
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+ //call the SendMessage test case
+ TInt sendmsg_state = iSendMsgObj->SendMessage(recipient_id,msg,iTestData);
+ if( sendmsg_state != CTestData::EMessageSent )
+ {
+ //There was some error while sending the message.
+ return_value = KErrGeneral;
+ }
+
+
+ //Do the logout.
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SendMessagetoinvalidUseridTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SendMessagetoinvalidUseridTestL(
+ CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+
+ iTestData->SetTestType(CTestData::ESendErr);
+
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+ //Send a message
+
+ //for sending a message
+ char *recipient_id, *msg;
+
+ TInt testType = iTestData->GetTestType();
+
+ recipient_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ //Create the Object of Send Message class
+ iSendMsgObj = CTelepathyGabbleSendRecvMessage::NewL();
+
+
+
+ //call the SendMessage test case
+ TInt sendmsg_state = iSendMsgObj->SendMessage(recipient_id,msg,iTestData);
+
+ if( sendmsg_state == CTestData::EMessageNotSent ||
+ sendmsg_state == CTestData::EMessageSent )
+ {
+ // EMessageSendErr was expected
+ return_value = KErrGeneral; //Error in Sending message
+ }
+
+ else if( sendmsg_state == CTestData::EMessageSendErr )
+ {
+ //If message sent to invalid userid or blank userid, state should EMessageSendErr
+ // This is used in case of SendMessagetoinvalidUseridTestL
+ return_value = KErrNone;
+ }
+
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::RemoveContactWithBlankUserIdTestL
+// Test for removing blank userid
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::RemoveContactWithBlankUserIdTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login happened successfully.
+ //Create the AddDelete Contact class object.
+
+ //iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+ iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+
+
+ //Get the contact_id and the message.
+ char *contact_id, *msg;
+
+ contact_id = ""; //make the contactid as blank
+ msg = connect_data->msg_data->message;
+
+ TInt contact_status = iAddDelContactObj->remove_contact( contact_id, msg, iTestData );
+
+ if( contact_status == CTestData::EDELETE_FAIL )
+ {
+ return_value = KErrNone;
+ }
+
+ //Do the logout and then return KErrNone;
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral; //logout was not successful
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+ else
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;//login was not successful
+ }
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::AddContactWithBlankUserIdTestL
+// Test for Adding blank userid
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::AddContactWithBlankUserIdTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login happened successfully.
+ //Create the AddDelete Contact class object.
+
+ //iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+ iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+
+
+ //Get the contact_id and the message.
+ char *addcontact_id, *msg;
+
+ addcontact_id = ""; //make the contactid as blank
+ msg = connect_data->msg_data->message;
+
+ TInt addcontact_status = iAddDelContactObj->add_contact(addcontact_id,msg, iTestData );
+
+ if( addcontact_status == CTestData::EADD_FAIL )
+ {
+ return_value = KErrNone;
+ }
+
+ //Do the logout and then return KErrNone;
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral; //logout was not successful
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+ else
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;//login was not successful
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::AddContactTestL
+// Test for Adding Contact
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::AddContactTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login happened successfully.
+ //Create the AddDelete Contact class object.
+
+ //iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+ iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+
+
+ //Get the contact_id and the message.
+ char *addcontact_id, *msg;
+
+ addcontact_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ TInt addcontact_status = iAddDelContactObj->add_contact(addcontact_id,msg, iTestData );
+
+ if( addcontact_status != CTestData::EADD_SUCCESS )
+ {
+ return_value = KErrGeneral;
+ }
+
+ //Do the logout and then return KErrNone;
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral; //logout was not successful
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+ else
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;//login was not successful
+ }
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::AddContactAlreadyInRosterTestL
+// Test for Adding Contact which is already added
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::AddContactAlreadyInRosterTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login happened successfully.
+ //Create the AddDelete Contact class object.
+
+ iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+
+ //Get the contact_id and the message.
+ char *addcontact_id, *msg;
+
+ addcontact_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ TInt addcontact_status = iAddDelContactObj->add_contact(addcontact_id,msg, iTestData );
+
+ if( addcontact_status != CTestData::EADD_SUCCESS )
+ {
+ return_value = KErrGeneral;
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral;
+ }
+
+ }
+ else
+ {
+ //The function add_contact resets iAddDeleteContactStatus (in CTestData) to EADD_FAIL
+ //to check again that adding a contact already added was successful(EADD_SUCCESS)
+ //so no need to set here explicitly
+
+
+ addcontact_status = iAddDelContactObj->add_contact(addcontact_id,msg, iTestData );
+ if( addcontact_status != CTestData::EADD_SUCCESS )
+ {
+ return_value = KErrGeneral;
+ }
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral;
+ }
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+ else
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral; //login was not successful
+ }
+
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::RemoveContactAlreadyRemovedTestL
+// Test for removing Contact which is already removed
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::RemoveContactAlreadyRemovedTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login happened successfully.
+ //Create the AddDelete Contact class object.
+
+ iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+
+ //Get the contact_id and the message.
+ char *contact_id, *msg;
+
+ contact_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ TInt contact_status = iAddDelContactObj->add_contact( contact_id, msg, iTestData );
+
+ if( contact_status != CTestData::EADD_SUCCESS )
+ {
+ iLog->Log( _L("CTelepathyGabbleTest:: contact not added successfully \n") );
+ return_value = KErrGeneral;
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral;
+ }
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+ contact_status = iAddDelContactObj->remove_contact( contact_id, msg, iTestData );
+
+ if( contact_status != CTestData::EDELETE_SUCCESS )
+ {
+ //contact removed first time, so should be removed successfully, otherwise error
+ iLog->Log( _L("CTelepathyGabbleTest::First Time contact not deleted successfully \n") );
+ return_value = KErrGeneral;
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral;
+ }
+ }
+ else
+ {
+ //The function remove_contact resets iAddDeleteContactStatus (in CTestData) to EDELETE_FAIL
+ //to check again that removing a contact already removed was not successful,
+ // so no need to set here explicitly
+ iLog->Log( _L("CTelepathyGabbleTest::First Time contact deleted successfully \n") );
+ contact_status = iAddDelContactObj->remove_contact(contact_id,msg, iTestData );
+
+
+ // because contact to be removed was already deleted, so status should be EDELETE_FAIL
+ if( contact_status != CTestData::EDELETE_FAIL )
+ {
+ iLog->Log( _L("CTelepathyGabbleTest::Second Time deleted successfully, it should give some error \n") );
+ return_value = KErrGeneral;
+ }
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ iLog->Log( _L("CTelepathyGabbleTest::Error in logout \n") );
+ return_value = KErrGeneral;
+ }
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+ else
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral; //login was not successful
+ }
+
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::RemoveContactTestL
+// Test for removing a contact
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::RemoveContactTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status = iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login happened successfully.
+ //Create the AddDelete Contact class object.
+
+
+ iAddDelContactObj = CTelepathyGabbleAddDeleteContact::NewL();
+
+
+ //Get the contact_id and the message.
+ char *contact_id, *msg;
+
+ contact_id = connect_data->msg_data->recipient;
+ msg = connect_data->msg_data->message;
+
+ TInt removecontact_status = iAddDelContactObj->remove_contact( contact_id, msg, iTestData);
+
+ if( removecontact_status != CTestData::EDELETE_SUCCESS )
+ {
+ return_value = KErrGeneral;
+ }
+
+ //Do the logout and then return KErrNone;
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral; //logout was not successful
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+ }
+
+ else
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::RemoveInvalidContactTestL
+// Test for removing invalid userid
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::RemoveInvalidContactTestL(
+ CStifItemParser& aItem )
+
+{
+ TInt err = RemoveContactTestL(aItem);
+ if ( err == KErrGeneral
+ && iTestData->GetAddDeleteContactStatus() == CTestData::EDELETE_FAIL )
+ {
+ // This is correct, since the contact_id was invalid
+ return KErrNone;
+ }
+
+ return KErrGeneral;
+
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::FetchContactsTestL
+// Test for fetching contacts
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::FetchContactsTestL(
+ CStifItemParser& aItem )
+{
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data (connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ char *username, *passwd , *servername , *resource_login,*ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ iTestData = CTestData::NewL(iLog);
+
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,
+ servername, resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData);
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+
+ //if successfully logged in
+ //fetch the contacts
+
+ iFetchContactObj = CTelepathyGabbleFetchContacts::NewL();
+
+ return_value = iFetchContactObj->test_request_roster( iTestData );
+
+ //Do the logout and the cleanup.
+ login_status = iLoginObj->action_logout(iTestData);
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ return_value = KErrGeneral; //there was error in logout
+ }
+
+ }
+ else
+ {
+ return_value = KErrGeneral; //login didn't happen successfully
+ }
+
+ free_data (connect_data, iLog );
+ return return_value;
+
+}
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchTwiceTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchTwiceTestL( CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ GValue *gvalue = NULL;
+
+ char *key, *value;
+
+ key = connect_data->msg_data->recipient;
+ value = connect_data->msg_data->message;
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, value );
+ g_hash_table_insert( data_to_search, GetSearchLabelL(servername,key), gvalue);
+
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+
+ //call the SendMessage test case
+ TInt search_state = iSearchObj->SearchL(data_to_search, iTestData);
+
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ else if( search_state == CTestData::ESearchCompleted)
+ {
+ search_state = iSearchObj->SearchL(data_to_search, iTestData);
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ }
+ //return_value = KErrNone;
+ }
+
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::SearchFiveTimesTestL
+// -----------------------------------------------------------------------------
+
+TInt CTelepathyGabbleTest::SearchFiveTimesTestL( CStifItemParser& aItem )
+ {
+ TInt return_value = KErrNone;
+ //Pass the parameters to action_login() from the
+ //data mentioned in the cfg file.
+
+ //step 1: Do the login.
+ ConnectData *connect_data = NULL;
+
+ if ( read_data ( connect_data, aItem, iLog ) != RC_OK )
+ {
+ free_data ( connect_data, iLog );
+ return KErrGeneral;
+ }
+
+
+ //for login
+ char *username, *passwd , *servername , *resource_login, *ssl_flag, *port;
+ char *proxy_server = NULL;
+ char *proxy_port = NULL;
+
+
+ username = connect_data->username;
+ passwd = connect_data->password;
+ servername = connect_data->server;
+ resource_login = connect_data->resource;
+ ssl_flag = connect_data->ssl_flag;
+ port = connect_data->port;
+ #ifdef __WINSCW__
+ proxy_server = connect_data->proxy_data->proxy_server;
+ proxy_port = connect_data->proxy_data->proxy_port;
+ #endif
+
+
+ if (iTestData == NULL)
+ {
+ //Create the iTestData if it is not existing.
+
+ iTestData = CTestData::NewL(iLog);
+ }
+ iTestData->SetTestType(CTestData::ESearch);
+ //Create the login object
+ iLoginObj = CTelepathyGabbleLoginTest::NewL();
+
+ //action_login will have parameters
+ //passed from cfg file
+
+ TInt login_status =
+ iLoginObj->action_login(username,passwd,servername,
+ resource_login,ssl_flag,
+ port,proxy_server, proxy_port,
+ iTestData );
+
+ if (login_status == CTestData::ECONNECTED)
+ {
+ //login was successful
+
+ GHashTable *data_to_search = NULL;
+
+ GValue *gvalue = NULL;
+
+ char *key, *value;
+
+ key = connect_data->msg_data->recipient;
+ value = connect_data->msg_data->message;
+
+ data_to_search = g_hash_table_new(g_str_hash,g_str_equal);
+
+ gvalue = g_new0(GValue, 1);
+
+
+ g_value_init(gvalue, G_TYPE_STRING);
+ g_value_set_string (gvalue, value );
+ g_hash_table_insert( data_to_search, GetSearchLabelL(servername,key), gvalue);
+
+
+
+ //Create the Object of Send Message class
+ iSearchObj = CTelepathyGabbleSearch::NewL();
+
+ TInt search_state;
+
+ for(TInt i = 0; i<5 ;i++ )
+ {
+ search_state = iSearchObj->SearchL(data_to_search, iTestData);
+ if( search_state == CTestData::ESearchError )
+ {
+ return_value = KErrGeneral; //Error in Searching
+ break;
+ }
+ }
+ iSearchObj->CloseChannel(iTestData);
+ //Do the logout
+ login_status = iLoginObj->action_logout(iTestData);
+
+ if (login_status != CTestData::EDISCONNECTED)
+ {
+ //logout didnot happen successfully
+ return_value = KErrGeneral;
+ }
+
+ //do this later
+ /*g_hash_table_foreach_remove ( data_to_search,
+ search_hash_remove, NULL );*/
+
+ //Free the hash table itself
+ g_hash_table_destroy ( data_to_search );
+
+ }
+ else
+ {
+ //Login itself didnot happen.
+ return_value = KErrGeneral;
+ }
+
+ free_data ( connect_data, iLog );
+ return return_value;
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::GetSearchLabelForYukonL
+// -----------------------------------------------------------------------------
+gchar* CTelepathyGabbleTest::GetSearchLabelForYukonL(gchar *search_key)
+{
+if(strcmp(search_key,"user") == 0)
+ {
+ gchar* label= "User";
+ return label;
+ }
+else if(strcmp(search_key,"fn") == 0)
+ {
+ gchar* label= "Full Name";
+ return label;
+ }
+else if(strcmp(search_key,"first") == 0)
+ {
+ gchar* label= "Name";
+ return label;
+ }
+else if(strcmp(search_key,"middle") == 0)
+ {
+ gchar* label= "Middle Name";
+ return label;
+ }
+else if(strcmp(search_key,"last") == 0)
+ {
+ gchar* label= "Family Name";
+ return label;
+ }
+else if(strcmp(search_key,"nick") == 0)
+ {
+ gchar* label= "Nickname";
+ return label;
+ }
+else if(strcmp(search_key,"email") == 0)
+ {
+ gchar* label= "Email";
+ return label;
+ }
+else if(strcmp(search_key,"bday") == 0)
+ {
+ gchar* label= "Birthday";
+ return label;
+ }
+else if(strcmp(search_key,"ctry") == 0)
+ {
+ gchar* label= "Country";
+ return label;
+ }
+else if(strcmp(search_key,"orgname") == 0)
+ {
+ gchar* label= "Organization Name";
+ return label;
+ }
+else if(strcmp(search_key,"locality") == 0)
+ {
+ gchar* label= "City";
+ return label;
+ }
+else if(strcmp(search_key,"orgunit") == 0)
+ {
+ gchar* label= "Organization Unit";
+ return label;
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::GetSearchLabelForGizmoL
+// -----------------------------------------------------------------------------
+gchar* CTelepathyGabbleTest::GetSearchLabelForGizmoL(gchar *search_key)
+{
+if(strcmp(search_key,"xmpp_user") == 0)
+ {
+ gchar* label= "Account Name";
+ return label;
+ }
+else if(strcmp(search_key,"email_address") == 0)
+ {
+ gchar* label= "Email Address";
+ return label;
+ }
+else if(strcmp(search_key,"first_name") == 0)
+ {
+ gchar* label= "First Name";
+ return label;
+ }
+else if(strcmp(search_key,"last_name") == 0)
+ {
+ gchar* label= "Family Name";
+ return label;
+ }
+else if(strcmp(search_key,"country") == 0)
+ {
+ gchar* label= "Country";
+ return label;
+ }
+else if(strcmp(search_key,"state") == 0)
+ {
+ gchar* label= "State/Province";
+ return label;
+ }
+else if(strcmp(search_key,"city") == 0)
+ {
+ gchar* label= "City";
+ return label;
+ }
+else if(strcmp(search_key,"max_results") == 0)
+ {
+ gchar* label= "Maximum # of Results";
+ return label;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// CTelepathyGabbleTest::GetSearchLabelL
+// -----------------------------------------------------------------------------
+gchar* CTelepathyGabbleTest::GetSearchLabelL(gchar* aService,gchar* aSearchKey)
+{
+if(strcmp(aService,"chat.gizmoproject.com") == 0)
+ {
+ GetSearchLabelForGizmoL(aSearchKey);
+ }
+else if(strcmp(aService,"chat.ovi.com") == 0 )
+ {
+ GetSearchLabelForYukonL(aSearchKey);
+ }
+}
+
+
+
+/**
+* Free function for the hash key/value pairs
+*/
+/*gboolean search_hash_remove( gpointer key, gpointer value,
+ gpointer user_data )
+ {
+
+ //Free function for the hash values
+ if ( key )
+ {
+ free( key );
+ }
+ if ( value )
+ {
+ free ( value );
+ }
+
+ return TRUE;
+ }
+*/
+//End of File
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabbletestdata.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,514 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: File containing Test Data at the global level (used by different test objects)
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "telepathygabbletestdata.h"
+#include <StifLogger.h>
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+
+CTestData::CTestData(CStifLogger *aLogger)
+ : iLogger(aLogger)
+ {
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ConstructL
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+
+void CTestData::ConstructL()
+ {
+ iConnectionState = EDISCONNECTED; //default.
+ iTestType = EOther;
+ //Create the mainloop and also add the callback.
+ iMainLoop = g_main_loop_new (NULL, FALSE);
+ iSendRecvState = EMessageNotSent;
+ iAddDeleteContactStatus = EADD_FAIL;
+ iSearchState = ESearchStarted;
+ iSearchKeys = g_new0( gchar*, 1);
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : NewL
+// description : Constructor
+// Returns : None
+//-----------------------------------------------------------------------------
+CTestData* CTestData::NewL(CStifLogger *aLogger)
+ {
+
+ CTestData* self = new(ELeave) CTestData(aLogger);
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : ~CTestData
+// description : destructor
+// Returns : None
+//-----------------------------------------------------------------------------
+CTestData::~CTestData()
+ {
+
+ if( iLogger )
+ {
+ iLogger->Log( _L("~CTestData in\n") );
+ }
+ //Destroy the hash table for text channels
+
+ if( iTextChannelHashTable )
+ {
+ g_hash_table_destroy( iTextChannelHashTable );
+ iTextChannelHashTable = NULL;
+ }
+
+ //Dbus connection object
+ if( iDBusConnection )
+ {
+ dbus_g_connection_unref (iDBusConnection);
+ iDBusConnection = NULL;
+ }
+
+ if( iTpConnMgr )
+ {
+ g_object_unref (iTpConnMgr);
+ iTpConnMgr = NULL;
+ }
+
+ //tp conn object
+ if( iTpConn )
+ {
+ g_object_unref (iTpConn);
+ iTpConn = NULL;
+ }
+
+ //main loop
+ if( iMainLoop )
+ {
+ g_main_loop_unref ( iMainLoop );
+ iMainLoop = NULL;
+ }
+
+
+ if( iSearchKeys )
+ {
+ for( TInt i=0; iSearchKeys[i]; i++ )
+ {
+ g_free( iSearchKeys[i] );
+ iSearchKeys[i] = NULL;
+ }
+ g_free( iSearchKeys );
+ iSearchKeys = NULL;
+ }
+
+ if( iLogger )
+ {
+ iLogger->Log( _L("~CTestData out\n") );
+ }
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetStifLogger
+//-----------------------------------------------------------------------------
+
+CStifLogger* CTestData::GetStifLogger()
+ {
+ return iLogger;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetMainLoop
+//-----------------------------------------------------------------------------
+
+GMainLoop* CTestData::GetMainLoop()
+ {
+ return iMainLoop;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupSubscribeInterface
+//-----------------------------------------------------------------------------
+
+DBusGProxy* CTestData::GetGroupSubscribeInterface()
+ {
+ return iGroupSubscribeInterface;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupKnownInterface
+//-----------------------------------------------------------------------------
+
+DBusGProxy* CTestData::GetGroupKnownInterface()
+ {
+ return iGroupKnownInterface;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupPublishInterface
+//-----------------------------------------------------------------------------
+
+DBusGProxy* CTestData::GetGroupPublishInterface()
+ {
+ return iGroupPublishInterface;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupDenyInterface
+//-----------------------------------------------------------------------------
+
+DBusGProxy* CTestData::GetGroupDenyInterface()
+ {
+ return iGroupDenyInterface;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetTextChannelsHT
+//-----------------------------------------------------------------------------
+
+GHashTable* CTestData::GetTextChannelsHT()
+ {
+ return iTextChannelHashTable;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : SetGroupSubscribeInterface
+//-----------------------------------------------------------------------------
+
+void CTestData::SetGroupSubscribeInterface( DBusGProxy* aGroupSubscribeInterface )
+ {
+ iGroupSubscribeInterface = aGroupSubscribeInterface;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupKnownInterface
+//-----------------------------------------------------------------------------
+
+void CTestData::SetGroupKnownInterface( DBusGProxy* aGroupKnownInterface )
+ {
+ iGroupKnownInterface = aGroupKnownInterface;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupPublishInterface
+//-----------------------------------------------------------------------------
+
+void CTestData::SetGroupPublishInterface( DBusGProxy* aGroupPublishInterface )
+ {
+ iGroupPublishInterface = aGroupPublishInterface;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetGroupDenyInterface
+//-----------------------------------------------------------------------------
+void CTestData::SetGroupDenyInterface(DBusGProxy* aGroupDenyInterface)
+ {
+ iGroupDenyInterface = aGroupDenyInterface;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetTextChannelsHT
+//-----------------------------------------------------------------------------
+
+void CTestData::SetTextChannelsHT( GHashTable* aTextChannelHashTable )
+ {
+ iTextChannelHashTable = aTextChannelHashTable;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : GetDBusConnection
+//-----------------------------------------------------------------------------
+DBusGConnection* CTestData::GetDBusConnection()
+ {
+ return iDBusConnection;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+// description : SetDBusConnection
+//-----------------------------------------------------------------------------
+void CTestData::SetDBusConnection( DBusGConnection* aDBusConnection )
+ {
+ iDBusConnection = aDBusConnection;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetTpConn
+//-----------------------------------------------------------------------------
+
+TpConn* CTestData::GetTpConn()
+ {
+ return iTpConn;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTpConn
+//-----------------------------------------------------------------------------
+
+void CTestData::SetTpConn(TpConn* aTpConn)
+ {
+ iTpConn = aTpConn;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTpConnMgr
+//-----------------------------------------------------------------------------
+
+void CTestData::SetTpConnMgr(TpConnMgr* aTpConnMgr)
+ {
+ iTpConnMgr = aTpConnMgr;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetLoginCompleteFlag
+//-----------------------------------------------------------------------------
+
+TInt CTestData::GetLoginCompleteFlag()
+ {
+ return iLoginComplete;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : IncLoginCompleteFlag
+//-----------------------------------------------------------------------------
+
+void CTestData::IncLoginCompleteFlag()
+ {
+ iLoginComplete++;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : ResetLoginCompleteFlag
+//-----------------------------------------------------------------------------
+
+void CTestData::ResetLoginCompleteFlag()
+ {
+ iLoginComplete = 0;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+TInt CTestData::GetTotalFetchCount()
+ {
+ return iTotalFetchCount;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetLastIndexInFetch
+//-----------------------------------------------------------------------------
+
+TInt CTestData::GetLastIndexInFetch()
+ {
+ return iLastIndex;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetLastIndexInFetch
+//-----------------------------------------------------------------------------
+
+void CTestData::SetLastIndexInFetch( TInt aLastIndex )
+ {
+ iLastIndex = aLastIndex;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+void CTestData::SetTotalFetchCount(TInt aValue)
+ {
+ iTotalFetchCount = aValue;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+CTestData::TConnectionState CTestData::GetConnectionState()
+ {
+ return iConnectionState;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+void CTestData::SetConnectionState(TConnectionState aConnectionState)
+ {
+ iConnectionState = aConnectionState;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+CTestData::TSendRecvState CTestData::GetSendRecvMsgState()
+ {
+ return iSendRecvState;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+void CTestData::SetSendRecvMsgState(TSendRecvState aSendRecvState)
+ {
+ iSendRecvState = aSendRecvState;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+CTestData::TAddDeleteContactStatus CTestData::GetAddDeleteContactStatus()
+ {
+ return iAddDeleteContactStatus;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTotalFetchCount
+//-----------------------------------------------------------------------------
+
+void CTestData::SetAddDeleteContactStatus(TAddDeleteContactStatus aAddDeleteContactStatus)
+ {
+ iAddDeleteContactStatus = aAddDeleteContactStatus;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetSearchState
+//-----------------------------------------------------------------------------
+
+CTestData::TSearchState CTestData::GetSearchState()
+ {
+ return iSearchState;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetSearchState
+//-----------------------------------------------------------------------------
+
+void CTestData::SetSearchState(TSearchState aSearchState)
+ {
+ iSearchState = aSearchState;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetTestType
+//-----------------------------------------------------------------------------
+
+CTestData::TTestType CTestData::GetTestType( )
+ {
+ return iTestType;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetTestType
+//-----------------------------------------------------------------------------
+
+void CTestData::SetTestType(TTestType aTestType)
+ {
+ iTestType = aTestType;
+ }
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetSearchKeys
+//-----------------------------------------------------------------------------
+
+void CTestData::SetSearchKeys( gchar **aKeys )
+ {
+ TInt i = 0;
+ for( i=0; aKeys[i]; i++ )
+ {
+ iSearchKeys[i] = g_strdup(aKeys[i]);
+ }
+ iSearchKeys[i] = aKeys[i];
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetSearchKeys
+//-----------------------------------------------------------------------------
+
+gchar** CTestData::GetSearchKeys( )
+ {
+ return iSearchKeys;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : SetSearchChan
+//-----------------------------------------------------------------------------
+
+void CTestData::SetSearchChan(TpChan *aSearchChan )
+ {
+ iSearchChan = aSearchChan;
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : CTestData
+/// description : GetSearchChan
+//-----------------------------------------------------------------------------
+
+TpChan* CTestData::GetSearchChan( )
+ {
+ return iSearchChan;
+ }
+
+
+//End of File
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libtelepathy/tsrc/src/telepathygabbleutils.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: File containing Utility functions
+*
+*/
+
+
+
+
+
+//Include files
+#include <e32err.h>
+#include <e32const.h>
+#include <e32base.h>
+
+#include <glib.h>
+
+#include "telepathygabbletestdata.h"
+#include "telepathygabbleutils.h"
+
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : CTelepathyGabbleUtils
+// description : constructor
+//-----------------------------------------------------------------------------
+guint CTelepathyGabbleUtils::get_handle_from_contact ( const gchar *contact_id,
+ CTestData* aTestData)
+
+{
+
+ guint handle;
+ gboolean success;
+ GError *error = NULL;
+
+
+ //check for the return value if 0 is ok or should some negative value to be passed
+ g_return_val_if_fail (contact_id != NULL, 0);
+
+ GArray *handles = NULL;
+ const gchar *contact_ids[2] ; //contact_ids initialization here gives error ..may be some compiler issue as otherwise okay to initialze here
+
+
+ contact_ids[0]= contact_id;
+ contact_ids[1]= NULL;
+
+
+ success = tp_conn_request_handles (DBUS_G_PROXY (aTestData->GetTpConn()),
+ TP_CONN_HANDLE_TYPE_CONTACT,
+ contact_ids, &handles, &error);
+ if( !handles || error )
+ {
+ //do some error handling here
+
+ g_error_free(error);
+ return KErrNotFound;
+ }
+
+
+ handle = g_array_index(handles, guint, 0);
+ g_array_free (handles, TRUE);
+
+
+ if (!success)
+ {
+ //test_log_handler ( error->message );
+ g_clear_error (&error);
+
+ //check for the return value if 0 is ok or should some negative value to be passed
+ return 0;
+ }
+
+ return handle;
+}
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/bwins/loudmouthu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,87 @@
+EXPORTS
+ lm_connection_authenticate @ 1 NONAME
+ lm_connection_authenticate_and_block @ 2 NONAME
+ lm_connection_cancel_open @ 3 NONAME
+ lm_connection_close @ 4 NONAME
+ lm_connection_get_full_jid @ 5 NONAME
+ lm_connection_get_jid @ 6 NONAME
+ lm_connection_get_keep_alive_rate @ 7 NONAME
+ lm_connection_get_local_host @ 8 NONAME
+ lm_connection_get_port @ 9 NONAME
+ lm_connection_get_proxy @ 10 NONAME
+ lm_connection_get_server @ 11 NONAME
+ lm_connection_get_ssl @ 12 NONAME
+ lm_connection_get_state @ 13 NONAME
+ lm_connection_is_authenticated @ 14 NONAME
+ lm_connection_is_open @ 15 NONAME
+ lm_connection_new @ 16 NONAME
+ lm_connection_new_with_context @ 17 NONAME
+ lm_connection_open @ 18 NONAME
+ lm_connection_open_and_block @ 19 NONAME
+ lm_connection_ref @ 20 NONAME
+ lm_connection_register_message_handler @ 21 NONAME
+ lm_connection_send @ 22 NONAME
+ lm_connection_send_raw @ 23 NONAME
+ lm_connection_send_with_reply @ 24 NONAME
+ lm_connection_send_with_reply_and_block @ 25 NONAME
+ lm_connection_set_disconnect_function @ 26 NONAME
+ lm_connection_set_jid @ 27 NONAME
+ lm_connection_set_keep_alive_rate @ 28 NONAME
+ lm_connection_set_port @ 29 NONAME
+ lm_connection_set_proxy @ 30 NONAME
+ lm_connection_set_server @ 31 NONAME
+ lm_connection_set_ssl @ 32 NONAME
+ lm_connection_unref @ 33 NONAME
+ lm_connection_unregister_message_handler @ 34 NONAME
+ lm_error_quark @ 35 NONAME
+ lm_message_get_node @ 36 NONAME
+ lm_message_get_sub_type @ 37 NONAME
+ lm_message_get_type @ 38 NONAME
+ lm_message_handler_invalidate @ 39 NONAME
+ lm_message_handler_is_valid @ 40 NONAME
+ lm_message_handler_new @ 41 NONAME
+ lm_message_handler_ref @ 42 NONAME
+ lm_message_handler_unref @ 43 NONAME
+ lm_message_new @ 44 NONAME
+ lm_message_new_with_sub_type @ 45 NONAME
+ lm_message_node_add_child @ 46 NONAME
+ lm_message_node_find_child @ 47 NONAME
+ lm_message_node_get_attribute @ 48 NONAME
+ lm_message_node_get_child @ 49 NONAME
+ lm_message_node_get_raw_mode @ 50 NONAME
+ lm_message_node_get_value @ 51 NONAME
+ lm_message_node_ref @ 52 NONAME
+ lm_message_node_set_attribute @ 53 NONAME
+ lm_message_node_set_attributes @ 54 NONAME
+ lm_message_node_set_raw_mode @ 55 NONAME
+ lm_message_node_set_value @ 56 NONAME
+ lm_message_node_to_string @ 57 NONAME
+ lm_message_node_unref @ 58 NONAME
+ lm_message_ref @ 59 NONAME
+ lm_message_unref @ 60 NONAME
+ lm_parser_free @ 61 NONAME
+ lm_parser_new @ 62 NONAME
+ lm_parser_parse @ 63 NONAME
+ lm_proxy_get_password @ 64 NONAME
+ lm_proxy_get_port @ 65 NONAME
+ lm_proxy_get_server @ 66 NONAME
+ lm_proxy_get_type @ 67 NONAME
+ lm_proxy_get_username @ 68 NONAME
+ lm_proxy_new @ 69 NONAME
+ lm_proxy_new_with_server @ 70 NONAME
+ lm_proxy_ref @ 71 NONAME
+ lm_proxy_set_password @ 72 NONAME
+ lm_proxy_set_port @ 73 NONAME
+ lm_proxy_set_server @ 74 NONAME
+ lm_proxy_set_type @ 75 NONAME
+ lm_proxy_set_username @ 76 NONAME
+ lm_proxy_unref @ 77 NONAME
+ lm_sha_hash @ 78 NONAME
+ lm_ssl_get_fingerprint @ 79 NONAME
+ lm_ssl_is_supported @ 80 NONAME
+ lm_ssl_new @ 81 NONAME
+ lm_ssl_ref @ 82 NONAME
+ lm_ssl_unref @ 83 NONAME
+ lm_ssl_use_starttls @ 84 NONAME
+ lm_utils_get_localtime @ 85 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/bwinscw/loudmouthu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,83 @@
+EXPORTS
+ lm_connection_authenticate @ 1 NONAME
+ lm_connection_authenticate_and_block @ 2 NONAME
+ lm_connection_cancel_open @ 3 NONAME
+ lm_connection_close @ 4 NONAME
+ lm_connection_get_jid @ 5 NONAME
+ lm_connection_get_port @ 6 NONAME
+ lm_connection_get_proxy @ 7 NONAME
+ lm_connection_get_server @ 8 NONAME
+ lm_connection_get_ssl @ 9 NONAME
+ lm_connection_get_state @ 10 NONAME
+ lm_connection_is_authenticated @ 11 NONAME
+ lm_connection_is_open @ 12 NONAME
+ lm_connection_new @ 13 NONAME
+ lm_connection_new_with_context @ 14 NONAME
+ lm_connection_open @ 15 NONAME
+ lm_connection_open_and_block @ 16 NONAME
+ lm_connection_ref @ 17 NONAME
+ lm_connection_register_message_handler @ 18 NONAME
+ lm_connection_send @ 19 NONAME
+ lm_connection_send_raw @ 20 NONAME
+ lm_connection_send_with_reply @ 21 NONAME
+ lm_connection_send_with_reply_and_block @ 22 NONAME
+ lm_connection_set_disconnect_function @ 23 NONAME
+ lm_connection_set_jid @ 24 NONAME
+ lm_connection_set_keep_alive_rate @ 25 NONAME
+ lm_connection_set_port @ 26 NONAME
+ lm_connection_set_proxy @ 27 NONAME
+ lm_connection_set_server @ 28 NONAME
+ lm_connection_set_ssl @ 29 NONAME
+ lm_connection_unref @ 30 NONAME
+ lm_connection_unregister_message_handler @ 31 NONAME
+ lm_error_quark @ 32 NONAME
+ lm_message_get_node @ 33 NONAME
+ lm_message_get_sub_type @ 34 NONAME
+ lm_message_get_type @ 35 NONAME
+ lm_message_handler_invalidate @ 36 NONAME
+ lm_message_handler_is_valid @ 37 NONAME
+ lm_message_handler_new @ 38 NONAME
+ lm_message_handler_ref @ 39 NONAME
+ lm_message_handler_unref @ 40 NONAME
+ lm_message_new @ 41 NONAME
+ lm_message_new_with_sub_type @ 42 NONAME
+ lm_message_node_add_child @ 43 NONAME
+ lm_message_node_find_child @ 44 NONAME
+ lm_message_node_get_attribute @ 45 NONAME
+ lm_message_node_get_child @ 46 NONAME
+ lm_message_node_get_raw_mode @ 47 NONAME
+ lm_message_node_get_value @ 48 NONAME
+ lm_message_node_ref @ 49 NONAME
+ lm_message_node_set_attribute @ 50 NONAME
+ lm_message_node_set_attributes @ 51 NONAME
+ lm_message_node_set_raw_mode @ 52 NONAME
+ lm_message_node_set_value @ 53 NONAME
+ lm_message_node_to_string @ 54 NONAME
+ lm_message_node_unref @ 55 NONAME
+ lm_message_ref @ 56 NONAME
+ lm_message_unref @ 57 NONAME
+ lm_parser_free @ 58 NONAME
+ lm_parser_new @ 59 NONAME
+ lm_parser_parse @ 60 NONAME
+ lm_proxy_get_password @ 61 NONAME
+ lm_proxy_get_port @ 62 NONAME
+ lm_proxy_get_server @ 63 NONAME
+ lm_proxy_get_type @ 64 NONAME
+ lm_proxy_get_username @ 65 NONAME
+ lm_proxy_new @ 66 NONAME
+ lm_proxy_new_with_server @ 67 NONAME
+ lm_proxy_ref @ 68 NONAME
+ lm_proxy_set_password @ 69 NONAME
+ lm_proxy_set_port @ 70 NONAME
+ lm_proxy_set_server @ 71 NONAME
+ lm_proxy_set_type @ 72 NONAME
+ lm_proxy_set_username @ 73 NONAME
+ lm_proxy_unref @ 74 NONAME
+ lm_sha_hash @ 75 NONAME
+ lm_ssl_get_fingerprint @ 76 NONAME
+ lm_ssl_is_supported @ 77 NONAME
+ lm_ssl_new @ 78 NONAME
+ lm_ssl_ref @ 79 NONAME
+ lm_ssl_unref @ 80 NONAME
+ lm_utils_get_localtime @ 81 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/eabi/loudmouthu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,83 @@
+EXPORTS
+ lm_connection_authenticate @ 1 NONAME
+ lm_connection_authenticate_and_block @ 2 NONAME
+ lm_connection_cancel_open @ 3 NONAME
+ lm_connection_close @ 4 NONAME
+ lm_connection_get_jid @ 5 NONAME
+ lm_connection_get_port @ 6 NONAME
+ lm_connection_get_proxy @ 7 NONAME
+ lm_connection_get_server @ 8 NONAME
+ lm_connection_get_ssl @ 9 NONAME
+ lm_connection_get_state @ 10 NONAME
+ lm_connection_is_authenticated @ 11 NONAME
+ lm_connection_is_open @ 12 NONAME
+ lm_connection_new @ 13 NONAME
+ lm_connection_new_with_context @ 14 NONAME
+ lm_connection_open @ 15 NONAME
+ lm_connection_open_and_block @ 16 NONAME
+ lm_connection_ref @ 17 NONAME
+ lm_connection_register_message_handler @ 18 NONAME
+ lm_connection_send @ 19 NONAME
+ lm_connection_send_raw @ 20 NONAME
+ lm_connection_send_with_reply @ 21 NONAME
+ lm_connection_send_with_reply_and_block @ 22 NONAME
+ lm_connection_set_disconnect_function @ 23 NONAME
+ lm_connection_set_jid @ 24 NONAME
+ lm_connection_set_keep_alive_rate @ 25 NONAME
+ lm_connection_set_port @ 26 NONAME
+ lm_connection_set_proxy @ 27 NONAME
+ lm_connection_set_server @ 28 NONAME
+ lm_connection_set_ssl @ 29 NONAME
+ lm_connection_unref @ 30 NONAME
+ lm_connection_unregister_message_handler @ 31 NONAME
+ lm_error_quark @ 32 NONAME
+ lm_message_get_node @ 33 NONAME
+ lm_message_get_sub_type @ 34 NONAME
+ lm_message_get_type @ 35 NONAME
+ lm_message_handler_invalidate @ 36 NONAME
+ lm_message_handler_is_valid @ 37 NONAME
+ lm_message_handler_new @ 38 NONAME
+ lm_message_handler_ref @ 39 NONAME
+ lm_message_handler_unref @ 40 NONAME
+ lm_message_new @ 41 NONAME
+ lm_message_new_with_sub_type @ 42 NONAME
+ lm_message_node_add_child @ 43 NONAME
+ lm_message_node_find_child @ 44 NONAME
+ lm_message_node_get_attribute @ 45 NONAME
+ lm_message_node_get_child @ 46 NONAME
+ lm_message_node_get_raw_mode @ 47 NONAME
+ lm_message_node_get_value @ 48 NONAME
+ lm_message_node_ref @ 49 NONAME
+ lm_message_node_set_attribute @ 50 NONAME
+ lm_message_node_set_attributes @ 51 NONAME
+ lm_message_node_set_raw_mode @ 52 NONAME
+ lm_message_node_set_value @ 53 NONAME
+ lm_message_node_to_string @ 54 NONAME
+ lm_message_node_unref @ 55 NONAME
+ lm_message_ref @ 56 NONAME
+ lm_message_unref @ 57 NONAME
+ lm_parser_free @ 58 NONAME
+ lm_parser_new @ 59 NONAME
+ lm_parser_parse @ 60 NONAME
+ lm_proxy_get_password @ 61 NONAME
+ lm_proxy_get_port @ 62 NONAME
+ lm_proxy_get_server @ 63 NONAME
+ lm_proxy_get_type @ 64 NONAME
+ lm_proxy_get_username @ 65 NONAME
+ lm_proxy_new @ 66 NONAME
+ lm_proxy_new_with_server @ 67 NONAME
+ lm_proxy_ref @ 68 NONAME
+ lm_proxy_set_password @ 69 NONAME
+ lm_proxy_set_port @ 70 NONAME
+ lm_proxy_set_server @ 71 NONAME
+ lm_proxy_set_type @ 72 NONAME
+ lm_proxy_set_username @ 73 NONAME
+ lm_proxy_unref @ 74 NONAME
+ lm_ssl_get_fingerprint @ 75 NONAME
+ lm_ssl_is_supported @ 76 NONAME
+ lm_ssl_new @ 77 NONAME
+ lm_ssl_ref @ 78 NONAME
+ lm_ssl_unref @ 79 NONAME
+ lm_ssl_use_starttls @ 80 NONAME
+ lm_utils_get_localtime @ 81 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,28 @@
+/*
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+PRJ_PLATFORMS
+DEFAULT
+
+#include <platform_paths.hrh>
+PRJ_EXPORTS
+../rom/loudmouth.iby CORE_MW_LAYER_IBY_EXPORT_PATH(loudmouth.iby)
+
+PRJ_MMPFILES
+loudmouth.mmp
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/group/loudmouth.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,130 @@
+/*
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include<platform_paths.hrh>
+TARGET loudmouth.dll
+TARGETTYPE DLL
+UID 0x1000008d 0x2000F851
+
+VERSION 10.1
+#ifdef EKA2
+LANG SC
+CAPABILITY All -TCB
+VENDORID VID_DEFAULT
+
+#endif
+
+#if !defined(__WINSCW__) && !defined(__WINS__)
+EpocAllowDllData
+#endif
+
+MACRO SYMBIAN
+MACRO HAVE_CONFIG_H
+
+MACRO LM_COMPILATION
+
+MACRO USE_TCP_KEEPALIVES
+#ifdef WINSCW
+MACRO EMULATOR
+#endif
+
+#ifndef WINSCW
+#define LM_NO_DEBUG
+#endif
+
+
+//EXPORTUNFROZEN
+
+USERINCLUDE ../inc
+USERINCLUDE ../inc/loudmouth
+
+SYSTEMINCLUDE ../inc
+SYSTEMINCLUDE /epoc32/include
+
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_BOOST_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+OS_LAYER_LIBUTILITY_SYSTEMINCLUDE
+
+//#endif
+
+
+
+/* Loudmouth source files */
+SOURCEPATH ../src
+
+SOURCE lm-connection.c
+SOURCE lm-debug.c
+SOURCE lm-error.c
+SOURCE lm-message.c
+SOURCE lm-message-handler.c
+SOURCE lm-message-node.c
+SOURCE lm-parser.c
+SOURCE lm-proxy.c
+SOURCE lm-sha.c
+SOURCE lm-sock.c
+SOURCE lm-ssl-base.c
+SOURCE lm-ssl-generic.c
+SOURCE lm-ssl-gnutls.c
+SOURCE lm-ssl-openssl.c
+SOURCE lm-utils.c
+SOURCE lm-socket.c
+SOURCE lm-message-queue.c
+SOURCE lm-sasl.c
+SOURCE lm-misc.c
+SOURCE md5.c
+SOURCE base64.c
+#ifdef WINSCW
+SOURCE libloudmouth_wsd.cpp
+#endif
+
+
+
+LIBRARY libc.lib
+LIBRARY libpthread.lib
+
+LIBRARY libglib.lib
+LIBRARY glibbackend.lib
+LIBRARY libgmodule.lib
+LIBRARY libgobject.lib
+LIBRARY libgthread.lib
+
+LIBRARY libssl.lib
+LIBRARY libcrypto.lib
+//LIBRARY libresolv.lib
+//LIBRARY libglib.lib
+#ifdef WINSCW
+//wsd solution
+LIBRARY ewsd.lib
+LIBRARY euser.lib
+#endif
+
+
+/*
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined(WINSCW)
+deffile ../bwinscw/
+#endif
+*/
+
+//VENDORID VID_DEFAULT
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/Makefile.in Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,645 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = loudmouth
+DIST_COMMON = $(libloudmouthinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" \
+ "$(DESTDIR)$(libloudmouthincludedir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libloudmouth_1_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am__libloudmouth_1_la_SOURCES_DIST = lm-connection.c lm-debug.c \
+ lm-debug.h lm-error.c lm-message.c lm-message-handler.c \
+ lm-message-node.c lm-message-queue.c lm-message-queue.h \
+ lm-misc.c lm-misc.h lm-parser.c lm-parser.h lm-internals.h \
+ lm-sha.c lm-sha.h lm-ssl-generic.c lm-ssl-base.c lm-ssl-base.h \
+ lm-ssl-internals.h lm-ssl-gnutls.c lm-ssl-openssl.c lm-utils.c \
+ lm-proxy.c lm-sock.h lm-sock.c lm-socket.c lm-socket.h \
+ asyncns.c asyncns.h lm-sasl.c lm-sasl.h md5.c md5.h base64.c \
+ base64.h
+@USE_GNUTLS_FALSE@@USE_OPENSSL_TRUE@am__objects_1 = lm-ssl-openssl.lo
+@USE_GNUTLS_TRUE@am__objects_1 = lm-ssl-gnutls.lo
+am__objects_2 =
+am_libloudmouth_1_la_OBJECTS = lm-connection.lo lm-debug.lo \
+ lm-error.lo lm-message.lo lm-message-handler.lo \
+ lm-message-node.lo lm-message-queue.lo lm-misc.lo lm-parser.lo \
+ lm-sha.lo lm-ssl-generic.lo lm-ssl-base.lo $(am__objects_1) \
+ lm-utils.lo lm-proxy.lo lm-sock.lo lm-socket.lo asyncns.lo \
+ lm-sasl.lo md5.lo base64.lo $(am__objects_2)
+libloudmouth_1_la_OBJECTS = $(am_libloudmouth_1_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libloudmouth_1_la_SOURCES)
+DIST_SOURCES = $(am__libloudmouth_1_la_SOURCES_DIST)
+libloudmouthincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(libloudmouthinclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHECK_CFLAGS = @CHECK_CFLAGS@
+CHECK_LIBS = @CHECK_LIBS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DOC_CFLAGS = @DOC_CFLAGS@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_GTK_DOC_FALSE = @ENABLE_GTK_DOC_FALSE@
+ENABLE_GTK_DOC_TRUE = @ENABLE_GTK_DOC_TRUE@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GLIB2_REQUIRED = @GLIB2_REQUIRED@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GNUTLS_REQUIRED = @GNUTLS_REQUIRED@
+GOBJECT_QUERY = @GOBJECT_QUERY@
+GREP = @GREP@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTK_DOC_USE_LIBTOOL_FALSE = @GTK_DOC_USE_LIBTOOL_FALSE@
+GTK_DOC_USE_LIBTOOL_TRUE = @GTK_DOC_USE_LIBTOOL_TRUE@
+HAVE_CHECK_FALSE = @HAVE_CHECK_FALSE@
+HAVE_CHECK_TRUE = @HAVE_CHECK_TRUE@
+HTML_DIR = @HTML_DIR@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
+LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
+LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
+LIBIDN_CFLAGS = @LIBIDN_CFLAGS@
+LIBIDN_LIBS = @LIBIDN_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTASN1_REQUIRED = @LIBTASN1_REQUIRED@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LOUDMOUTH_CFLAGS = @LOUDMOUTH_CFLAGS@
+LOUDMOUTH_LIBS = @LOUDMOUTH_LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+REBUILD = @REBUILD@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+USE_GNUTLS_FALSE = @USE_GNUTLS_FALSE@
+USE_GNUTLS_TRUE = @USE_GNUTLS_TRUE@
+USE_OPENSSL_FALSE = @USE_OPENSSL_FALSE@
+USE_OPENSSL_TRUE = @USE_OPENSSL_TRUE@
+VERSION = @VERSION@
+WARN_CFLAGS = @WARN_CFLAGS@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+NULL =
+TEST_DIR = $(top_srcdir)/
+AM_CPPFLAGS = \
+ -I. \
+ -I$(top_srcdir) \
+ $(LOUDMOUTH_CFLAGS) \
+ $(LIBIDN_CFLAGS) \
+ -DLM_COMPILATION \
+ -DRUNTIME_ENDIAN \
+ $(NULL)
+
+lib_LTLIBRARIES = libloudmouth-1.la
+@USE_GNUTLS_TRUE@ssl_sources = \
+@USE_GNUTLS_TRUE@ lm-ssl-gnutls.c
+
+@USE_OPENSSL_TRUE@ssl_sources = \
+@USE_OPENSSL_TRUE@ lm-ssl-openssl.c
+
+libloudmouth_1_la_SOURCES = \
+ lm-connection.c \
+ lm-debug.c \
+ lm-debug.h \
+ lm-error.c \
+ lm-message.c \
+ lm-message-handler.c \
+ lm-message-node.c \
+ lm-message-queue.c \
+ lm-message-queue.h \
+ lm-misc.c \
+ lm-misc.h \
+ lm-parser.c \
+ lm-parser.h \
+ lm-internals.h \
+ lm-sha.c \
+ lm-sha.h \
+ lm-ssl-generic.c \
+ lm-ssl-base.c \
+ lm-ssl-base.h \
+ lm-ssl-internals.h \
+ $(ssl_sources) \
+ lm-utils.c \
+ lm-proxy.c \
+ lm-sock.h \
+ lm-sock.c \
+ lm-socket.c \
+ lm-socket.h \
+ asyncns.c \
+ asyncns.h \
+ lm-sasl.c \
+ lm-sasl.h \
+ md5.c \
+ md5.h \
+ base64.c \
+ base64.h \
+ $(NULL)
+
+libloudmouthinclude_HEADERS = \
+ lm-connection.h \
+ lm-error.h \
+ lm-message.h \
+ lm-message-handler.h \
+ lm-message-node.h \
+ lm-utils.h \
+ lm-proxy.h \
+ lm-ssl.h \
+ loudmouth.h \
+ $(NULL)
+
+libloudmouth_1_la_LIBADD = \
+ $(LOUDMOUTH_LIBS) \
+ $(LIBIDN_LIBS) \
+ -lresolv
+
+libloudmouth_1_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -export-symbols $(srcdir)/loudmouth.sym
+
+libloudmouthincludedir = $(includedir)/loudmouth-1.0/loudmouth
+EXTRA_DIST = \
+ lm-ssl-gnutls.c \
+ lm-ssl-openssl.c \
+ loudmouth.sym
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu loudmouth/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu loudmouth/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libloudmouth-1.la: $(libloudmouth_1_la_OBJECTS) $(libloudmouth_1_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libloudmouth_1_la_LDFLAGS) $(libloudmouth_1_la_OBJECTS) $(libloudmouth_1_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asyncns.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-connection.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-debug.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-error.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-message-handler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-message-node.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-message-queue.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-message.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-misc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-parser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-proxy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-sasl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-sha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-sock.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-socket.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-ssl-base.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-ssl-generic.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-ssl-gnutls.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-ssl-openssl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm-utils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+install-libloudmouthincludeHEADERS: $(libloudmouthinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(libloudmouthincludedir)" || $(mkdir_p) "$(DESTDIR)$(libloudmouthincludedir)"
+ @list='$(libloudmouthinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(libloudmouthincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libloudmouthincludedir)/$$f'"; \
+ $(libloudmouthincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libloudmouthincludedir)/$$f"; \
+ done
+
+uninstall-libloudmouthincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(libloudmouthinclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(libloudmouthincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(libloudmouthincludedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libloudmouthincludedir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-libloudmouthincludeHEADERS
+
+install-exec-am: install-libLTLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-libloudmouthincludeHEADERS
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am \
+ install-libLTLIBRARIES install-libloudmouthincludeHEADERS \
+ install-man install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-libloudmouthincludeHEADERS
+
+
+# an explicit dependency here so alm generated files get built
+$(OBJECTS): $(built_sources)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/asyncns.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,162 @@
+
+
+/* $Id: asyncns.h 23 2007-02-16 12:49:17Z lennart $ */
+
+/***
+ This file is part of libasyncns.
+ Copyright (C) 2006 Collabora Ltd.
+ *
+ libasyncns is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ libasyncns is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with libasyncns; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+#ifndef fooasyncnshfoo
+#define fooasyncnshfoo
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+/** /mainpage
+ *
+ * /section moo Method of operation
+ *
+ * To use libasyncns allocate an asyncns_t object with
+ * asyncns_new(). This will spawn a number of worker threads (or processes, depending on what is available) which
+ * are subsequently used to process the queries the controlling
+ * program issues via asyncns_getaddrinfo() and
+ * asyncns_getnameinfo(). Use asyncns_free() to shut down the worker
+ * threads/processes.
+ *
+ * Since libasyncns may fork off new processes you have to make sure that
+ * your program is not irritated by spurious SIGCHLD signals.
+ */
+
+/** /example asyncns-test.c
+ * An example program */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** An opaque libasyncns session structure */
+typedef struct asyncns asyncns_t;
+
+/** An opaque libasyncns query structure */
+typedef struct asyncns_query asyncns_query_t;
+
+/** Allocate a new libasyncns session with n_proc worker processes */
+asyncns_t* asyncns_new(unsigned n_proc);
+
+/** Free a libasyncns session. This destroys all attached
+ * asyncns_query_t objects automatically */
+void asyncns_free(asyncns_t *asyncns);
+
+/** Return the UNIX file descriptor to select() for readability
+ * on. Use this function to integrate libasyncns with your custom main
+ * loop. */
+int asyncns_fd(asyncns_t *asyncns);
+
+/** Process pending responses. After this function is called you can
+ * get the next completed query object(s) using asyncns_getnext(). If
+ * block is non-zero wait until at least one response has been
+ * processed. If block is zero, process all pending responses and
+ * return. */
+int asyncns_wait(asyncns_t *asyncns, int block);
+
+/** Issue a name to address query on the specified session. The
+ * arguments are compatible with the ones of libc's
+ * getaddrinfo(3). The function returns a new query object. When the
+ * query is completed you may retrieve the results using
+ * asyncns_getaddrinfo_done().*/
+asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
+
+/** Retrieve the results of a preceding asyncns_getaddrinfo()
+ * call. Returns a addrinfo structure and a return value compatible
+ * with libc's getaddrinfo(3). The query object q is destroyed by this
+ * call and may not be used any further. Make sure to free the
+ * returned addrinfo structure with asyncns_freeaddrinfo() and not
+ * libc's freeaddrinfo(3)! If the query is not completed yet EAI_AGAIN
+ * is returned.*/
+int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
+
+/** Issue an address to name query on the specified session. The
+arguments are compatible with the ones of libc's getnameinfo(3). The
+function returns a new query object. When the query is completed you
+may retrieve the results using asyncns_getnameinfo_done(). Set gethost
+(resp. getserv) to non-zero if you want to query the hostname
+(resp. the service name). */
+asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
+
+/** Retrieve the results of a preceding asyncns_getnameinfo)(
+ * call. Returns the hostname and the service name in ret_host and
+ * ret_serv. The query object q is destroyed by this call and may not
+ * be used any further. If the query is not completed yet EAI_AGAIN is
+ * returned. */
+int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
+
+/** Issue an resolver query on the specified session. The arguments are
+ * compatible with the ones of libc's res_query(3). The function returns a new
+ * query object. When the query is completed you may retrieve the results using
+ * asyncns_res_done(). */
+asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
+
+/** Issue an resolver query on the specified session. The arguments are
+ * compatible with the ones of libc's res_search(3). The function returns a new
+ * query object. When the query is completed you may retrieve the results using
+ * asyncns_res_done(). */
+asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
+
+/** Retrieve the results of a preceding asyncns_res_query)( or
+ * asyncns_res_search call. The query object q is destroyed by this call and
+ * may not be used any further. Returns a pointer to the answer of the
+ * res_query call. If the query is not completed yet -EAGAIN is returned, on
+ * failure -errno is returned otherwise the length of answer is returned. */
+int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char
+**answer);
+
+/** Return the next completed query object. If no query has been
+ * completed yet, return NULL. Please note that you need to run
+ * asyncns_wait() before this function will return sensible data. */
+asyncns_query_t* asyncns_getnext(asyncns_t *asyncns);
+
+/** Return the number of query objects (completed or not) attached to
+ * this session */
+int asyncns_getnqueries(asyncns_t *asyncns);
+
+/** Cancel a currently running query. q is is destroyed by this call
+ * and may not be used any futher. */
+void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q);
+
+/** Free the addrinfo structure as returned by
+asyncns_getaddrinfo_done(). Make sure to use this functions instead of
+the libc's freeaddrinfo()! */
+void asyncns_freeaddrinfo(struct addrinfo *ai);
+
+/** Returns non-zero when the query operation specified by q has been completed */
+int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q);
+
+/** Assign some opaque userdata with a query object */
+void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
+
+/** Return userdata assigned to a query object. Use
+ * asyncns_setuserdata() to set this data. If no data has been set
+ * prior to this call it returns NULL. */
+void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/base64.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,31 @@
+/*
+ * base64.h - Base 64 encoding/decoding implementation
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __BASE64_H__
+#define __BASE64_H__
+
+#include <glib.h>
+
+gchar *_lm_base64_encode (const gchar *str, gsize n);
+gchar *_lm_base64_decode (const gchar *str, gsize *len);
+
+#define base64_encode _lm_base64_encode
+#define base64_decode _lm_base64_decode
+
+#endif /* __BASE64_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/config.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,120 @@
+/*
+ * © . All rights reserved.
+ */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* whether to use GnuTSL support. */
+/* #undef HAVE_GNUTLS */
+
+/* Define if IDN support is included */
+/* #define HAVE_IDN 1 */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `nsl' library (-lnsl). */
+#define HAVE_LIBNSL 1
+
+/* Define to 1 if you have the `socket' library (-lsocket). */
+/* #undef HAVE_LIBSOCKET */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Have OpenSSL */
+#define HAVE_OPENSSL
+
+/* Define to 1 if you have the <openssl/ssl.h> header file. */
+#define HAVE_OPENSSL_SSL_H 1
+
+/* whether to use SSL support. */
+#define HAVE_SSL 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if libc defines a timezone variable */
+/* #undef HAVE_TIMEZONE */
+
+/* Define if struct tm has a tm_gmtoff member */
+#define HAVE_TM_GMTOFF 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <winsock2.h> header file. */
+/* #undef HAVE_WINSOCK2_H */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "loudmouth"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "Loudmouth"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "Loudmouth 1.2.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "loudmouth"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.2.0"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/gdebug.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,69 @@
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * . All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GLib Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_DEBUG_H__
+#define __G_DEBUG_H__
+
+#include <_ansi.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ G_DEBUG_FATAL_WARNINGS = 1 << 0,
+ G_DEBUG_FATAL_CRITICALS = 1 << 1
+} GDebugFlag;
+
+
+#ifdef G_ENABLE_DEBUG
+
+#define G_NOTE(type, action) G_STMT_START { \
+ if (!_g_debug_initialized) \
+ { _g_debug_init (); } \
+ if (_g_debug_flags & G_DEBUG_##type) \
+ { action; }; } G_STMT_END
+
+#else /* !G_ENABLE_DEBUG */
+
+#define G_NOTE(type, action)
+
+#endif /* G_ENABLE_DEBUG */
+
+#ifdef SYMBIAN
+IMPORT_C gboolean * __g_debug_initialized();
+#endif /* SYMBIAN */
+GLIB_VAR gboolean _g_debug_initialized;
+
+#ifdef SYMBIAN
+IMPORT_C guint * __g_debug_flags();
+#endif /* SYMBIAN */
+GLIB_VAR guint _g_debug_flags;
+
+void _g_debug_init (void) G_GNUC_INTERNAL;
+
+G_END_DECLS
+
+#endif /* __G_DEBUG_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/libloudmouth_wsd_macros.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _LIBLOUDMOUTHMACROS_WSD_DEFS_H_
+#define _LIBLOUDMOUTHMACROS_WSD_DEFS_H_
+
+#if (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
+#if EMULATOR
+#undef EMULATOR
+#endif
+#ifdef GET_WSD_VAR_NAME
+#undef GET_WSD_VAR_NAME
+#endif
+
+#define EMULATOR (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
+#define GET_WSD_VAR_NAME(var,filename,prefix) _##prefix##_##filename##_##var
+
+#define RETURN_WSD_VAR(var,filename,prefix) (libloudmouth_ImpurePtr()->GET_WSD_VAR_NAME(var,filename,prefix))
+
+#define GET_WSD_VAR_FROM_TLS(var,filename,type,prefix)\
+type *_##prefix##_##filename##_##var()\
+{\
+ return (&RETURN_WSD_VAR(var,filename,prefix));\
+}
+
+#define GET_WSD_ARRAY_FROM_TLS(var,filename,type,prefix)\
+type *_##prefix##_##filename##_##var()\
+{\
+ return (RETURN_WSD_VAR(var,filename,prefix));\
+}
+
+#define VARIABLE_DECL(var,varprefix,filename,datatype)\
+datatype GET_WSD_VAR_NAME(var,filename,varprefix);
+
+#define VARIABLE_DECL_ARRAY(var,prefix,filename,datatype,size) \
+datatype GET_WSD_VAR_NAME(var,filename,prefix)[size];
+
+#define VARIABLE_DECL_2DARRAY(var,prefix,filename,datatype,size,size1) \
+datatype GET_WSD_VAR_NAME(var,filename,prefix)[size][size1];
+
+
+#define GET_STATIC_VAR_FROM_TLS(var,filename,type) GET_WSD_VAR_FROM_TLS(var,filename,type,s)
+
+#define GET_GLOBAL_VAR_FROM_TLS(var,filename,type) GET_WSD_VAR_FROM_TLS(var,filename,type,g)
+
+#define GET_STATIC_ARRAY_FROM_TLS(var,filename,type) GET_WSD_ARRAY_FROM_TLS(var,filename,type,s)
+
+#define GET_GLOBAL_ARRAY_FROM_TLS(var,filename,type) GET_WSD_ARRAY_FROM_TLS(var,filename,type,g)
+
+#endif
+#endif //_LIBLOUDMOUTHMACROS_WSD_DEFS_H_
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/libloudmouth_wsd_solution.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _LIBLOUDMOUTH_WSD_H
+#define _LIBLOUDMOUTH_WSD_H
+#include "libloudmouth_wsd_macros.h"
+#include "lm_enums.h"
+#include "ghash.h"
+#include <gutils.h>
+#include "lm-internals.h"
+#include <glib/gtypes.h>
+/*#include "lm-debug.h"
+#include "lm-message.h"
+#include "lm-utils.h"
+#include "base64.h"
+#include "lm-misc.h"
+#include "lm-sha.h"*/
+
+#if EMULATOR
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+typedef struct _TypeNames TypeNames;
+
+struct _TypeNames
+ {
+ LmMessageType type;
+ const gchar name[20];
+
+ };
+
+
+typedef struct _SubTypeNames SubTypeNames;
+
+struct _SubTypeNames
+ {
+ LmMessageSubType type;
+ const gchar name[20];
+
+ };
+
+
+struct libloudmouth_global_struct
+ {
+ VARIABLE_DECL(debug_flags, g, lm_debug,LmLogLevelFlags)
+ VARIABLE_DECL(initialized, g, lm_debug,gboolean)
+ VARIABLE_DECL(log_handler_id, g, lm_debug,guint)
+ VARIABLE_DECL_ARRAY(type_names, s, lm_message,TypeNames,13)
+ VARIABLE_DECL_ARRAY(sub_type_names, s, lm_message,SubTypeNames,14)
+ VARIABLE_DECL(initialized, s, lm_ssl_openssl,gboolean)
+ VARIABLE_DECL(last_id, s, lm_utils,guint)
+ VARIABLE_DECL_ARRAY(base64chars, s, lm_utils, gchar, 256)
+ VARIABLE_DECL_ARRAY(ret_val, s, lm_sha, gchar, 256)
+ VARIABLE_DECL_ARRAY(encoding, s, lm_base64, gchar, 256)
+ VARIABLE_DECL_ARRAY(buf, s, lm_misc, char, 256)
+ VARIABLE_DECL(initialised, g, lm_sock,gboolean)
+
+
+ /*END-global vars*/
+
+ };
+
+struct libloudmouth_global_struct * libloudmouth_ImpurePtr();
+int libloudmouth_Init(struct libloudmouth_global_struct *);
+#ifdef __cplusplus
+}
+#endif
+#endif //EMULATOR
+#endif //header guard ifdef _LIBGABBLE_WSD_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-debug.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,98 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_DEBUG_H__
+#define __LM_DEBUG_H__
+#include <stdio.h>
+#include <glib.h>
+#include "lm_enums.h"
+
+//Wsd changes
+
+/*typedef enum {
+
+ LM_LOG_LEVEL_VERBOSE = 1 << (G_LOG_LEVEL_USER_SHIFT),
+ LM_LOG_LEVEL_NET = 1 << (G_LOG_LEVEL_USER_SHIFT + 1),
+ LM_LOG_LEVEL_PARSER = 1 << (G_LOG_LEVEL_USER_SHIFT + 2),
+ LM_LOG_LEVEL_SSL = 1 << (G_LOG_LEVEL_USER_SHIFT + 3),
+ LM_LOG_LEVEL_SASL = 1 << (G_LOG_LEVEL_USER_SHIFT + 4),
+ LM_LOG_LEVEL_ALL = (LM_LOG_LEVEL_NET |
+ LM_LOG_LEVEL_VERBOSE |
+ LM_LOG_LEVEL_PARSER |
+ LM_LOG_LEVEL_SSL |
+ LM_LOG_LEVEL_SASL)
+} LmLogLevelFlags;
+*/
+#ifndef LM_LOG_DOMAIN
+# define LM_LOG_DOMAIN "LM"
+#endif
+
+#ifndef _DEBUG
+#define LM_NO_DEBUG
+#endif
+#ifdef G_HAVE_ISO_VARARGS
+# ifdef LM_NO_DEBUG
+# define lm_verbose(...)
+# else
+# define lm_verbose(...) \
+ g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_VERBOSE, __VA_ARGS__)
+# endif
+#elif defined(G_HAVE_GNUC_VARARGS)
+# if LM_NO_DEBUG
+# define lm_verbose(fmt...)
+# else
+# define lm_verbose(fmt...) \
+ g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_VERBOSE, fmt)
+# endif
+#else
+# ifdef LM_NO_DEBUG
+ static void
+ lm_verbose(const gchar *format, ...) {};
+# else
+static void
+lm_verbose (const gchar *format, ...)
+{
+//#ifdef HAVELMLOGS
+ FILE *fp;
+ va_list args;
+ va_start (args, format);
+ // g_logv (LM_LOG_DOMAIN, LM_LOG_LEVEL_VERBOSE, format, args);
+ fp = fopen("c:\\lmlogs.txt","a");
+
+ if(fp)
+ {
+ /* fprintf(fp,arg);
+ fprintf(fp,"\n");*/
+ // fprintf (fp, "%lu: 0x%lx: ", _dbus_getpid (), pthread_self ());
+ vfprintf (fp, format, args);
+ fflush(fp);
+ fclose(fp);
+ }
+ va_end (args);
+ //#endif
+}
+# endif
+#endif
+
+void lm_debug_init (void);
+
+#endif /* __LM_DEBUG_H__ */
+#define UNUSED_FORMAL_PARAM(p) (void) p
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-internals.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,117 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* Private functions that are internal to the library */
+
+#ifndef __LM_INTERNALS_H__
+#define __LM_INTERNALS_H__
+
+#include <glib.h>
+
+#include <sys/types.h>
+
+#include "lm-message.h"
+#include "lm-message-handler.h"
+#include "lm-message-node.h"
+#include "lm-sock.h"
+#include "lm-socket.h"
+
+#ifndef G_OS_WIN32
+typedef int LmSocketT;
+#else /* G_OS_WIN32 */
+typedef SOCKET LmSocketT;
+#endif /* G_OS_WIN32 */
+
+typedef struct {
+ gpointer func;
+ gpointer user_data;
+ GDestroyNotify notify;
+} LmCallback;
+
+typedef struct {
+ LmConnection *connection;
+ LmSocket *socket;
+
+ /* struct to save resolved address */
+ struct addrinfo *resolved_addrs;
+ struct addrinfo *current_addr;
+ LmSocketT fd;
+ GIOChannel *io_channel;
+} LmConnectData;
+
+gboolean _lm_socket_failed_with_error (LmConnectData *connect_data,
+ int error);
+gboolean _lm_socket_failed (LmConnectData *connect_data);
+void _lm_socket_succeeded (LmConnectData *connect_data);
+gboolean _lm_connection_async_connect_waiting (LmConnection *connection);
+void _lm_connection_set_async_connect_waiting (LmConnection *connection,
+ gboolean waiting);
+
+LmCallback * _lm_utils_new_callback (gpointer func,
+ gpointer data,
+ GDestroyNotify notify);
+void _lm_utils_free_callback (LmCallback *cb);
+
+gchar * _lm_utils_generate_id (void);
+gchar * _lm_utils_base64_encode (const gchar *str);
+gchar * _lm_utils_hostname_to_punycode (const gchar *hostname);
+const gchar * _lm_message_type_to_string (LmMessageType type);
+const gchar * _lm_message_sub_type_to_string (LmMessageSubType type);
+LmMessage * _lm_message_new_from_node (LmMessageNode *node);
+void _lm_message_node_add_child_node (LmMessageNode *node,
+ LmMessageNode *child);
+LmMessageNode * _lm_message_node_new (const gchar *name);
+void _lm_debug_init (void);
+
+
+gboolean _lm_proxy_connect_cb (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data);
+LmHandlerResult
+_lm_message_handler_handle_message (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *messag);
+gboolean _lm_sock_library_init (void);
+void _lm_sock_library_shutdown (void);
+void _lm_sock_set_blocking (LmSocketT sock,
+ gboolean block);
+void _lm_sock_shutdown (LmSocketT sock);
+void _lm_sock_close (LmSocketT sock);
+LmSocketT _lm_sock_makesocket (int af,
+ int type,
+ int protocol);
+int _lm_sock_connect (LmSocketT sock,
+ const struct sockaddr *name,
+ int namelen);
+gboolean _lm_sock_is_blocking_error (int err);
+gboolean _lm_sock_is_blocking_success (int err);
+int _lm_sock_get_last_error (void);
+void _lm_sock_get_error (LmSocketT sock,
+ void *error,
+ socklen_t *len);
+const gchar * _lm_sock_get_error_str (int err);
+const gchar * _lm_sock_addrinfo_get_error_str (int err);
+gchar * _lm_sock_get_local_host (LmSocketT sock);
+
+#ifdef USE_TCP_KEEPALIVES
+gboolean _lm_sock_set_keepalive (LmSocketT sock, int delay);
+#endif /* USE_TCP_KEEPALIVES */
+
+#endif /* __LM_INTERNALS_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-message-queue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_MESSAGE_QUEUE_H__
+#define __LM_MESSAGE_QUEUE_H__
+
+#include <glib.h>
+#include "loudmouth/lm-message.h"
+
+typedef struct _LmMessageQueue LmMessageQueue;
+
+typedef void (* LmMessageQueueCallback) (LmMessageQueue *queue,
+ gpointer user_data);
+
+LmMessageQueue * lm_message_queue_new (LmMessageQueueCallback func,
+ gpointer data);
+void lm_message_queue_attach (LmMessageQueue *queue,
+ GMainContext *context);
+
+void lm_message_queue_detach (LmMessageQueue *queue);
+void lm_message_queue_push_tail (LmMessageQueue *queue,
+ LmMessage *m);
+LmMessage * lm_message_queue_peek_nth (LmMessageQueue *queue,
+ guint n);
+LmMessage * lm_message_queue_pop_nth (LmMessageQueue *queue,
+ guint n);
+guint lm_message_queue_get_length (LmMessageQueue *queue);
+gboolean lm_message_queue_is_empty (LmMessageQueue *queue);
+
+LmMessageQueue * lm_message_queue_ref (LmMessageQueue *queue);
+void lm_message_queue_unref (LmMessageQueue *queue);
+
+#endif /* __LM_MESSAGE_QUEUE_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-misc.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_MISC_H__
+#define __LM_MISC_H__
+
+#include <glib.h>
+
+GSource * lm_misc_add_io_watch (GMainContext *context,
+ GIOChannel *chan,
+ GIOCondition condition,
+ GIOFunc function,
+ gpointer data);
+GSource * lm_misc_add_idle (GMainContext *context,
+ GSourceFunc function,
+ gpointer data);
+GSource * lm_misc_add_timeout (GMainContext *context,
+ guint interval,
+ GSourceFunc function,
+ gpointer data);
+
+const char * lm_misc_io_condition_to_str (GIOCondition condition);
+
+
+#endif /* __LM_MISC_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-parser.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,40 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_PARSER_H__
+#define __LM_PARSER_H__
+
+#include <glib.h>
+#include "lm-message.h"
+
+typedef struct LmParser LmParser;
+
+typedef void (* LmParserMessageFunction) (LmParser *parser,
+ LmMessage *message,
+ gpointer user_data);
+
+IMPORT_C LmParser * lm_parser_new (LmParserMessageFunction function,
+ gpointer user_data,
+ GDestroyNotify notify);
+IMPORT_C void lm_parser_parse (LmParser *parser,
+ const gchar *string);
+IMPORT_C void lm_parser_free (LmParser *parser);
+
+#endif /* __LM_PARSER_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-sasl.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SASL_H__
+#define __LM_SASL_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _LmSASL LmSASL;
+
+typedef void (*LmSASLResultHandler) (LmSASL *sasl,
+ LmConnection *connection,
+ gboolean success,
+ const gchar *reason);
+
+LmSASL *lm_sasl_new (LmConnection *connection);
+
+void lm_sasl_authenticate (LmSASL *sasl,
+ const gchar *username,
+ const gchar *password,
+ const gchar *server,
+ LmSASLResultHandler handler);
+
+void lm_sasl_free (LmSASL *sasl);
+
+void
+lm_sasl_get_auth_params (LmSASL *sasl, const gchar **username,
+ const gchar **password);
+G_END_DECLS
+
+#endif /* __LM_SASL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-sha.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,28 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SHA_H__
+#define __LM_SHA_H__
+
+#include <glib.h>
+
+IMPORT_C const gchar * lm_sha_hash (const gchar *str);
+
+#endif /* __LM_SHA_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-sock.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SOCK_H__
+#define __LM_SOCK_H__
+
+G_BEGIN_DECLS
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may di/sappear or change contents."
+#endif
+
+#include <glib.h>
+
+#ifndef G_OS_WIN32
+
+#include <unistd.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#define _LM_SOCK_EINPROGRESS EINPROGRESS
+#define _LM_SOCK_EWOULDBLOCK EWOULDBLOOK
+#define _LM_SOCK_EALREADY EALREADY
+#define _LM_SOCK_EISCONN EISCONN
+#define _LM_SOCK_EINVAL EINVAL
+
+//added by prima
+//to be removed later when MRT fixes the bug on return of socket connect
+#define _LM_SOCK_EEXISTS EEXIST
+//end added by prima
+
+#define _LM_SOCK_VALID(S) ((S) >= 0)
+
+#else /* G_OS_WIN32 */
+
+/* This means that we require Windows XP or above to build on
+ * Windows, the reason for this, is that getaddrinfo() and
+ * freeaddrinfo() require ws2tcpip.h functions that are only available
+ * on these platforms.
+ *
+ * This MUST be defined before windows.h is included.
+ */
+
+
+#if (_WIN32_WINNT < 0x0501)
+#undef WINVER
+#define WINVER 0x0501
+#undef _WIN32_WINNT
+#define _WIN32_WINNT WINVER
+#endif
+
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+#define _LM_SOCK_EINPROGRESS WSAEINPROGRESS
+#define _LM_SOCK_EWOULDBLOCK WSAEWOULDBLOCK
+#define _LM_SOCK_EALREADY WSAEALREADY
+#define _LM_SOCK_EISCONN WSAEISCONN
+#define _LM_SOCK_EINVAL WSAEINVAL
+#define _LM_SOCK_VALID(S) ((S) != INVALID_SOCKET)
+
+#endif /* G_OS_WIN32 */
+
+G_END_DECLS
+
+#endif /* __LM_SOCK__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-socket.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SOCKET_H__
+#define __LM_SOCKET_H__
+
+#include <glib.h>
+
+#include "lm-internals.h"
+
+typedef struct _LmSocket LmSocket;
+
+typedef void (* IncomingDataFunc) (LmSocket *socket,
+ const gchar *buf,
+ gpointer user_data);
+
+typedef void (* SocketClosedFunc) (LmSocket *socket,
+ LmDisconnectReason reason,
+ gpointer user_data);
+
+typedef void (* ConnectResultFunc) (LmSocket *socket,
+ gboolean result,
+ gpointer user_data);
+
+gboolean lm_socket_output_is_buffered (LmSocket *socket,
+ const gchar *buffer,
+ gint len);
+void lm_socket_setup_output_buffer (LmSocket *socket,
+ const gchar *buffer,
+ gint len);
+gint lm_socket_do_write (LmSocket *socket,
+ const gchar *buf,
+ gint len);
+
+LmSocket * lm_socket_create (GMainContext *context,
+ IncomingDataFunc data_func,
+ SocketClosedFunc closed_func,
+ ConnectResultFunc connect_func,
+ gpointer user_data,
+ LmConnection *connection,
+ gboolean blocking,
+ const gchar *server,
+ const gchar *domain,
+ guint port,
+ LmSSL *ssl,
+ LmProxy *proxy,
+ GError **error);
+void lm_socket_flush (LmSocket *socket);
+void lm_socket_close (LmSocket *socket);
+LmSocket * lm_socket_ref (LmSocket *socket);
+void lm_socket_unref (LmSocket *socket);
+#ifdef HAVE_ASYNCNS
+void _asyncns_cancel (LmSocket *socket);
+#endif
+gboolean lm_socket_starttls (LmSocket *socket);
+gboolean lm_socket_set_keepalive (LmSocket *socket, int delay);
+gchar * lm_socket_get_local_host (LmSocket *socket);
+
+#endif /* __LM_SOCKET_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-ssl-base.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,49 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SSL_BASE_H__
+#define __LM_SSL_BASE_H__
+
+#include "lm-ssl.h"
+
+#define LM_SSL_BASE(x) ((LmSSLBase *) x)
+
+typedef struct _LmSSLBase LmSSLBase;
+struct _LmSSLBase {
+ LmSSLFunction func;
+ gpointer func_data;
+ GDestroyNotify data_notify;
+ gchar *expected_fingerprint;
+ char fingerprint[20];
+ gboolean use_starttls;
+ gboolean require_starttls;
+
+ gint ref_count;
+};
+
+void _lm_ssl_base_init (LmSSLBase *base,
+ const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+void _lm_ssl_base_free_fields (LmSSLBase *base);
+
+#endif /* __LM_SSL_BASE_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm-ssl-internals.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,69 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SSL_INTERNALS_H__
+#define __LM_SSL_INTERNALS_H__
+
+#include <glib.h>
+
+LmSSLResponse _lm_ssl_func_always_continue (LmSSL *ssl,
+ LmSSLStatus status,
+ gpointer user_data);
+LmSSL * _lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+void _lm_ssl_initialize (LmSSL *ssl);
+gboolean _lm_ssl_begin (LmSSL *ssl,
+ gint fd,
+ const gchar *server,
+ GError **error);
+GIOStatus _lm_ssl_read (LmSSL *ssl,
+ gchar *buf,
+ gint len,
+ gsize *bytes_read);
+gint _lm_ssl_send (LmSSL *ssl,
+ const gchar *str,
+ gint len);
+void _lm_ssl_close (LmSSL *ssl);
+void _lm_ssl_free (LmSSL *ssl);
+
+LmSSL * _lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+void _lm_ssl_initialize (LmSSL *ssl);
+gboolean _lm_ssl_begin (LmSSL *ssl,
+ gint fd,
+ const gchar *server,
+ GError **error);
+GIOStatus _lm_ssl_read (LmSSL *ssl,
+ gchar *buf,
+ gint len,
+ gsize *bytes_read);
+gint _lm_ssl_send (LmSSL *ssl,
+ const gchar *str,
+ gint len);
+void _lm_ssl_close (LmSSL *ssl);
+void _lm_ssl_free (LmSSL *ssl);
+
+#endif /* __LM_SSL_INTERNALS_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/lm_enums.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef enum_lm
+#define enum_lm
+#include <glib/gmessages.h>
+typedef enum
+{
+ LM_LOG_LEVEL_VERBOSE = 1 << (G_LOG_LEVEL_USER_SHIFT),
+ LM_LOG_LEVEL_NET = 1 << (G_LOG_LEVEL_USER_SHIFT+1),
+ LM_LOG_LEVEL_PARSER = 1 << (G_LOG_LEVEL_USER_SHIFT+2),
+ LM_LOG_LEVEL_SSL = 1 << (G_LOG_LEVEL_USER_SHIFT+3),
+ LM_LOG_LEVEL_SASL = 1 << (G_LOG_LEVEL_USER_SHIFT+4),
+ LM_LOG_LEVEL_ALL = ((1 << ((8) +1)) |
+ (1 << ((8))) |
+ (1 << ((8) +2)) |
+ (1 << ((8) +3)) |
+ (1 << ((8) +4)))
+} LmLogLevelFlags;
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-connection.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,175 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_CONNECTION_H__
+#define __LM_CONNECTION_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include "loudmouth/lm-message.h"
+#include "loudmouth/lm-proxy.h"
+#include "loudmouth/lm-ssl.h"
+
+G_BEGIN_DECLS
+
+#define LM_CONNECTION(o) (LmConnection *) o;
+
+#define LM_CONNECTION_DEFAULT_PORT 5222
+#define LM_CONNECTION_DEFAULT_PORT_SSL 5223
+
+typedef struct _LmConnection LmConnection;
+
+typedef struct LmMessageHandler LmMessageHandler;
+
+typedef enum {
+ LM_HANDLER_RESULT_REMOVE_MESSAGE,
+ LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS
+} LmHandlerResult;
+
+typedef enum {
+ LM_HANDLER_PRIORITY_LAST = 1,
+ LM_HANDLER_PRIORITY_NORMAL = 2,
+ LM_HANDLER_PRIORITY_FIRST = 3
+} LmHandlerPriority;
+
+typedef enum {
+ LM_DISCONNECT_REASON_OK,
+ LM_DISCONNECT_REASON_PING_TIME_OUT,
+ LM_DISCONNECT_REASON_HUP,
+ LM_DISCONNECT_REASON_ERROR,
+ LM_DISCONNECT_REASON_RESOURCE_CONFLICT,
+ LM_DISCONNECT_REASON_INVALID_XML,
+ LM_DISCONNECT_REASON_UNKNOWN
+} LmDisconnectReason;
+
+typedef enum {
+ LM_CONNECTION_STATE_CLOSED,
+ LM_CONNECTION_STATE_OPENING,
+ LM_CONNECTION_STATE_OPEN,
+ LM_CONNECTION_STATE_AUTHENTICATING,
+ LM_CONNECTION_STATE_AUTHENTICATED
+} LmConnectionState;
+
+typedef void (* LmResultFunction) (LmConnection *connection,
+ gboolean success,
+ gpointer user_data);
+
+typedef void (* LmDisconnectFunction) (LmConnection *connection,
+ LmDisconnectReason reason,
+ gpointer user_data);
+
+IMPORT_C LmConnection *lm_connection_new (const gchar *server);
+IMPORT_C LmConnection *lm_connection_new_with_context (const gchar *server,
+ GMainContext *context);
+IMPORT_C gboolean lm_connection_open (LmConnection *connection,
+ LmResultFunction function,
+ gpointer user_data,
+ GDestroyNotify notify,
+ GError **error);
+
+IMPORT_C gboolean lm_connection_open_and_block (LmConnection *connection,
+ GError **error);
+
+IMPORT_C void lm_connection_cancel_open (LmConnection *connection);
+IMPORT_C gboolean lm_connection_close (LmConnection *connection,
+ GError **error);
+IMPORT_C gboolean lm_connection_authenticate (LmConnection *connection,
+ const gchar *username,
+ const gchar *password,
+ const gchar *resource,
+ LmResultFunction function,
+ gpointer user_data,
+ GDestroyNotify notify,
+ GError **error);
+IMPORT_C gboolean
+lm_connection_authenticate_and_block (LmConnection *connection,
+ const gchar *username,
+ const gchar *password,
+ const gchar *resource,
+ GError **error);
+IMPORT_C guint lm_connection_get_keep_alive_rate (LmConnection *connection);
+IMPORT_C void lm_connection_set_keep_alive_rate (LmConnection *connection,
+ guint rate);
+
+IMPORT_C gboolean lm_connection_is_open (LmConnection *connection);
+IMPORT_C gboolean lm_connection_is_authenticated (LmConnection *connection);
+
+IMPORT_C const gchar * lm_connection_get_server (LmConnection *connection);
+IMPORT_C void lm_connection_set_server (LmConnection *connection,
+ const gchar *server);
+IMPORT_C void lm_connection_set_jid (LmConnection *connection,
+ const gchar *jid);
+IMPORT_C const gchar * lm_connection_get_jid (LmConnection *connection);
+IMPORT_C gchar * lm_connection_get_full_jid (LmConnection *connection);
+
+IMPORT_C guint lm_connection_get_port (LmConnection *connection);
+IMPORT_C void lm_connection_set_port (LmConnection *connection,
+ guint port);
+
+IMPORT_C LmSSL * lm_connection_get_ssl (LmConnection *connection);
+IMPORT_C void lm_connection_set_ssl (LmConnection *connection,
+ LmSSL *ssl);
+IMPORT_C LmProxy * lm_connection_get_proxy (LmConnection *connection);
+IMPORT_C void lm_connection_set_proxy (LmConnection *connection,
+ LmProxy *proxy);
+IMPORT_C gboolean lm_connection_send (LmConnection *connection,
+ LmMessage *message,
+ GError **error);
+IMPORT_C gboolean lm_connection_send_with_reply (LmConnection *connection,
+ LmMessage *message,
+ LmMessageHandler *handler,
+ GError **error);
+IMPORT_C LmMessage *
+lm_connection_send_with_reply_and_block (LmConnection *connection,
+ LmMessage *message,
+ GError **error);
+IMPORT_C void
+lm_connection_register_message_handler (LmConnection *connection,
+ LmMessageHandler *handler,
+ LmMessageType type,
+ LmHandlerPriority priority);
+IMPORT_C void
+lm_connection_unregister_message_handler (LmConnection *connection,
+ LmMessageHandler *handler,
+ LmMessageType type);
+IMPORT_C void
+lm_connection_set_disconnect_function (LmConnection *connection,
+ LmDisconnectFunction function,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+IMPORT_C gboolean lm_connection_send_raw (LmConnection *connection,
+ const gchar *str,
+ GError **error);
+IMPORT_C LmConnectionState lm_connection_get_state (LmConnection *connection);
+IMPORT_C gchar * lm_connection_get_local_host (LmConnection *connection);
+IMPORT_C LmConnection* lm_connection_ref (LmConnection *connection);
+IMPORT_C void lm_connection_unref (LmConnection *connection);
+
+gboolean
+_lm_connection_old_auth (LmConnection *connection, const gchar *username,
+ const gchar *password, const gchar *resource,
+ GError **errror);
+
+G_END_DECLS
+
+#endif /* __LM_CONNECTION_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-error.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_ERROR_H__
+#define __LM_ERROR_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define LM_ERROR lm_error_quark ()
+
+typedef enum {
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ LM_ERROR_CONNECTION_OPEN,
+ LM_ERROR_AUTH_FAILED,
+ LM_ERROR_CONNECTION_FAILED
+} LmError;
+
+IMPORT_C GQuark lm_error_quark (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __LM_ERROR_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-message-handler.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_MESSAGE_HANDLER_H__
+#define __LM_MESSAGE_HANDLER_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include "loudmouth/lm-connection.h"
+
+G_BEGIN_DECLS
+
+typedef LmHandlerResult (* LmHandleMessageFunction) (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data);
+
+IMPORT_C LmMessageHandler *lm_message_handler_new (LmHandleMessageFunction function,
+ gpointer user_data,
+ GDestroyNotify notify);
+IMPORT_C void lm_message_handler_invalidate (LmMessageHandler *handler);
+IMPORT_C gboolean lm_message_handler_is_valid (LmMessageHandler *handler);
+IMPORT_C LmMessageHandler *lm_message_handler_ref (LmMessageHandler *handler);
+IMPORT_C void lm_message_handler_unref (LmMessageHandler *handler);
+
+G_END_DECLS
+
+#endif /* __LM_MESSAGE_HANDLER_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-message-node.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_MESSAGE_NODE_H__
+#define __LM_MESSAGE_NODE_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _LmMessageNode LmMessageNode;
+
+struct _LmMessageNode {
+ gchar *name;
+ gchar *value;
+ gboolean raw_mode;
+
+ LmMessageNode *next;
+ LmMessageNode *prev;
+ LmMessageNode *parent;
+ LmMessageNode *children;
+
+ /* < private > */
+ GSList *attributes;
+ gint ref_count;
+};
+
+IMPORT_C const gchar * lm_message_node_get_value (LmMessageNode *node);
+IMPORT_C void lm_message_node_set_value (LmMessageNode *node,
+ const gchar *value);
+IMPORT_C LmMessageNode *lm_message_node_add_child (LmMessageNode *node,
+ const gchar *name,
+ const gchar *value);
+IMPORT_C void lm_message_node_set_attributes (LmMessageNode *node,
+ const gchar *name,
+ ...);
+IMPORT_C void lm_message_node_set_attribute (LmMessageNode *node,
+ const gchar *name,
+ const gchar *value);
+IMPORT_C const gchar * lm_message_node_get_attribute (LmMessageNode *node,
+ const gchar *name);
+IMPORT_C LmMessageNode *lm_message_node_get_child (LmMessageNode *node,
+ const gchar *child_name);
+IMPORT_C LmMessageNode *lm_message_node_find_child (LmMessageNode *node,
+ const gchar *child_name);
+IMPORT_C gboolean lm_message_node_get_raw_mode (LmMessageNode *node);
+IMPORT_C void lm_message_node_set_raw_mode (LmMessageNode *node,
+ gboolean raw_mode);
+IMPORT_C LmMessageNode *lm_message_node_ref (LmMessageNode *node);
+IMPORT_C void lm_message_node_unref (LmMessageNode *node);
+IMPORT_C gchar * lm_message_node_to_string (LmMessageNode *node);
+
+G_END_DECLS
+
+#endif /* __LM_MESSAGE_NODE_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-message.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,89 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_MESSAGE_H__
+#define __LM_MESSAGE_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#include "loudmouth/lm-message-node.h"
+
+G_BEGIN_DECLS
+
+typedef struct LmMessagePriv LmMessagePriv;
+
+typedef struct {
+ LmMessageNode *node;
+
+ LmMessagePriv *priv;
+} LmMessage;
+
+typedef enum {
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_TYPE_STREAM,
+ LM_MESSAGE_TYPE_STREAM_ERROR,
+ LM_MESSAGE_TYPE_STREAM_FEATURES,
+ LM_MESSAGE_TYPE_AUTH,
+ LM_MESSAGE_TYPE_CHALLENGE,
+ LM_MESSAGE_TYPE_RESPONSE,
+ LM_MESSAGE_TYPE_SUCCESS,
+ LM_MESSAGE_TYPE_FAILURE,
+ LM_MESSAGE_TYPE_PROCEED,
+ LM_MESSAGE_TYPE_STARTTLS,
+ LM_MESSAGE_TYPE_UNKNOWN
+} LmMessageType;
+
+typedef enum {
+ LM_MESSAGE_SUB_TYPE_NOT_SET = -10,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE = -1,
+ LM_MESSAGE_SUB_TYPE_NORMAL = 0,
+ LM_MESSAGE_SUB_TYPE_CHAT,
+ LM_MESSAGE_SUB_TYPE_GROUPCHAT,
+ LM_MESSAGE_SUB_TYPE_HEADLINE,
+ LM_MESSAGE_SUB_TYPE_UNAVAILABLE,
+ LM_MESSAGE_SUB_TYPE_PROBE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE,
+ LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBED,
+ LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED,
+ LM_MESSAGE_SUB_TYPE_GET,
+ LM_MESSAGE_SUB_TYPE_SET,
+ LM_MESSAGE_SUB_TYPE_RESULT,
+ LM_MESSAGE_SUB_TYPE_ERROR
+} LmMessageSubType;
+
+IMPORT_C LmMessage * lm_message_new (const gchar *to,
+ LmMessageType type);
+IMPORT_C LmMessage * lm_message_new_with_sub_type (const gchar *to,
+ LmMessageType type,
+ LmMessageSubType sub_type);
+IMPORT_C LmMessageType lm_message_get_type (LmMessage *message);
+IMPORT_C LmMessageSubType lm_message_get_sub_type (LmMessage *message);
+IMPORT_C LmMessageNode * lm_message_get_node (LmMessage *message);
+IMPORT_C LmMessage * lm_message_ref (LmMessage *message);
+IMPORT_C void lm_message_unref (LmMessage *message);
+
+G_END_DECLS
+
+#endif /* __LM_MESSAGE_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-proxy.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2004 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __LM_PROXY_H__
+#define __LM_PROXY_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+G_BEGIN_DECLS
+
+typedef struct _LmProxy LmProxy;
+
+typedef enum {
+ LM_PROXY_TYPE_NONE = 0,
+ LM_PROXY_TYPE_HTTP
+} LmProxyType;
+
+IMPORT_C LmProxy * lm_proxy_new (LmProxyType type);
+IMPORT_C LmProxy * lm_proxy_new_with_server (LmProxyType type,
+ const gchar *server,
+ guint port);
+
+IMPORT_C LmProxyType lm_proxy_get_type (LmProxy *proxy);
+IMPORT_C void lm_proxy_set_type (LmProxy *proxy,
+ LmProxyType type);
+
+IMPORT_C const gchar * lm_proxy_get_server (LmProxy *proxy);
+IMPORT_C void lm_proxy_set_server (LmProxy *proxy,
+ const gchar *server);
+
+IMPORT_C guint lm_proxy_get_port (LmProxy *proxy);
+IMPORT_C void lm_proxy_set_port (LmProxy *proxy,
+ guint port);
+
+IMPORT_C const gchar * lm_proxy_get_username (LmProxy *proxy);
+IMPORT_C void lm_proxy_set_username (LmProxy *proxy,
+ const gchar *username);
+
+IMPORT_C const gchar * lm_proxy_get_password (LmProxy *proxy);
+IMPORT_C void lm_proxy_set_password (LmProxy *proxy,
+ const gchar *password);
+
+IMPORT_C LmProxy * lm_proxy_ref (LmProxy *proxy);
+IMPORT_C void lm_proxy_unref (LmProxy *proxy);
+
+G_END_DECLS
+#endif /* __LM_PROXY_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-ssl.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,81 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2004 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_SSL_H__
+#define __LM_SSL_H__
+
+#include <glib.h>
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents."
+#endif
+
+G_BEGIN_DECLS
+
+typedef struct _LmSSL LmSSL;
+
+typedef enum {
+ LM_CERT_INVALID,
+ LM_CERT_ISSUER_NOT_FOUND,
+ LM_CERT_REVOKED
+} LmCertificateStatus;
+
+typedef enum {
+ LM_SSL_STATUS_NO_CERT_FOUND,
+ LM_SSL_STATUS_UNTRUSTED_CERT,
+ LM_SSL_STATUS_CERT_EXPIRED,
+ LM_SSL_STATUS_CERT_NOT_ACTIVATED,
+ LM_SSL_STATUS_CERT_HOSTNAME_MISMATCH,
+ LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH,
+ LM_SSL_STATUS_GENERIC_ERROR
+} LmSSLStatus;
+
+typedef enum {
+ LM_SSL_RESPONSE_CONTINUE,
+ LM_SSL_RESPONSE_STOP
+} LmSSLResponse;
+
+typedef LmSSLResponse (* LmSSLFunction) (LmSSL *ssl,
+ LmSSLStatus status,
+ gpointer user_data);
+
+IMPORT_C LmSSL * lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+IMPORT_C gboolean lm_ssl_is_supported (void);
+
+IMPORT_C const gchar * lm_ssl_get_fingerprint (LmSSL *ssl);
+
+IMPORT_C void lm_ssl_use_starttls (LmSSL *ssl,
+ gboolean use_starttls,
+ gboolean require);
+
+gboolean lm_ssl_get_use_starttls (LmSSL *ssl);
+
+gboolean lm_ssl_get_require_starttls (LmSSL *ssl);
+
+IMPORT_C LmSSL * lm_ssl_ref (LmSSL *ssl);
+IMPORT_C void lm_ssl_unref (LmSSL *ssl);
+
+G_END_DECLS
+
+#endif /* __LM_SSL_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/lm-utils.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LM_UTILS_H__
+#define __LM_UTILS_H__
+
+#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
+#error "Only <loudmouth/loudmouth.h> can be included directly, this file may di/sappear or change contents."
+#endif
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+IMPORT_C struct tm *lm_utils_get_localtime (const gchar *stamp);
+
+G_END_DECLS
+
+#endif /* __LM_UTILS_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/loudmouth/loudmouth.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,37 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LOUDMOUTH_H__
+#define __LOUDMOUTH_H__
+
+#define LM_INSIDE_LOUDMOUTH_H 1
+
+#include "loudmouth/lm-connection.h"
+#include "loudmouth/lm-error.h"
+#include "loudmouth/lm-message.h"
+#include "loudmouth/lm-message-handler.h"
+#include "loudmouth/lm-message-node.h"
+#include "loudmouth/lm-proxy.h"
+#include "loudmouth/lm-utils.h"
+#include "loudmouth/lm-ssl.h"
+
+#undef LM_INSIDE_LOUDMOUTH_H
+
+#endif /* __LOUDMOUTH_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/inc/md5.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Removed support for non-ANSI compilers; removed
+ references to Ghostscript; clarified derivation from RFC 1321;
+ now handles byte order either statically or dynamically.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+#ifndef md5_INCLUDED
+# define md5_INCLUDED
+
+/*
+ * This package supports both compile-time and run-time determination of CPU
+ * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
+ * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * defined as non-zero, the code will be compiled to run only on big-endian
+ * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
+ * run on either big- or little-endian CPUs, but will run slightly less
+ * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
+ */
+
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ md5_word_t count[2]; /* message length in bits, lsw first */
+ md5_word_t abcd[4]; /* digest buffer */
+ md5_byte_t buf[64]; /* accumulate block */
+} md5_state_t;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Initialize the algorithm. */
+void md5_init(md5_state_t *pms);
+
+/* Append a string to the message. */
+void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+
+/* Finish the message and return the digest. */
+void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* md5_INCLUDED */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/install/loudmouth.bat Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,26 @@
+/*
+ * loudmouth.bat
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+
+@ECHO OFF
+makesis loudmouth.pkg
+signsis loudmouth.sis loudmouth.sisx rd.cer rd-key.pem
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/install/loudmouth.pkg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,56 @@
+; ============================================================================
+; Name : loudmouth.pkg
+; Part of : OpenC project
+; Description : package file for all openc libraries
+;
+;
+;
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; * Redistributions of source code must retain the above copyright notice, this
+; list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright notice,
+; this list of conditions and the following disclaimer in the documentation
+; and/or other materials provided with the distribution.
+; * Neither the name of the <ORGANIZATION> nor the names of its contributors
+; may be used to endorse or promote products derived from this software
+; without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+; SERVICES, LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+; ===========================================================================
+;Languages
+&EN
+
+;Header
+#{"loudmouth-pkg"},(0x19207369),1,0,0
+
+;Localised Vendor name
+%{"Nokia Testing EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;INI FILE
+; "\epoc32\winscw\c\testframework\testframework.ini" - "c:\testframework\testframework_tlm.ini"
+
+;CFG FILES
+ "\epoc32\winscw\c\testframework\tstlm_gtalk.cfg" - "c:\testframework\tstlm_gtalk.cfg"
+ "\epoc32\winscw\c\testframework\tstlm_gtalk1.cfg" - "c:\testframework\tstlm_gtalk1.cfg"
+
+
+;TEST EXE
+"\epoc32\release\ARMV5\urel\tstlm.dll" - "!:\Sys\Bin\tstlm.dll"
+
+;loudmouth
+;"\epoc32\release\armv5\urel\loudmouth.dll" - "!:\sys\bin\loudmouth.dll"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/rom/loudmouth.iby Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,34 @@
+/*
+ * loudmouth.iby
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+#ifndef __LOUDMOUTH_IBY__
+#define __LOUDMOUTH_IBY__
+
+//Loudmouth DLLs
+file=ABI_DIR\BUILD_DIR\loudmouth.dll SHARED_LIB_DIR\loudmouth.dll
+
+// mecostub SIS, provides support for SIS upgrading
+//data=DATAZ_\system\install\meco_stub.sis system\install\meco_stub.sis
+
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/asyncns.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1143 @@
+/* $Id: asyncns.c 27 2007-02-16 13:51:03Z lennart $ */
+
+/***
+ This file is part of libasyncns.
+ Copyright (C) 2006 Collabora Ltd.
+
+ libasyncns is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ libasyncns is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with libasyncns; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+/*#undef HAVE_PTHREAD */
+
+#include <assert.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/select.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
+#if HAVE_PTHREAD
+#include <pthread.h>
+#endif
+
+#include "asyncns.h"
+
+#define MAX_WORKERS 16
+#define MAX_QUERIES 256
+#define BUFSIZE (10240)
+
+typedef enum {
+ REQUEST_ADDRINFO,
+ RESPONSE_ADDRINFO,
+ REQUEST_NAMEINFO,
+ RESPONSE_NAMEINFO,
+ REQUEST_RES_QUERY,
+ REQUEST_RES_SEARCH,
+ RESPONSE_RES,
+ REQUEST_TERMINATE
+} query_type_t;
+
+enum {
+ REQUEST_RECV_FD = 0,
+ REQUEST_SEND_FD = 1,
+ RESPONSE_RECV_FD = 2,
+ RESPONSE_SEND_FD = 3
+};
+
+struct asyncns {
+ int fds[4];
+
+#ifndef HAVE_PTHREAD
+ pid_t workers[MAX_WORKERS];
+#else
+ pthread_t workers[MAX_WORKERS];
+#endif
+ unsigned valid_workers;
+
+ unsigned current_id, current_index;
+ asyncns_query_t* queries[MAX_QUERIES];
+
+ asyncns_query_t *done_head, *done_tail;
+
+ int n_queries;
+};
+
+struct asyncns_query {
+ asyncns_t *asyncns;
+ int done;
+ unsigned id;
+ query_type_t type;
+ asyncns_query_t *done_next, *done_prev;
+ int ret;
+ struct addrinfo *addrinfo;
+ char *serv, *host;
+ void *userdata;
+};
+
+typedef struct rheader {
+ query_type_t type;
+ unsigned id;
+ size_t length;
+} rheader_t;
+
+typedef struct addrinfo_request {
+ struct rheader header;
+ int hints_is_null;
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ size_t node_len, service_len;
+} addrinfo_request_t;
+
+typedef struct addrinfo_response {
+ struct rheader header;
+ int ret;
+} addrinfo_response_t;
+
+typedef struct addrinfo_serialization {
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ size_t ai_addrlen;
+ size_t canonname_len;
+} addrinfo_serialization_t;
+
+typedef struct nameinfo_request {
+ struct rheader header;
+ int flags;
+ socklen_t sockaddr_len;
+ int gethost, getserv;
+} nameinfo_request_t;
+
+typedef struct nameinfo_response {
+ struct rheader header;
+ size_t hostlen, servlen;
+ int ret;
+} nameinfo_response_t;
+
+typedef struct res_query_request {
+ struct rheader header;
+ int class;
+ int type;
+ size_t dlen;
+} res_request_t;
+
+typedef struct res_query_response {
+ struct rheader header;
+ int ret;
+} res_response_t;
+
+#ifndef HAVE_STRNDUP
+
+static char *strndup(const char *s, size_t l) {
+ size_t a;
+ char *n;
+
+ a = strlen(s);
+ if (a > l)
+ a = l;
+
+ if (!(n = malloc(a+1)))
+ return NULL;
+
+ strncpy(n, s, a);
+ n[a] = 0;
+
+ return n;
+}
+
+#endif
+
+static int fd_nonblock(int fd) {
+ int i;
+ assert(fd >= 0);
+
+ if ((i = fcntl(fd, F_GETFL, 0)) < 0)
+ return -1;
+
+ if (i & O_NONBLOCK)
+ return 0;
+
+ return fcntl(fd, F_SETFL, i | O_NONBLOCK);
+}
+
+static int fd_cloexec(int fd) {
+ int v;
+ assert(fd >= 0);
+
+ if ((v = fcntl(fd, F_GETFD, 0)) < 0)
+ return -1;
+
+ if (v & FD_CLOEXEC)
+ return 0;
+
+ return fcntl(fd, F_SETFD, v | FD_CLOEXEC);
+}
+
+
+static void *serialize_addrinfo(void *p, const struct addrinfo *ai, size_t *length, size_t maxlength) {
+ addrinfo_serialization_t *s = p;
+ size_t cnl, l;
+ assert(p);
+ assert(ai);
+ assert(length);
+ assert(*length <= maxlength);
+
+ cnl = (ai->ai_canonname ? strlen(ai->ai_canonname)+1 : 0);
+ l = sizeof(addrinfo_serialization_t) + ai->ai_addrlen + cnl;
+
+ if (*length + l > maxlength)
+ return NULL;
+
+ s->ai_flags = ai->ai_flags;
+ s->ai_family = ai->ai_family;
+ s->ai_socktype = ai->ai_socktype;
+ s->ai_protocol = ai->ai_protocol;
+ s->ai_addrlen = ai->ai_addrlen;
+ s->canonname_len = cnl;
+
+ memcpy((uint8_t*) p + sizeof(addrinfo_serialization_t), ai->ai_addr, ai->ai_addrlen);
+
+ if (ai->ai_canonname)
+ strcpy((char*) p + sizeof(addrinfo_serialization_t) + ai->ai_addrlen, ai->ai_canonname);
+
+ *length += l;
+ return (uint8_t*) p + l;
+}
+
+static int send_addrinfo_reply(int out_fd, unsigned id, int ret, struct addrinfo *ai) {
+ uint8_t data[BUFSIZE];
+ addrinfo_response_t *resp = (addrinfo_response_t*) data;
+ assert(out_fd >= 0);
+
+ resp->header.type = RESPONSE_ADDRINFO;
+ resp->header.id = id;
+ resp->header.length = sizeof(addrinfo_response_t);
+ resp->ret = ret;
+
+ if (ret == 0 && ai) {
+ void *p = data + sizeof(addrinfo_response_t);
+
+ while (ai && p) {
+ p = serialize_addrinfo(p, ai, &resp->header.length, BUFSIZE);
+ ai = ai->ai_next;
+ }
+ }
+
+ if (ai)
+ freeaddrinfo(ai);
+
+ return send(out_fd, resp, resp->header.length, 0);
+}
+
+static int send_nameinfo_reply(int out_fd, unsigned id, int ret, const char *host, const char *serv) {
+ uint8_t data[BUFSIZE];
+ size_t hl, sl;
+ nameinfo_response_t *resp = (nameinfo_response_t*) data;
+
+ assert(out_fd >= 0);
+
+ sl = serv ? strlen(serv)+1 : 0;
+ hl = host ? strlen(host)+1 : 0;
+
+ resp->header.type = RESPONSE_NAMEINFO;
+ resp->header.id = id;
+ resp->header.length = sizeof(nameinfo_response_t) + hl + sl;
+ resp->ret = ret;
+ resp->hostlen = hl;
+ resp->servlen = sl;
+
+ assert(sizeof(data) >= resp->header.length);
+
+ if (host)
+ memcpy(data + sizeof(nameinfo_response_t), host, hl);
+
+ if (serv)
+ memcpy(data + sizeof(nameinfo_response_t) + hl, serv, sl);
+
+ return send(out_fd, resp, resp->header.length, 0);
+}
+
+static int send_res_reply(int out_fd, unsigned id, const unsigned char *answer, int ret) {
+ uint8_t data[BUFSIZE];
+ res_response_t *resp = (res_response_t *) data;
+
+ assert(out_fd >= 0);
+
+ resp->header.type = RESPONSE_RES;
+ resp->header.id = id;
+ resp->header.length = sizeof(res_response_t) + (ret < 0 ? 0 : ret);
+ resp->ret = (ret < 0) ? -errno : ret;
+
+ assert(sizeof(data) >= resp->header.length);
+
+ if (ret > 0)
+ memcpy(data + sizeof(res_response_t), answer, ret);
+
+ return send(out_fd, resp, resp->header.length, 0);
+}
+
+static int handle_request(int out_fd, const rheader_t *req, size_t length) {
+ assert(out_fd >= 0);
+ assert(req);
+ assert(length >= sizeof(rheader_t));
+ assert(length == req->length);
+
+ switch (req->type) {
+ case REQUEST_ADDRINFO: {
+ struct addrinfo ai, *result = NULL;
+ const addrinfo_request_t *ai_req = (const addrinfo_request_t*) req;
+ const char *node, *service;
+ int ret;
+
+ assert(length >= sizeof(addrinfo_request_t));
+ assert(length == sizeof(addrinfo_request_t) + ai_req->node_len + ai_req->service_len);
+
+ memset(&ai, 0, sizeof(ai));
+ ai.ai_flags = ai_req->ai_flags;
+ ai.ai_family = ai_req->ai_family;
+ ai.ai_socktype = ai_req->ai_socktype;
+ ai.ai_protocol = ai_req->ai_protocol;
+
+ node = ai_req->node_len ? (const char*) req + sizeof(addrinfo_request_t) : NULL;
+ service = ai_req->service_len ? (const char*) req + sizeof(addrinfo_request_t) + ai_req->node_len : NULL;
+
+ /*printf("[getaddrinfo for '%s']\n", node);*/
+ ret = getaddrinfo(node, service,
+ ai_req->hints_is_null ? NULL : &ai,
+ &result);
+ /*printf("[return value: %d: '%s']\n", ret, gai_strerror(ret));*/
+
+ /* send_addrinfo_reply() frees result */
+ return send_addrinfo_reply(out_fd, req->id, ret, result);
+ }
+
+ case REQUEST_NAMEINFO: {
+ int ret;
+ const nameinfo_request_t *ni_req = (const nameinfo_request_t*) req;
+ char hostbuf[NI_MAXHOST], servbuf[NI_MAXSERV];
+ const struct sockaddr *sa;
+
+ assert(length >= sizeof(nameinfo_request_t));
+ assert(length == sizeof(nameinfo_request_t) + ni_req->sockaddr_len);
+
+ sa = (const struct sockaddr*) ((const char*) req + sizeof(nameinfo_request_t));
+
+ ret = getnameinfo(sa, ni_req->sockaddr_len,
+ ni_req->gethost ? hostbuf : NULL, ni_req->gethost ? sizeof(hostbuf) : 0,
+ ni_req->getserv ? servbuf : NULL, ni_req->getserv ? sizeof(servbuf) : 0,
+ ni_req->flags);
+
+ return send_nameinfo_reply(out_fd, req->id, ret,
+ ret == 0 && ni_req->gethost ? hostbuf : NULL,
+ ret == 0 && ni_req->getserv ? servbuf : NULL);
+ }
+
+ case REQUEST_RES_QUERY:
+ case REQUEST_RES_SEARCH: {
+ int ret;
+ unsigned char answer[BUFSIZE];
+ const res_request_t *res_req = (const res_request_t *)req;
+ const char *dname;
+
+ assert(length >= sizeof(res_request_t));
+ assert(length == sizeof(res_request_t) + res_req->dlen + 1);
+
+ dname = (const char *) req + sizeof(res_request_t);
+
+ if (req->type == REQUEST_RES_QUERY) {
+ /*printf("[res query for '%s']\n", dname);*/
+ ret = res_query(dname, res_req->class, res_req->type,
+ answer, BUFSIZE);
+ /*printf("[return value: %d]\n", ret);*/
+ } else {
+ ret = res_search(dname, res_req->class, res_req->type,
+ answer, BUFSIZE);
+ }
+ return send_res_reply(out_fd, req->id, answer, ret);
+ }
+
+ case REQUEST_TERMINATE: {
+ /* Quit */
+ return -1;
+ }
+
+ default:
+ ;
+ }
+
+ return 0;
+}
+
+#ifndef HAVE_PTHREAD
+
+static int process_worker(int in_fd, int out_fd) {
+ int have_death_sig = 0;
+ assert(in_fd > 2);
+ assert(out_fd > 2);
+
+ close(0);
+ close(1);
+ close(2);
+
+ open("/dev/null", O_RDONLY);
+ open("/dev/null", O_WRONLY);
+ open("/dev/null", O_WRONLY);
+
+ chdir("/");
+
+ if (geteuid() == 0) {
+ struct passwd *pw;
+
+ if ((pw = getpwnam("nobody"))) {
+#ifdef HAVE_SETRESUID
+ setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid);
+#elif HAVE_SETREUID
+ setreuid(pw->pw_uid, pw->pw_uid);
+#else
+ setuid(pw->pw_uid);
+ seteuid(pw->pw_uid);
+#endif
+ }
+ }
+
+ signal(SIGTERM, SIG_DFL);
+
+ signal(SIGINT, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGUSR1, SIG_IGN);
+ signal(SIGUSR2, SIG_IGN);
+
+#ifdef PR_SET_PDEATHSIG
+ if (prctl(PR_SET_PDEATHSIG, SIGTERM) >= 0)
+ have_death_sig = 1;
+#endif
+
+ if (!have_death_sig)
+ fd_nonblock(in_fd);
+
+ while (getppid() > 1) { /* if the parent PID is 1 our parent process died. */
+ char buf[BUFSIZE];
+ ssize_t length;
+
+ if (!have_death_sig) {
+ fd_set fds;
+ struct timeval tv = { 0, 500000 } ;
+
+ FD_ZERO(&fds);
+ FD_SET(in_fd, &fds);
+
+ if (select(in_fd+1, &fds, NULL, NULL, &tv) < 0)
+ break;
+
+ if (getppid() == 1)
+ break;
+ }
+
+ if ((length = recv(in_fd, buf, sizeof(buf), 0)) <= 0) {
+
+ if (length < 0 && errno == EAGAIN)
+ continue;
+
+ break;
+ }
+
+ if (handle_request(out_fd, (rheader_t*) buf, (size_t) length) < 0)
+ break;
+ }
+
+ close(in_fd);
+ close(out_fd);
+
+ return 0;
+}
+
+#else
+
+static void* thread_worker(void *p) {
+ sigset_t fullset;
+ int *fds = p;
+ pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
+
+ /* No signals in this thread please */
+ sigfillset(&fullset);
+ pthread_sigmask(SIG_BLOCK, &fullset, NULL);
+
+ for (;;) {
+ char buf[BUFSIZE];
+ ssize_t length;
+
+ if ((length = recv(fds[REQUEST_RECV_FD], buf, sizeof(buf), 0)) <= 0)
+ break;
+
+ if (handle_request(fds[RESPONSE_SEND_FD], (rheader_t*) buf, (size_t) length) < 0)
+ break;
+
+ }
+
+ return NULL;
+}
+
+#endif
+
+asyncns_t* asyncns_new(unsigned n_proc) {
+ asyncns_t *asyncns = NULL;
+ int i;
+ unsigned p;
+ assert(n_proc >= 1);
+
+ if (n_proc > MAX_WORKERS)
+ n_proc = MAX_WORKERS;
+
+ if (!(asyncns = malloc(sizeof(asyncns_t))))
+ goto fail;
+
+ asyncns->valid_workers = 0;
+
+ for (i = 0; i < 4; i++)
+ asyncns->fds[i] = -1;
+
+ for (p = 0; p < MAX_QUERIES; p++)
+ asyncns->queries[p] = NULL;
+
+ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns->fds) < 0 ||
+ socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns->fds+2) < 0)
+ goto fail;
+
+ for (i = 0; i < 4; i++)
+ fd_cloexec(asyncns->fds[i]);
+
+ for (asyncns->valid_workers = 0; asyncns->valid_workers < n_proc; asyncns->valid_workers++) {
+
+#ifndef HAVE_PTHREAD
+ if ((asyncns->workers[asyncns->valid_workers] = fork()) < 0)
+ goto fail;
+ else if (asyncns->workers[asyncns->valid_workers] == 0) {
+ close(asyncns->fds[REQUEST_SEND_FD]);
+ close(asyncns->fds[RESPONSE_RECV_FD]);
+ _exit(process_worker(asyncns->fds[REQUEST_RECV_FD], asyncns->fds[RESPONSE_SEND_FD]));
+ }
+#else
+ if (pthread_create(&asyncns->workers[asyncns->valid_workers], NULL, thread_worker, asyncns->fds) != 0)
+ goto fail;
+#endif
+ }
+
+#ifndef HAVE_PTHREAD
+ close(asyncns->fds[REQUEST_RECV_FD]);
+ close(asyncns->fds[RESPONSE_SEND_FD]);
+ asyncns->fds[REQUEST_RECV_FD] = asyncns->fds[RESPONSE_SEND_FD] = -1;
+#endif
+
+ asyncns->current_index = asyncns->current_id = 0;
+ asyncns->done_head = asyncns->done_tail = NULL;
+ asyncns->n_queries = 0;
+
+ fd_nonblock(asyncns->fds[RESPONSE_RECV_FD]);
+
+ return asyncns;
+
+fail:
+ if (asyncns)
+ asyncns_free(asyncns);
+
+ return NULL;
+}
+
+void asyncns_free(asyncns_t *asyncns) {
+ unsigned p;
+ int i;
+ rheader_t req;
+ assert(asyncns);
+
+ req.type = REQUEST_TERMINATE;
+ req.length = sizeof(req);
+ req.id = 0;
+
+ /* Send one termiantion packet for each worker */
+ for (p = 0; p < asyncns->valid_workers; p++)
+ send(asyncns->fds[REQUEST_SEND_FD], &req, req.length, 0);
+
+ /* No terminate them forcibly*/
+ for (p = 0; p < asyncns->valid_workers; p++) {
+#ifndef HAVE_PTHREAD
+ kill(asyncns->workers[p], SIGTERM);
+ waitpid(asyncns->workers[p], NULL, 0);
+#else
+ pthread_cancel(asyncns->workers[p]);
+ pthread_join(asyncns->workers[p], NULL);
+#endif
+ }
+
+ /* Due to Solaris' broken thread cancelation we first send an
+ * termination request and then cancel th thread. */
+
+
+ for (i = 0; i < 4; i++)
+ if (asyncns->fds[i] >= 0)
+ close(asyncns->fds[i]);
+
+ for (p = 0; p < MAX_QUERIES; p++)
+ if (asyncns->queries[p])
+ asyncns_cancel(asyncns, asyncns->queries[p]);
+
+ free(asyncns);
+}
+
+int asyncns_fd(asyncns_t *asyncns) {
+ assert(asyncns);
+
+ return asyncns->fds[RESPONSE_RECV_FD];
+}
+
+static asyncns_query_t *lookup_query(asyncns_t *asyncns, unsigned id) {
+ asyncns_query_t *q;
+ assert(asyncns);
+
+ if ((q = asyncns->queries[id % MAX_QUERIES]))
+ if (q->id == id)
+ return q;
+
+ return NULL;
+}
+
+static void complete_query(asyncns_t *asyncns, asyncns_query_t *q) {
+ assert(asyncns);
+ assert(q);
+ assert(!q->done);
+
+ q->done = 1;
+
+ if ((q->done_prev = asyncns->done_tail))
+ asyncns->done_tail->done_next = q;
+ else
+ asyncns->done_head = q;
+
+ asyncns->done_tail = q;
+ q->done_next = NULL;
+}
+
+static void *unserialize_addrinfo(void *p, struct addrinfo **ret_ai, size_t *length) {
+ addrinfo_serialization_t *s = p;
+ size_t l;
+ struct addrinfo *ai;
+ assert(p);
+ assert(ret_ai);
+ assert(length);
+
+ if (*length < sizeof(addrinfo_serialization_t))
+ return NULL;
+
+ l = sizeof(addrinfo_serialization_t) + s->ai_addrlen + s->canonname_len;
+ if (*length < l)
+ return NULL;
+
+ if (!(ai = malloc(sizeof(struct addrinfo))))
+ goto fail;
+
+ ai->ai_addr = NULL;
+ ai->ai_canonname = NULL;
+ ai->ai_next = NULL;
+
+ if (s->ai_addrlen && !(ai->ai_addr = malloc(s->ai_addrlen)))
+ goto fail;
+
+ if (s->canonname_len && !(ai->ai_canonname = malloc(s->canonname_len)))
+ goto fail;
+
+ ai->ai_flags = s->ai_flags;
+ ai->ai_family = s->ai_family;
+ ai->ai_socktype = s->ai_socktype;
+ ai->ai_protocol = s->ai_protocol;
+ ai->ai_addrlen = s->ai_addrlen;
+
+ if (ai->ai_addr)
+ memcpy(ai->ai_addr, (uint8_t*) p + sizeof(addrinfo_serialization_t), s->ai_addrlen);
+
+ if (ai->ai_canonname)
+ memcpy(ai->ai_canonname, (uint8_t*) p + sizeof(addrinfo_serialization_t) + s->ai_addrlen, s->canonname_len);
+
+ *length -= l;
+ *ret_ai = ai;
+
+ return (uint8_t*) p + l;
+
+
+fail:
+ if (ai)
+ asyncns_freeaddrinfo(ai);
+
+ return NULL;
+}
+
+static int handle_response(asyncns_t *asyncns, rheader_t *resp, size_t length) {
+ asyncns_query_t *q;
+ assert(asyncns);
+ assert(resp);
+ assert(length >= sizeof(rheader_t));
+ assert(length == resp->length);
+
+ if (!(q = lookup_query(asyncns, resp->id)))
+ return 0;
+
+ switch (resp->type) {
+ case RESPONSE_ADDRINFO: {
+ const addrinfo_response_t *ai_resp = (addrinfo_response_t*) resp;
+ void *p;
+ size_t l;
+ struct addrinfo *prev = NULL;
+
+ assert(length >= sizeof(addrinfo_response_t));
+ assert(q->type == REQUEST_ADDRINFO);
+
+ q->ret = ai_resp->ret;
+ l = length - sizeof(addrinfo_response_t);
+ p = (uint8_t*) resp + sizeof(addrinfo_response_t);
+
+ while (l > 0 && p) {
+ struct addrinfo *ai = NULL;
+ p = unserialize_addrinfo(p, &ai, &l);
+
+ if (!ai)
+ break;
+
+ if (prev)
+ prev->ai_next = ai;
+ else
+ q->addrinfo = ai;
+
+ prev = ai;
+ }
+
+ complete_query(asyncns, q);
+ break;
+ }
+
+ case RESPONSE_NAMEINFO: {
+ const nameinfo_response_t *ni_resp = (nameinfo_response_t*) resp;
+
+ assert(length >= sizeof(nameinfo_response_t));
+ assert(q->type == REQUEST_NAMEINFO);
+
+ q->ret = ni_resp->ret;
+
+ if (ni_resp->hostlen)
+ q->host = strndup((const char*) ni_resp + sizeof(nameinfo_response_t), ni_resp->hostlen-1);
+
+ if (ni_resp->servlen)
+ q->serv = strndup((const char*) ni_resp + sizeof(nameinfo_response_t) + ni_resp->hostlen, ni_resp->servlen-1);
+
+
+ complete_query(asyncns, q);
+ break;
+ }
+
+ case RESPONSE_RES: {
+ const res_response_t *res_resp = (res_response_t *)resp;
+
+ assert(length >= sizeof(res_response_t));
+ assert(q->type == REQUEST_RES_QUERY || q->type == REQUEST_RES_SEARCH);
+
+ q->ret = res_resp->ret;
+
+ if (res_resp->ret >= 0) {
+ q->serv = malloc(res_resp->ret);
+ memcpy(q->serv, (char *)resp + sizeof(res_response_t), res_resp->ret);
+ }
+
+ complete_query(asyncns, q);
+ break;
+ }
+
+ default:
+ ;
+ }
+
+ return 0;
+}
+
+int asyncns_wait(asyncns_t *asyncns, int block) {
+ int handled = 0;
+ assert(asyncns);
+
+ for (;;) {
+ char buf[BUFSIZE];
+ ssize_t l;
+
+ if (((l = recv(asyncns->fds[RESPONSE_RECV_FD], buf, sizeof(buf), 0)) < 0)) {
+ fd_set fds;
+
+ if (errno != EAGAIN)
+ return -1;
+
+ if (!block || handled)
+ return 0;
+
+ FD_ZERO(&fds);
+ FD_SET(asyncns->fds[RESPONSE_RECV_FD], &fds);
+
+ if (select(asyncns->fds[RESPONSE_RECV_FD]+1, &fds, NULL, NULL, NULL) < 0)
+ return -1;
+
+ continue;
+ }
+
+
+ if (handle_response(asyncns, (rheader_t*) buf, (size_t) l) < 0)
+ return -1;
+
+ handled = 1;
+ }
+}
+
+static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
+ asyncns_query_t *q;
+ assert(asyncns);
+
+ if (asyncns->n_queries >= MAX_QUERIES)
+ return NULL;
+
+ while (asyncns->queries[asyncns->current_index]) {
+
+ asyncns->current_index++;
+ asyncns->current_id++;
+
+ while (asyncns->current_index >= MAX_QUERIES)
+ asyncns->current_index -= MAX_QUERIES;
+ }
+
+ if (!(q = asyncns->queries[asyncns->current_index] = malloc(sizeof(asyncns_query_t))))
+ return NULL;
+
+ asyncns->n_queries++;
+
+ q->asyncns = asyncns;
+ q->done = 0;
+ q->id = asyncns->current_id;
+ q->done_next = q->done_prev = NULL;
+ q->ret = 0;
+ q->addrinfo = NULL;
+ q->userdata = NULL;
+ q->host = q->serv = NULL;
+
+ return q;
+}
+
+asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints) {
+ uint8_t data[BUFSIZE];
+ addrinfo_request_t *req = (addrinfo_request_t*) data;
+ asyncns_query_t *q;
+ assert(asyncns);
+ assert(node || service);
+
+ if (!(q = alloc_query(asyncns)))
+ return NULL;
+
+ memset(req, 0, sizeof(addrinfo_request_t));
+
+ req->node_len = node ? strlen(node)+1 : 0;
+ req->service_len = service ? strlen(service)+1 : 0;
+
+ req->header.id = q->id;
+ req->header.type = q->type = REQUEST_ADDRINFO;
+ req->header.length = sizeof(addrinfo_request_t) + req->node_len + req->service_len;
+
+ if (req->header.length > BUFSIZE)
+ goto fail;
+
+ if (!(req->hints_is_null = !hints)) {
+ req->ai_flags = hints->ai_flags;
+ req->ai_family = hints->ai_family;
+ req->ai_socktype = hints->ai_socktype;
+ req->ai_protocol = hints->ai_protocol;
+ }
+
+ if (node)
+ strcpy((char*) req + sizeof(addrinfo_request_t), node);
+
+ if (service)
+ strcpy((char*) req + sizeof(addrinfo_request_t) + req->node_len, service);
+
+ if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, 0) < 0)
+ goto fail;
+
+ return q;
+
+fail:
+ if (q)
+ asyncns_cancel(asyncns, q);
+
+ return NULL;
+}
+
+int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res) {
+ int ret;
+ assert(asyncns);
+ assert(q);
+ assert(q->asyncns == asyncns);
+ assert(q->type == REQUEST_ADDRINFO);
+
+ if (!q->done)
+ return EAI_AGAIN;
+
+ *ret_res = q->addrinfo;
+ q->addrinfo = NULL;
+ ret = q->ret;
+ asyncns_cancel(asyncns, q);
+
+ return ret;
+}
+
+asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
+ uint8_t data[BUFSIZE];
+ nameinfo_request_t *req = (nameinfo_request_t*) data;
+ asyncns_query_t *q;
+
+ assert(asyncns);
+ assert(sa);
+ assert(salen > 0);
+
+ if (!(q = alloc_query(asyncns)))
+ return NULL;
+
+ memset(req, 0, sizeof(nameinfo_request_t));
+
+ req->header.id = q->id;
+ req->header.type = q->type = REQUEST_NAMEINFO;
+ req->header.length = sizeof(nameinfo_request_t) + salen;
+
+ if (req->header.length > BUFSIZE)
+ goto fail;
+
+ req->flags = flags;
+ req->sockaddr_len = salen;
+ req->gethost = gethost;
+ req->getserv = getserv;
+
+ memcpy((uint8_t*) req + sizeof(nameinfo_request_t), sa, salen);
+
+ if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, 0) < 0)
+ goto fail;
+
+ return q;
+
+fail:
+ if (q)
+ asyncns_cancel(asyncns, q);
+
+ return NULL;
+}
+
+int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
+ int ret;
+ assert(asyncns);
+ assert(q);
+ assert(q->asyncns == asyncns);
+ assert(q->type == REQUEST_NAMEINFO);
+ assert(!ret_host || hostlen);
+ assert(!ret_serv || servlen);
+
+ if (!q->done)
+ return EAI_AGAIN;
+
+ if (ret_host && q->host) {
+ strncpy(ret_host, q->host, hostlen);
+ ret_host[hostlen-1] = 0;
+ }
+
+ if (ret_serv && q->serv) {
+ strncpy(ret_serv, q->serv, servlen);
+ ret_serv[servlen-1] = 0;
+ }
+
+ ret = q->ret;
+ asyncns_cancel(asyncns, q);
+
+ return ret;
+}
+
+static asyncns_query_t *
+asyncns_res(asyncns_t *asyncns, query_type_t qtype,
+ const char *dname, int class, int type) {
+ uint8_t data[BUFSIZE];
+ res_request_t *req = (res_request_t*) data;
+ asyncns_query_t *q;
+ size_t dlen;
+
+ assert(asyncns);
+ assert(dname);
+
+ dlen = strlen(dname);
+
+ if (!(q = alloc_query(asyncns)))
+ return NULL;
+
+ memset(req, 0, sizeof(res_request_t));
+
+ req->header.id = q->id;
+ req->header.type = q->type = qtype;
+ req->header.length = sizeof(res_request_t) + dlen + 1;
+
+ if (req->header.length > BUFSIZE)
+ goto fail;
+
+ req->class = class;
+ req->type = type;
+ req->dlen = dlen;
+
+ memcpy((uint8_t*) req + sizeof(res_request_t), dname, dlen + 1);
+
+ if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, 0) < 0)
+ goto fail;
+
+ return q;
+
+fail:
+ if (q)
+ asyncns_cancel(asyncns, q);
+
+ return NULL;
+}
+
+asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type) {
+ return asyncns_res(asyncns, REQUEST_RES_QUERY, dname, class, type);
+}
+
+asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type) {
+ return asyncns_res(asyncns, REQUEST_RES_SEARCH, dname, class, type);
+}
+
+int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer) {
+ int ret;
+ assert(asyncns);
+ assert(q);
+ assert(q->asyncns == asyncns);
+ assert(q->type == REQUEST_RES_QUERY || q->type == REQUEST_RES_SEARCH);
+ assert(answer);
+
+ if (!q->done)
+ return -EAGAIN;
+
+ *answer = (unsigned char *)q->serv;
+ q->serv = NULL;
+
+ ret = q->ret;
+
+ asyncns_cancel(asyncns, q);
+
+ return ret;
+}
+
+asyncns_query_t* asyncns_getnext(asyncns_t *asyncns) {
+ assert(asyncns);
+ return asyncns->done_head;
+}
+
+int asyncns_getnqueries(asyncns_t *asyncns) {
+ assert(asyncns);
+ return asyncns->n_queries;
+}
+
+void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q) {
+ int i;
+ assert(asyncns);
+ assert(q);
+ assert(q->asyncns == asyncns);
+ assert(asyncns->n_queries > 0);
+
+ if (q->done) {
+
+ if (q->done_prev)
+ q->done_prev->done_next = q->done_next;
+ else
+ asyncns->done_head = q->done_next;
+
+ if (q->done_next)
+ q->done_next->done_prev = q->done_prev;
+ else
+ asyncns->done_tail = q->done_prev;
+ }
+
+
+ i = q->id % MAX_QUERIES;
+ assert(asyncns->queries[i] == q);
+ asyncns->queries[i] = NULL;
+
+ asyncns_freeaddrinfo(q->addrinfo);
+ free(q->addrinfo);
+ free(q->host);
+ free(q->serv);
+
+ asyncns->n_queries--;
+ free(q);
+}
+
+void asyncns_freeaddrinfo(struct addrinfo *ai) {
+ if (!ai)
+ return;
+
+ while (ai) {
+ struct addrinfo *next = ai->ai_next;
+
+ free(ai->ai_addr);
+ free(ai->ai_canonname);
+ free(ai);
+
+ ai = next;
+ }
+}
+
+int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q) {
+ assert(asyncns);
+ assert(q);
+ assert(q->asyncns == asyncns);
+
+ return q->done;
+}
+
+void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata) {
+ assert(q);
+ assert(asyncns);
+ assert(q->asyncns = asyncns);
+
+ q->userdata = userdata;
+}
+
+void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q) {
+ assert(q);
+ assert(asyncns);
+ assert(q->asyncns = asyncns);
+
+ return q->userdata;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/base64.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,207 @@
+/*
+ * base64.c - Base 64 encoding/decoding implementation
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <ctype.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "base64.h"
+
+/*
+|AAAA AABB|BBBB CCCC|CCDD DDDD|
+
+0xFC = 1111 1100
+0x03 = 0000 0011
+0xF0 = 1111 0000
+0x0F = 0000 1111
+0xC0 = 1100 0000
+0x3F = 0011 1111
+
+3 input bytes = 4 output bytes;
+2 input bytes = 2 output bytes;
+1 input byte = 1 output byte.
+*/
+
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+
+GET_STATIC_ARRAY_FROM_TLS(encoding, lm_base64, gchar)
+ #define encoding (GET_WSD_VAR_NAME(encoding, lm_base64, s)())
+
+#else
+
+static const gchar *encoding =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+#endif
+
+
+
+static const guint decoding[256] =
+{
+ /* ... */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0,
+ /* + */
+ 62,
+ /* ... */
+ 0, 0, 0,
+ /* / , 0-9 */
+ 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+ /* ... */
+ 0, 0, 0, 0, 0, 0, 0,
+ /* A */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+ /* ... */
+ 0, 0, 0, 0, 0, 0,
+ /* a */
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+};
+
+#define GET_6_BITS_0(s) (((s)[0] & 0xFC) >> 2)
+#define GET_6_BITS_1(s) (((s)[0] & 0x03) << 4) | \
+ (((s)[1] & 0xF0) >> 4)
+#define GET_6_BITS_2(s) (((s)[1] & 0x0F) << 2) | \
+ (((s)[2] & 0xC0) >> 6)
+#define GET_6_BITS_3(s) (((s)[2] & 0x3F) << 0)
+
+#define GET_BYTE_0(s) (((decoding[(guchar)(s)[0]] & 0x3F) << 2) | \
+ ((decoding[(guchar)(s)[1]] & 0x30) >> 4))
+#define GET_BYTE_1(s) (((decoding[(guchar)(s)[1]] & 0x0F) << 4) | \
+ ((decoding[(guchar)(s)[2]] & 0x3C) >> 2))
+#define GET_BYTE_2(s) (((decoding[(guchar)(s)[2]] & 0x03) << 6) | \
+ ((decoding[(guchar)(s)[3]] & 0xFF) << 0))
+
+gchar *_lm_base64_encode (const gchar *txt, gsize n)
+{
+ guint i;
+ guint len;
+ GString *tmp;
+ GString *str = g_string_new_len (txt, n);
+
+ len = str->len;
+ /* TODO: calculate requisite output string length and allocate that big a
+ * GString */
+ tmp = g_string_new ("");
+
+ for (i = 0; i < len; i += 3)
+ {
+ guint c1, c2, c3, c4;
+
+ switch (i + 3 - len)
+ {
+ case 1:
+ c1 = encoding[GET_6_BITS_0 (str->str + i)];
+ c2 = encoding[GET_6_BITS_1 (str->str + i)];
+ c3 = encoding[GET_6_BITS_2 (str->str + i)];
+ c4 = '=';
+ break;
+ case 2:
+ c1 = encoding[GET_6_BITS_0 (str->str + i)];
+ c2 = encoding[GET_6_BITS_1 (str->str + i)];
+ c3 = '=';
+ c4 = '=';
+ break;
+ default:
+ c1 = encoding[GET_6_BITS_0 (str->str + i)];
+ c2 = encoding[GET_6_BITS_1 (str->str + i)];
+ c3 = encoding[GET_6_BITS_2 (str->str + i)];
+ c4 = encoding[GET_6_BITS_3 (str->str + i)];
+ }
+
+ g_string_append_printf (tmp, "%c%c%c%c", c1, c2, c3, c4);
+ }
+
+ return g_string_free (tmp, FALSE);
+}
+
+gchar *_lm_base64_decode (const gchar *str, gsize *len)
+{
+ guint i;
+ GString *tmp;
+ char group[4];
+ guint filled = 0;
+
+ *len = 0;
+
+ for (i = 0; str[i]; i++)
+ {
+ if (str[i] != 'A' &&
+ str[i] != '=' &&
+ !isspace(str[i]) &&
+ decoding[(guchar) str[i]] == 0)
+ {
+ g_debug ("bad character %x at byte %u", (guchar)str[i], i);
+ return NULL;
+ }
+ }
+
+ tmp = g_string_new ("");
+
+ for (i = 0; str[i]; i++)
+ {
+ if (isspace(str[i]))
+ continue;
+
+ group[filled++] = str[i];
+
+ if (filled == 4)
+ {
+ if (group[3] == '=')
+ {
+ if (group[2] == '=')
+ {
+ g_string_append_c (tmp, GET_BYTE_0(group));
+ }
+ else
+ {
+ g_string_append_c (tmp, GET_BYTE_0(group));
+ g_string_append_c (tmp, GET_BYTE_1(group));
+ }
+ }
+ else
+ {
+ g_string_append_c (tmp, GET_BYTE_0(group));
+ g_string_append_c (tmp, GET_BYTE_1(group));
+ g_string_append_c (tmp, GET_BYTE_2(group));
+ }
+ filled = 0;
+ }
+ }
+
+ if (filled)
+ {
+ g_debug ("insufficient padding at end of base64 string:\n%s", str);
+ g_string_free (tmp, TRUE);
+ return NULL;
+ }
+
+ *len = tmp->len;
+ return g_string_free (tmp, FALSE);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/libloudmouth_wsd.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2003-2007 Imendio AB
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary/subsidiaries.
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <e32std.h>
+#include "libloudmouth_wsd_solution.h"
+#include <string.h>
+
+
+#include <pls.h> // For emulator WSD API
+
+const TUid KLibLoudmouthUid3 = {0x10281F99}; // This is the UID of the library
+struct libloudmouth_global_struct *libloudmouth_ImpurePtr()
+{
+ #if defined(__WINSCW__) || defined(__WINS__)
+
+ // Access the PLS of this process
+ struct libloudmouth_global_struct *g = Pls<struct libloudmouth_global_struct>(KLibLoudmouthUid3, &libloudmouth_Init);
+ return g;
+
+ #else
+
+ return NULL;
+
+ #endif
+};
+
+int libloudmouth_Init(libloudmouth_global_struct *g)
+{
+
+TypeNames type_names[14] = {
+ { LM_MESSAGE_TYPE_MESSAGE, "message" },
+ { LM_MESSAGE_TYPE_PRESENCE, "presence" },
+ { LM_MESSAGE_TYPE_IQ, "iq" },
+ { LM_MESSAGE_TYPE_STREAM, "stream:stream" },
+ { LM_MESSAGE_TYPE_STREAM_FEATURES, "stream:features" },
+ { LM_MESSAGE_TYPE_STREAM_ERROR, "stream:error" },
+ { LM_MESSAGE_TYPE_AUTH, "auth" },
+ { LM_MESSAGE_TYPE_CHALLENGE, "challenge" },
+ { LM_MESSAGE_TYPE_RESPONSE, "response" },
+ { LM_MESSAGE_TYPE_SUCCESS, "success" },
+ { LM_MESSAGE_TYPE_FAILURE, "failure" },
+ { LM_MESSAGE_TYPE_PROCEED, "proceed" },
+ { LM_MESSAGE_TYPE_STARTTLS, "starttls" },
+ { LM_MESSAGE_TYPE_UNKNOWN, NULL }
+
+};
+
+SubTypeNames sub_type_names[14] = {
+ { LM_MESSAGE_SUB_TYPE_NORMAL, "normal" },
+ { LM_MESSAGE_SUB_TYPE_CHAT, "chat" },
+ { LM_MESSAGE_SUB_TYPE_GROUPCHAT, "groupchat" },
+ { LM_MESSAGE_SUB_TYPE_HEADLINE, "headline" },
+ { LM_MESSAGE_SUB_TYPE_UNAVAILABLE, "unavailable" },
+ { LM_MESSAGE_SUB_TYPE_PROBE, "probe" },
+ { LM_MESSAGE_SUB_TYPE_SUBSCRIBE, "subscribe" },
+ { LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE, "unsubscribe" },
+ { LM_MESSAGE_SUB_TYPE_SUBSCRIBED, "subscribed" },
+ { LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED, "unsubscribed" },
+ { LM_MESSAGE_SUB_TYPE_GET, "get" },
+ { LM_MESSAGE_SUB_TYPE_SET, "set" },
+ { LM_MESSAGE_SUB_TYPE_RESULT, "result" },
+ { LM_MESSAGE_SUB_TYPE_ERROR, "error" }
+};
+gchar base_64_chars[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+gchar encoding1[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+gchar retval[41] = "";
+
+char buffer[256] = "";
+
+ if(g)
+ {
+ //g->GET_WSD_VAR_NAME(debug_flags,lm_debug,g) = Flags;
+
+ g->GET_WSD_VAR_NAME(initialized,lm_debug,g) = EFalse;
+ g->GET_WSD_VAR_NAME(log_handler_id,lm_debug,g) = 0;
+ memcpy (&(g->GET_WSD_VAR_NAME(type_names,lm_message,s)), type_names, 13*sizeof(TypeNames));
+ memcpy (&(g->GET_WSD_VAR_NAME(sub_type_names,lm_message,s)), sub_type_names, 14*sizeof(SubTypeNames));
+ g->GET_WSD_VAR_NAME(initialized,lm_ssl_openssl,s) = EFalse;
+ g->GET_WSD_VAR_NAME(last_id,lm_utils, s) = 0;
+
+ strcpy((g->GET_WSD_VAR_NAME(base64chars,lm_utils,s)), base_64_chars);
+
+ strcpy((g->GET_WSD_VAR_NAME(ret_val,lm_sha,s)), retval);
+
+ strcpy((g->GET_WSD_VAR_NAME(encoding,lm_base64,s)), encoding1);
+
+ strcpy((g->GET_WSD_VAR_NAME(buf,lm_misc,s)), buffer);
+
+ g->GET_WSD_VAR_NAME(initialised,lm_sock,g) = EFalse;
+ return 0;
+ }
+ return 1;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-connection.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,2248 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2007 Imendio AB
+ * and/or its subsidiary/subsidiaries. All rights reserved.
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+/* Needed on Mac OS X */
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#include <arpa/nameser.h>
+//#include <resolv.h>
+
+#include <glib.h>
+#include <gdebug.h>
+
+#include "lm-sock.h"
+#include "lm-debug.h"
+#include "lm-error.h"
+#include "lm-internals.h"
+#include "lm-message-queue.h"
+#include "lm-misc.h"
+#include "lm-ssl-internals.h"
+#include "lm-parser.h"
+#include "lm-sha.h"
+#include "lm-connection.h"
+#include "lm-utils.h"
+#include "lm-socket.h"
+#include "lm-sasl.h"
+
+#define IN_BUFFER_SIZE 1024
+//#define SRV_LEN 8192
+#define SRV_LEN 2048 // check the actual value needed here! - MeCo
+
+typedef struct {
+ LmHandlerPriority priority;
+ LmMessageHandler *handler;
+} HandlerData;
+
+struct _LmConnection {
+ /* Parameters */
+ GMainContext *context;
+ gchar *server;
+ gchar *jid;
+ gchar *effective_jid;
+ guint port;
+ gboolean use_srv;
+
+ LmSocket *socket;
+ LmSSL *ssl;
+ LmProxy *proxy;
+ LmParser *parser;
+
+ gchar *stream_id;
+
+ GHashTable *id_handlers;
+ GSList *handlers[LM_MESSAGE_TYPE_UNKNOWN];
+
+ /* XMPP1.0 stuff (SASL, resource binding, StartTLS) */
+ gboolean use_sasl;
+ LmSASL *sasl;
+ gchar *resource;
+ LmMessageHandler *features_cb;
+ LmMessageHandler *starttls_cb;
+ gboolean tls_started;
+
+ /* Communication */
+ guint open_id;
+ LmCallback *open_cb;
+
+ gboolean async_connect_waiting;
+ gboolean blocking;
+
+ gboolean cancel_open;
+ LmCallback *auth_cb;
+
+ LmCallback *disconnect_cb;
+
+ LmMessageQueue *queue;
+
+ LmConnectionState state;
+
+ guint keep_alive_rate;
+ GSource *keep_alive_source;
+
+ gint ref_count;
+};
+
+typedef enum {
+ AUTH_TYPE_PLAIN = 1,
+ AUTH_TYPE_DIGEST = 2,
+ AUTH_TYPE_0K = 4
+} AuthType;
+
+#define XMPP_NS_BIND "urn:ietf:params:xml:ns:xmpp-bind"
+#define XMPP_NS_SESSION "urn:ietf:params:xml:ns:xmpp-session"
+#define XMPP_NS_STARTTLS "urn:ietf:params:xml:ns:xmpp-tls"
+
+static void connection_free (LmConnection *connection);
+
+
+static void connection_handle_message (LmConnection *connection,
+ LmMessage *message);
+
+static void connection_new_message_cb (LmParser *parser,
+ LmMessage *message,
+ LmConnection *connection);
+static gboolean connection_do_open (LmConnection *connection,
+ GError **error);
+void connection_do_close (LmConnection *connection);
+
+
+static LmMessage * connection_create_auth_req_msg (const gchar *username);
+static LmMessage * connection_create_auth_msg (LmConnection *connection,
+ const gchar *username,
+ const gchar *password,
+ const gchar *resource,
+ gint auth_type);
+static LmHandlerResult connection_auth_req_reply (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *m,
+ gpointer user_data);
+static int connection_check_auth_type (LmMessage *auth_req_rpl);
+
+static LmHandlerResult
+connection_auth_reply (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *m,
+ gpointer user_data);
+
+static void connection_stream_received (LmConnection *connection,
+ LmMessage *m);
+static void connection_stream_error (LmConnection *connection,
+ LmMessage *m);
+
+static gint connection_handler_compare_func (HandlerData *a,
+ HandlerData *b);
+static gboolean connection_send_keep_alive (LmConnection *connection);
+static void connection_start_keep_alive (LmConnection *connection);
+static void connection_stop_keep_alive (LmConnection *connection);
+static gboolean connection_send (LmConnection *connection,
+ const gchar *str,
+ gint len,
+ GError **error);
+static void connection_message_queue_cb (LmMessageQueue *queue,
+ LmConnection *connection);
+static void connection_signal_disconnect (LmConnection *connection,
+ LmDisconnectReason reason);
+static void connection_incoming_data (LmSocket *socket,
+ const gchar *buf,
+ LmConnection *connection);
+static void connection_socket_closed_cb (LmSocket *socket,
+ LmDisconnectReason reason,
+ LmConnection *connection);
+static void connection_socket_connect_cb (LmSocket *socket,
+ gboolean result,
+ LmConnection *connection);
+
+static gboolean connection_get_server_from_jid (const gchar *jid,
+ gchar **server);
+static void connection_send_stream_header (LmConnection *connection);
+static LmHandlerResult connection_features_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data);
+
+static void
+connection_free (LmConnection *connection)
+{
+ int i;
+
+ g_free (connection->server);
+ g_free (connection->jid);
+ g_free (connection->effective_jid);
+ g_free (connection->stream_id);
+ g_free (connection->resource);
+
+ if (connection->sasl) {
+ lm_sasl_free (connection->sasl);
+ }
+
+ if (connection->parser) {
+ lm_parser_free (connection->parser);
+ }
+
+ /* Unref handlers */
+ for (i = 0; i < LM_MESSAGE_TYPE_UNKNOWN; ++i) {
+ GSList *l;
+
+ for (l = connection->handlers[i]; l; l = l->next) {
+ HandlerData *hd = (HandlerData *) l->data;
+
+ lm_message_handler_unref (hd->handler);
+ g_free (hd);
+ }
+
+ g_slist_free (connection->handlers[i]);
+ }
+
+ g_hash_table_destroy (connection->id_handlers);
+ if (connection->state >= LM_CONNECTION_STATE_OPENING) {
+ connection_do_close (connection);
+ }
+
+ if (connection->open_cb) {
+ _lm_utils_free_callback (connection->open_cb);
+ }
+
+ if (connection->auth_cb) {
+ _lm_utils_free_callback (connection->auth_cb);
+ }
+
+ lm_connection_set_disconnect_function (connection, NULL, NULL, NULL);
+
+ if (connection->proxy) {
+ lm_proxy_unref (connection->proxy);
+ }
+
+ lm_message_queue_unref (connection->queue);
+
+ if (connection->context) {
+ g_main_context_unref (connection->context);
+ }
+
+ if (connection->socket) {
+ lm_socket_unref (connection->socket);
+ }
+
+ g_free (connection);
+}
+
+static void
+connection_handle_message (LmConnection *connection, LmMessage *m)
+{
+ LmMessageHandler *handler;
+ GSList *l;
+ const gchar *id;
+ LmHandlerResult result = LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ lm_connection_ref (connection);
+ lm_verbose("[connection_handle_message]: Inside\n");
+ lm_verbose("msg type:[%d]\n", lm_message_get_type (m));
+ id = lm_message_node_get_attribute (m->node, "id");
+ if(id)
+ {
+ lm_verbose("handlemsg node id: %s\n", id);
+ }
+ if (lm_message_get_type (m) == LM_MESSAGE_TYPE_STREAM) {
+ lm_verbose("[connection_handle_message]: Stream received\n");
+ lm_verbose("[connection_handle_message]: calling connection_stream_received \n");
+ connection_stream_received (connection, m);
+ lm_verbose("[connection_handle_message]: CALLED connection_stream_received \n");
+ goto out;
+ }
+
+ if ((lm_message_get_sub_type (m) == LM_MESSAGE_SUB_TYPE_ERROR) ||
+ (lm_message_get_sub_type (m) == LM_MESSAGE_SUB_TYPE_RESULT)) {
+ id = lm_message_node_get_attribute (m->node, "id");
+
+ lm_verbose("[connection_handle_message]: type is error or result \n");
+ if (id) {
+ handler = g_hash_table_lookup (connection->id_handlers, id);
+ if (handler) {
+ lm_verbose("[connection_handle_message]: calling the right handler for error/result \n");
+ result = _lm_message_handler_handle_message (handler,
+ connection,
+ m);
+ lm_verbose("[connection_handle_message]: Called right handler for error/result \n");
+ g_hash_table_remove (connection->id_handlers,
+ id);
+ }
+ }
+
+ if (result == LM_HANDLER_RESULT_REMOVE_MESSAGE) {
+ lm_verbose("return from connection_handle_message\n");
+ goto out;
+ }
+ }
+ lm_verbose("[connection_handle_message]:starting for loop for more handlers\n");
+ for (l = connection->handlers[lm_message_get_type (m)];
+ l && result == LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ l = l->next) {
+ HandlerData *hd = (HandlerData *) l->data;
+ lm_verbose("[connection_handle_message]:inside for loop for more handlers with msg type: %d\n", lm_message_get_type (m));
+ lm_verbose("[connection_handle_message]:inside for loop with node name: %s\n",lm_message_get_node(m)->name);
+ result = _lm_message_handler_handle_message (hd->handler,
+ connection,
+ m);
+ lm_verbose("[connection_handle_message]:got result from _lm_message_handler_handle_message as :%d\n",result);
+ }
+ lm_verbose("[connection_handle_message]:Ended for loop for more handlers\n");
+ if (lm_message_get_type (m) == LM_MESSAGE_TYPE_STREAM_ERROR) {
+ lm_verbose("[connection_handle_message]:stream error\n");
+ connection_stream_error (connection, m);
+ goto out;
+ }
+
+out:
+ lm_verbose("[connection_handle_message]:exiting connection_handle_message\n");
+ lm_connection_unref (connection);
+ lm_verbose("[connection_handle_message]:after unref of connection\n");
+ return;
+}
+
+static void
+connection_new_message_cb (LmParser *parser,
+ LmMessage *m,
+ LmConnection *connection)
+{
+ const gchar *from;
+
+ lm_message_ref (m);
+
+ from = lm_message_node_get_attribute (m->node, "from");
+ if (!from) {
+ from = "unknown";
+ }
+
+ lm_verbose ("New message with type=\"%s\" from: %s\n",
+ _lm_message_type_to_string (lm_message_get_type (m)),
+ from);
+
+ lm_message_queue_push_tail (connection->queue, m);
+ UNUSED_FORMAL_PARAM(parser);
+}
+
+static gboolean
+connection_send_keep_alive (LmConnection *connection)
+{
+ lm_verbose ("[connection_send_keep_alive]\n");
+ if (!connection_send (connection, " ", -1, NULL)) {
+ lm_verbose ("Error while sending keep alive package!\n");
+ }
+ return TRUE;
+}
+
+static void
+connection_start_keep_alive (LmConnection *connection)
+{
+ lm_verbose("[connection_start_keep_alive]:Inside ....");
+ /* try using TCP keepalives if possible */
+ if ((connection->keep_alive_rate > 0) &&
+ lm_socket_set_keepalive (connection->socket,
+ connection->keep_alive_rate)) {
+ lm_verbose("[connection_start_keep_alive]: timer already active\n");
+ connection->keep_alive_source =
+ lm_misc_add_timeout (connection->context,
+ connection->keep_alive_rate * 1000,
+ (GSourceFunc) connection_send_keep_alive,
+ connection);
+ return;
+ }
+
+ if (connection->keep_alive_source) {
+ lm_verbose("[connection_start_keep_alive]:stopping keep alive timer");
+ connection_stop_keep_alive (connection);
+ }
+
+ if (connection->keep_alive_rate > 0) {
+ connection->keep_alive_source =
+ lm_misc_add_timeout (connection->context,
+ connection->keep_alive_rate * 1000,
+ (GSourceFunc) connection_send_keep_alive,
+ connection);
+ lm_verbose("[connection_start_keep_alive]: added timer to gsource\n");
+ }
+lm_verbose("[connection_start_keep_alive]: ...Exiting connection_start_keep_alive....");
+}
+
+static void
+connection_stop_keep_alive (LmConnection *connection)
+{
+ lm_verbose("[connection_start_keep_alive]:Stopping Keep Alive\n");
+ if (connection->keep_alive_source) {
+ g_source_destroy (connection->keep_alive_source);
+ }
+
+ connection->keep_alive_source = NULL;
+}
+
+static gboolean
+connection_send (LmConnection *connection,
+ const gchar *str,
+ gint len,
+ GError **error)
+{
+ gint b_written;
+
+ if (connection->state < LM_CONNECTION_STATE_OPENING) {
+ /* g_log (LM_LOG_DOMAIN,LM_LOG_LEVEL_NET,
+ "Connection is not open.\n");
+
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ "Connection is not open, call lm_connection_open() first");*/
+ lm_verbose("[connection_send]: Connection is not open call lm_connection_open() first");
+ return FALSE;
+ }
+
+ if (len == -1) {
+ len = strlen (str);
+ }
+
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nSEND:\n");
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ // "-----------------------------------\n");
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "%s\n", str);
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ // "-----------------------------------\n");
+ lm_verbose ( "\n[connection_send]: SEND:\n");
+ lm_verbose ( "-----------------------------------\n");
+ lm_verbose ( "%s\n", str);
+ lm_verbose ( "-----------------------------------\n");
+
+ /* Check to see if there already is an output buffer, if so, add to the
+ buffer and return */
+
+ if (lm_socket_output_is_buffered (connection->socket, str, len)) {
+ return TRUE;
+ }
+
+ b_written = lm_socket_do_write (connection->socket, str, len);
+
+ lm_verbose("[connection_send]: number of bytes written using lm_socket_do_write is : %d\n",b_written);
+ if (b_written < 0) {
+ lm_verbose("[connection_send]: Since b_written<0 closing the connection\n");
+ connection_do_close (connection);
+ connection_signal_disconnect (connection,
+ LM_DISCONNECT_REASON_ERROR);
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_FAILED,
+ "Server closed the connection");
+ return FALSE;
+ }
+
+ if (b_written < len) {
+ lm_socket_setup_output_buffer (connection->socket,
+ str + b_written,
+ len - b_written);
+ }
+
+ return TRUE;
+}
+
+static void
+connection_message_queue_cb (LmMessageQueue *queue, LmConnection *connection)
+{
+ LmMessage *m;
+
+ m = lm_message_queue_pop_nth (connection->queue, 0);
+
+ if (m) {
+ lm_verbose("In connection_message_queue_cb\n");
+ connection_handle_message (connection, m);
+ lm_message_unref (m);
+ lm_verbose("After un refing the message\n");
+ }
+ UNUSED_FORMAL_PARAM(queue);
+}
+
+/* Returns directly */
+/* Setups all data needed to start the connection attempts */
+static gboolean
+connection_do_open (LmConnection *connection, GError **error)
+{
+ gchar *domain = NULL;
+
+ if (lm_connection_is_open (connection)) {
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ "Connection is already open, call lm_connection_close() first");
+ return FALSE;
+ }
+
+ if (!connection_get_server_from_jid (connection->jid, &domain)) {
+ domain = g_strdup (connection->server);
+ }
+
+ lm_verbose ("[connection_do_open]: Connecting to: %s:%d\n", connection->server, connection->port);
+
+ connection->socket = lm_socket_create (connection->context,
+ (IncomingDataFunc) connection_incoming_data,
+ (SocketClosedFunc) connection_socket_closed_cb,
+ (ConnectResultFunc) connection_socket_connect_cb,
+ connection,
+ connection,
+ connection->blocking,
+ connection->server,
+ domain,
+ connection->port,
+ connection->ssl,
+ connection->proxy,
+ error);
+
+ g_free (domain);
+ lm_verbose ("[connection_do_open]: after lm_socket_create call in connection_do_open");
+
+ if (!connection->socket) {
+ return FALSE;
+ }
+
+ lm_message_queue_attach (connection->queue, connection->context);
+
+ connection->state = LM_CONNECTION_STATE_OPENING;
+ connection->async_connect_waiting = FALSE;
+
+ return TRUE;
+}
+
+void
+connection_do_close (LmConnection *connection)
+{
+ connection_stop_keep_alive (connection);
+
+ if (connection->socket) {
+ lm_socket_close (connection->socket);
+ }
+
+ lm_message_queue_detach (connection->queue);
+
+ if (!lm_connection_is_open (connection)) {
+ /* lm_connection_is_open is FALSE for state OPENING as well */
+ connection->state = LM_CONNECTION_STATE_CLOSED;
+ connection->async_connect_waiting = FALSE;
+ return;
+ }
+
+ connection->state = LM_CONNECTION_STATE_CLOSED;
+ connection->async_connect_waiting = FALSE;
+ if (connection->ssl) {
+ _lm_ssl_close (connection->ssl);
+ }
+
+ if (connection->sasl) {
+ lm_sasl_free (connection->sasl);
+ connection->sasl = NULL;
+ }
+}
+
+typedef struct {
+ gchar *username;
+ gchar *password;
+ gchar *resource;
+} AuthReqData;
+
+static void
+auth_req_data_free (AuthReqData *data)
+{
+ g_free (data->username);
+ g_free (data->password);
+ g_free (data->resource);
+ g_free (data);
+}
+
+static LmMessage *
+connection_create_auth_req_msg (const gchar *username)
+{
+ LmMessage *m;
+ LmMessageNode *q_node;
+
+ m = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (m->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,
+ "xmlns", "jabber:iq:auth",
+ NULL);
+ lm_message_node_add_child (q_node, "username", username);
+
+ return m;
+}
+
+static LmMessage *
+connection_create_auth_msg (LmConnection *connection,
+ const gchar *username,
+ const gchar *password,
+ const gchar *resource,
+ gint auth_type)
+{
+ LmMessage *auth_msg;
+ LmMessageNode *q_node;
+
+ auth_msg = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ q_node = lm_message_node_add_child (auth_msg->node, "query", NULL);
+
+ lm_message_node_set_attributes (q_node,
+ "xmlns", "jabber:iq:auth",
+ NULL);
+
+ lm_message_node_add_child (q_node, "username", username);
+
+ if (auth_type & AUTH_TYPE_0K) {
+ lm_verbose ("Using 0k auth (not implemented yet)\n");
+ /* TODO: Should probably use this? */
+ }
+
+ if (auth_type & AUTH_TYPE_DIGEST) {
+ gchar *str;
+ const gchar *digest;
+
+ lm_verbose ("Using digest\n");
+ str = g_strconcat (connection->stream_id, password, NULL);
+ digest = lm_sha_hash (str);
+ g_free (str);
+ lm_message_node_add_child (q_node, "digest", digest);
+ }
+ else if (auth_type & AUTH_TYPE_PLAIN) {
+ lm_verbose ("Using plaintext auth\n");
+ lm_message_node_add_child (q_node, "password", password);
+ } else {
+ /* TODO: Report error somehow */
+ }
+
+ lm_message_node_add_child (q_node, "resource", resource);
+
+ return auth_msg;
+}
+
+static LmHandlerResult
+connection_auth_req_reply (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *m,
+ gpointer user_data)
+{
+ int auth_type;
+ LmMessage *auth_msg;
+ LmMessageHandler *auth_handler;
+ AuthReqData *data = (AuthReqData *) user_data;
+ gboolean result;
+
+ auth_type = connection_check_auth_type (m);
+
+ auth_msg = connection_create_auth_msg (connection,
+ data->username,
+ data->password,
+ data->resource,
+ auth_type);
+
+ auth_handler = lm_message_handler_new (connection_auth_reply,
+ NULL, NULL);
+ result = lm_connection_send_with_reply (connection, auth_msg,
+ auth_handler, NULL);
+ lm_message_handler_unref (auth_handler);
+ lm_message_unref (auth_msg);
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(user_data);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static int
+connection_check_auth_type (LmMessage *auth_req_rpl)
+{
+ LmMessageNode *q_node;
+ gint ret_val = 0;
+
+ q_node = lm_message_node_get_child (auth_req_rpl->node, "query");
+
+ if (!q_node) {
+ return AUTH_TYPE_PLAIN;
+ }
+
+ if (lm_message_node_get_child (q_node, "password")) {
+ ret_val |= AUTH_TYPE_PLAIN;
+ }
+
+ if (lm_message_node_get_child (q_node, "digest")) {
+ ret_val |= AUTH_TYPE_DIGEST;
+ }
+
+ if (lm_message_node_get_child (q_node, "sequence") &&
+ lm_message_node_get_child (q_node, "token")) {
+ ret_val |= AUTH_TYPE_0K;
+ }
+
+ return ret_val;
+}
+
+static LmHandlerResult
+connection_auth_reply (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *m,
+ gpointer user_data)
+{
+ const gchar *type;
+ gboolean result = TRUE;
+
+ g_return_val_if_fail (connection != NULL,
+ LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS);
+
+
+ type = lm_message_node_get_attribute (m->node, "type");
+ if (strcmp (type, "result") == 0) {
+ result = TRUE;
+ connection->state = LM_CONNECTION_STATE_AUTHENTICATED;
+ }
+ else if (strcmp (type, "error") == 0) {
+ result = FALSE;
+ connection->state = LM_CONNECTION_STATE_OPEN;
+ }
+
+ lm_verbose ("AUTH reply: %d\n", result);
+
+ if (connection->auth_cb) {
+ LmCallback *cb = connection->auth_cb;
+
+ connection->auth_cb = NULL;
+
+ if (cb->func) {
+ (* ((LmResultFunction) cb->func)) (connection,
+ result, cb->user_data);
+ }
+
+ _lm_utils_free_callback (cb);
+ }
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(user_data);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+
+static LmHandlerResult
+_lm_connection_starttls_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ if (lm_socket_starttls (connection->socket)) {
+ connection->tls_started = TRUE;
+ connection_send_stream_header (connection);
+ } else {
+ connection_do_close (connection);
+ connection_signal_disconnect (connection,
+ LM_DISCONNECT_REASON_ERROR);
+ }
+ UNUSED_FORMAL_PARAM(message);
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(user_data);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+connection_stream_received (LmConnection *connection, LmMessage *m)
+{
+ gboolean result;
+ const char *xmpp_version;
+
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (m != NULL);
+
+ connection->stream_id = g_strdup (lm_message_node_get_attribute (m->node,
+ "id"));;
+
+ xmpp_version = lm_message_node_get_attribute (m->node, "version");
+ if (xmpp_version && strcmp (xmpp_version, "1.0") == 0) {
+ lm_verbose ("[connection_stream_received]: XMPP 1.0 stream received: %s\n",
+ connection->stream_id);
+
+ connection->use_sasl = TRUE;
+
+ /* stream is started multiple times, but we only want
+ * one sasl mechanism */
+ if (!connection->sasl)
+ connection->sasl = lm_sasl_new(connection);
+
+ /* if we'd like to use tls and we didn't already start
+ * it, prepare for it now */
+ if (connection->ssl &&
+ lm_ssl_get_use_starttls (connection->ssl) &&
+ !connection->starttls_cb) {
+ lm_verbose("[connction_stream_received]: Starttls called");
+ connection->starttls_cb =
+ lm_message_handler_new (_lm_connection_starttls_cb,
+ NULL, NULL);
+ lm_connection_register_message_handler (connection,
+ connection->starttls_cb,
+ LM_MESSAGE_TYPE_PROCEED,
+ LM_HANDLER_PRIORITY_FIRST);
+ }
+ } else {
+ lm_verbose ("Old Jabber stream received: %s\n",
+ connection->stream_id);
+ }
+
+ if (connection->state < LM_CONNECTION_STATE_OPEN) {
+ connection->state = LM_CONNECTION_STATE_OPEN;
+ }
+
+ /* Check to see if the stream is correctly set up */
+ result = TRUE;
+
+// connection_start_keep_alive (connection); //prima
+
+ if (connection->open_cb) {
+ LmCallback *cb = connection->open_cb;
+
+ connection->open_cb = NULL;
+
+ if (cb->func) {
+ (* ((LmResultFunction) cb->func)) (connection, result,
+ cb->user_data);
+ }
+ _lm_utils_free_callback (cb);
+ }
+}
+
+static void
+connection_stream_error (LmConnection *connection, LmMessage *m)
+{
+ LmMessageNode *node, *reason_node;
+ LmDisconnectReason reason;
+
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (m != NULL);
+
+ node = m->node;
+
+ /* Resource conflict */
+ reason_node = lm_message_node_get_child (node, "conflict");
+ if (reason_node) {
+ lm_verbose ("Stream error: Conflict (resource connected elsewhere)\n");
+ reason = LM_DISCONNECT_REASON_RESOURCE_CONFLICT;
+ return;
+ }
+
+ /* XML is crack */
+ reason_node = lm_message_node_get_child (node, "xml-not-well-formed");
+ if (reason_node) {
+ lm_verbose ("Stream error: XML not well formed\n");
+ reason = LM_DISCONNECT_REASON_INVALID_XML;
+ return;
+ }
+
+ lm_verbose ("Stream error: Unrecognised error\n");
+ reason = LM_DISCONNECT_REASON_ERROR;
+ connection->stream_id = g_strdup (lm_message_node_get_attribute (m->node,
+ "id"));;
+ connection_do_close (connection);
+ connection_signal_disconnect (connection, reason);
+}
+
+static gint
+connection_handler_compare_func (HandlerData *a, HandlerData *b)
+{
+ return b->priority - a->priority;
+}
+
+static void
+connection_signal_disconnect (LmConnection *connection,
+ LmDisconnectReason reason)
+{
+ lm_verbose ("[connection_signal_disconnect]\n");
+ if (connection->disconnect_cb && connection->disconnect_cb->func) {
+
+ LmCallback *cb = connection->disconnect_cb;
+ lm_verbose("[connection_signal_disconnect]: ...disconnecting\n");
+ lm_connection_ref (connection);
+ (* ((LmDisconnectFunction) cb->func)) (connection,
+ reason,
+ cb->user_data);
+ lm_connection_unref (connection);
+ lm_verbose("[connection_signal_disconnect]: ...after unref\n");
+ }
+}
+
+static void
+connection_incoming_data (LmSocket *socket,
+ const gchar *buf,
+ LmConnection *connection)
+{
+ lm_parser_parse (connection->parser, buf);
+ UNUSED_FORMAL_PARAM(socket);
+}
+
+static void
+connection_socket_closed_cb (LmSocket *socket,
+ LmDisconnectReason reason,
+ LmConnection *connection)
+{
+ lm_verbose("[connection_socket_closed_cb]: inside..\n");
+ connection_do_close (connection);
+ connection_signal_disconnect (connection, reason);
+ lm_verbose("[connection_socket_closed_cb]: exiting..\n");
+ UNUSED_FORMAL_PARAM(socket);
+}
+
+static void
+connection_socket_connect_cb (LmSocket *socket,
+ gboolean result,
+ LmConnection *connection)
+{
+ if (!result) {
+ connection_do_close (connection);
+ lm_verbose ("[connection_socket_connect_cb]: result false ");
+ if (connection->open_cb) {
+ LmCallback *cb = connection->open_cb;
+ lm_verbose ("[connection_socket_connect_cb]: connection->open_cb is defined ");
+
+ connection->open_cb = NULL;
+
+ (* ((LmResultFunction) cb->func)) (connection, FALSE,
+ cb->user_data);
+ _lm_utils_free_callback (cb);
+ }
+
+ UNUSED_FORMAL_PARAM(socket);
+ return;
+ }
+
+ /* FIXME: Set up according to XMPP 1.0 specification */
+ /* StartTLS and the like */
+ if (!connection_send (connection,
+ "<?xml version='1.0' encoding='UTF-8'?>", -1,
+ NULL)) {
+ lm_verbose ("Failed to send xml version and encoding\n");
+ connection_do_close (connection);
+
+ return;
+ }
+
+ connection_send_stream_header (connection);
+ lm_verbose("\n[connection_socket_connect_cb]: exiting ");
+}
+
+static gboolean
+connection_get_server_from_jid (const gchar *jid,
+ gchar **server)
+{
+ gchar *ch;
+ gchar *ch_end;
+
+ if (jid != NULL && (ch = strchr (jid, '@')) != NULL) {
+ ch_end = strchr(ch + 1, '/');
+ if (ch_end != NULL) {
+ *server = g_strndup (ch + 1, ch_end - ch - 1);
+ } else {
+ *server = g_strdup (ch + 1);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+connection_send_stream_header (LmConnection *connection)
+{
+ LmMessage *m;
+ gchar *server_from_jid;
+
+ lm_verbose ("Sending stream header\n");
+
+ if (!connection_get_server_from_jid (connection->jid, &server_from_jid)) {
+ server_from_jid = g_strdup (connection->server);
+ }
+
+ m = lm_message_new (server_from_jid, LM_MESSAGE_TYPE_STREAM);
+ lm_message_node_set_attributes (m->node,
+ "xmlns:stream",
+ "http://etherx.jabber.org/streams",
+ "xmlns", "jabber:client",
+ "version", "1.0",
+ NULL);
+
+ g_free (server_from_jid);
+
+ if (!lm_connection_send (connection, m, NULL)) {
+ lm_verbose ("Failed to send stream information\n");
+ connection_do_close (connection);
+ }
+ connection_start_keep_alive (connection); //prima
+ lm_message_unref (m);
+ lm_verbose("\n[connection_send_stream_header]: Exiting send stream header method");
+}
+
+gboolean
+_lm_connection_async_connect_waiting (LmConnection *connection)
+{
+ return connection->async_connect_waiting;
+}
+
+void
+_lm_connection_set_async_connect_waiting (LmConnection *connection,
+ gboolean waiting)
+{
+ connection->async_connect_waiting = waiting;
+}
+
+static void
+connection_call_auth_cb (LmConnection *connection, gboolean success)
+{
+ if (success) {
+ lm_verbose("connection_call_auth_cb: authenticated\n");
+ connection->state = LM_CONNECTION_STATE_AUTHENTICATED;
+ } else {
+ lm_verbose("connection_call_auth_cb: conn still open\n");
+ connection->state = LM_CONNECTION_STATE_OPEN;
+ }
+
+ if (connection->auth_cb) {
+ LmCallback *cb = connection->auth_cb;
+
+ connection->auth_cb = NULL;
+
+ if (cb->func) {
+ lm_verbose("connection_call_auth_cb: calling the test code's registered cb method\n");
+ (* ((LmResultFunction) cb->func)) (connection,
+ success,
+ cb->user_data);
+ }
+
+ _lm_utils_free_callback (cb);
+ }
+}
+
+static LmHandlerResult
+connection_bind_reply (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmMessage *m;
+ LmMessageNode *session_node;
+ LmMessageNode *jid_node;
+ int result;
+ LmMessageSubType type;
+ lm_verbose("[connection_bind_reply]: inside connection_bind_reply\n");
+ type = lm_message_get_sub_type (message);
+ if (type == LM_MESSAGE_SUB_TYPE_ERROR) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: error while binding to resource\n", G_STRFUNC);*/
+ lm_verbose("[connection_bind_reply]: calling connection_call_auth_cb\n");
+ connection_call_auth_cb (connection, FALSE);
+ lm_verbose("[connection_bind_reply]: called connection_call_auth_cb\n");
+ UNUSED_FORMAL_PARAM(user_data);
+ UNUSED_FORMAL_PARAM(handler);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ /* use whatever server returns as our effective jid */
+ jid_node = lm_message_node_find_child (message->node, "jid");
+ if (jid_node) {
+ g_free (connection->effective_jid);
+ connection->effective_jid = g_strdup
+ (lm_message_node_get_value (jid_node));
+ }
+
+
+ m = lm_message_new_with_sub_type (NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ lm_verbose("[connection_bind_reply]: Creation session child node\n");
+ session_node = lm_message_node_add_child (m->node, "session", NULL);
+ lm_message_node_set_attributes (session_node,
+ "xmlns", XMPP_NS_SESSION,
+ NULL);
+ lm_verbose("[connection_bind_reply]: Sending session child node\n");
+ result = lm_connection_send (connection, m, NULL);
+ lm_message_unref (m);
+ if (result < 0) {
+ connection_do_close (connection);
+ }
+
+ /* We may finally tell the client they're authorized */
+ connection_call_auth_cb (connection, TRUE);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static LmHandlerResult
+connection_features_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmMessageNode *bind_node;
+ LmMessageNode *starttls_node;
+ LmMessageNode *old_auth;
+ lm_verbose("[connection_features_cb] inside..\n");
+
+ starttls_node = lm_message_node_find_child (message->node, "starttls");
+ if (connection->ssl && lm_ssl_get_use_starttls (connection->ssl)) {
+ if (starttls_node) {
+ LmMessage *msg;
+
+ msg = lm_message_new (NULL, LM_MESSAGE_TYPE_STARTTLS);
+
+ lm_message_node_set_attributes (
+ msg->node,
+ "xmlns", XMPP_NS_STARTTLS,
+ NULL);
+
+ lm_connection_send (connection, msg, NULL);
+ lm_message_unref (msg);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ } else if (!connection->tls_started &&
+ lm_ssl_get_require_starttls (connection->ssl)) {
+ /* If there were no starttls features present and we require it, this is
+ * the place to scream. */
+ lm_verbose("connection_features_cb: Required StartTLS feature not supported by server\n");
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: required StartTLS feature not supported by server\n", G_STRFUNC);*/
+ connection_do_close (connection);
+ connection_signal_disconnect (connection,
+ LM_DISCONNECT_REASON_ERROR);
+ UNUSED_FORMAL_PARAM(user_data);
+ UNUSED_FORMAL_PARAM(handler);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ }
+
+ bind_node = lm_message_node_find_child (message->node, "bind");
+ if (bind_node) {
+ LmMessageHandler *bind_handler;
+ LmMessage *bind_msg;
+ const gchar *ns;
+ int result;
+
+ lm_verbose("connection_features_cb: found bind node\n");
+ ns = lm_message_node_get_attribute (bind_node, "xmlns");
+ if (!ns || strcmp (ns, XMPP_NS_BIND) != 0) {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ bind_msg = lm_message_new_with_sub_type (NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ bind_node = lm_message_node_add_child (bind_msg->node,
+ "bind", NULL);
+ lm_message_node_set_attributes (bind_node,
+ "xmlns", XMPP_NS_BIND,
+ NULL);
+
+ lm_message_node_add_child (bind_node, "resource",
+ connection->resource);
+
+ lm_verbose("[connection_features_cb]:setting callback method for bind response\n");
+ bind_handler = lm_message_handler_new (connection_bind_reply,
+ NULL, NULL);
+ lm_verbose("[connection_features_cb]: calling lm_connection_send_with_reply for bind response\n");
+ result = lm_connection_send_with_reply (connection, bind_msg,
+ bind_handler, NULL);
+ lm_verbose("[connection_features_cb]:called lm_connection_send_with_reply for bind response with result: %d\n", result);
+ lm_message_handler_unref (bind_handler);
+ lm_message_unref (bind_msg);
+
+ if (result < 0) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: can't send resource binding request\n", G_STRFUNC);*/
+ connection_do_close (connection);
+ }
+ }
+
+ old_auth = lm_message_node_find_child (message->node, "auth");
+ if (connection->use_sasl && old_auth) {
+ g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "Server uses XEP-0078 (jabber iq auth) instead of SASL\n");
+ /* So the server is XMPP1.0, but doesn't support SASL and uses
+ * obsolete XEP-0078 instead. Let's cope. */
+
+ connection->use_sasl = FALSE;
+
+ if (connection->sasl) {
+ const gchar *user, *pass;
+
+ lm_sasl_get_auth_params (connection->sasl, &user, &pass);
+ if (user && pass) {
+ GError *error = NULL;
+ lm_verbose("[connection_features_cb]:calling _lm_connection_old_auth\n");
+ _lm_connection_old_auth (connection, user, pass,
+ connection->resource, &error);
+
+ if (error) {
+ g_error_free (error);
+ }
+ }
+
+ lm_sasl_free (connection->sasl);
+ connection->sasl = NULL;
+ }
+ }
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+/**
+ * lm_connection_new:
+ * @server: The hostname to the server for the connection.
+ *
+ * Creates a new closed connection. To open the connection call
+ * lm_connection_open(). @server can be #NULL but must be set before calling lm_connection_open().
+ *
+ * Return value: A newly created LmConnection, should be unreffed with lm_connection_unref().
+ **/
+EXPORT_C LmConnection *
+lm_connection_new (const gchar *server)
+{
+ LmConnection *connection = NULL;
+ gint i;
+
+ lm_debug_init ();
+ _lm_sock_library_init ();
+
+ connection = g_new0 (LmConnection, 1);
+
+ if (server) {
+ connection->server = _lm_utils_hostname_to_punycode (server);
+ connection->use_srv = FALSE;
+ } else {
+ connection->server = NULL;
+ connection->use_srv = TRUE;
+ }
+
+ connection->context = NULL;
+ connection->port = LM_CONNECTION_DEFAULT_PORT;
+ connection->jid = NULL;
+ connection->effective_jid = NULL;
+ connection->ssl = NULL;
+ connection->proxy = NULL;
+ connection->disconnect_cb = NULL;
+ connection->queue = lm_message_queue_new ((LmMessageQueueCallback) connection_message_queue_cb,
+ connection);
+ connection->cancel_open = FALSE;
+ connection->state = LM_CONNECTION_STATE_CLOSED;
+ connection->keep_alive_source = NULL;
+ connection->keep_alive_rate = 0;
+ connection->socket = NULL;
+ connection->use_sasl = FALSE;
+ connection->tls_started = FALSE;
+
+ connection->id_handlers = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) lm_message_handler_unref);
+ connection->ref_count = 1;
+
+ for (i = 0; i < LM_MESSAGE_TYPE_UNKNOWN; ++i) {
+ connection->handlers[i] = NULL;
+ }
+
+ connection->parser = lm_parser_new
+ ((LmParserMessageFunction) connection_new_message_cb,
+ connection, NULL);
+
+ return connection;
+}
+
+/**
+ * lm_connection_new_with_context:
+ * @server: The hostname to the server for the connection.
+ * @context: The context this connection should be running in.
+ *
+ * Creates a new closed connection running in a certain context. To open the
+ * connection call #lm_connection_open. @server can be #NULL but must be set
+ * before calling #lm_connection_open.
+ *
+ * Return value: A newly created LmConnection, should be unreffed with lm_connection_unref().
+ **/
+EXPORT_C LmConnection *
+lm_connection_new_with_context (const gchar *server, GMainContext *context)
+{
+ LmConnection *connection;
+
+ connection = lm_connection_new (server);
+ connection->context = context;
+
+ if (context) {
+ g_main_context_ref (connection->context);
+ }
+
+ return connection;
+}
+
+/**
+ * lm_connection_open:
+ * @connection: #LmConnection to open
+ * @function: Callback function that will be called when the connection is open.
+ * @user_data: User data that will be passed to @function.
+ * @notify: Function for freeing that user_data, can be NULL.
+ * @error: location to store error, or %NULL
+ *
+ * An async call to open @connection. When the connection is open @function will be called.
+ *
+ * Return value: #TRUE if everything went fine, otherwise #FALSE.
+ **/
+EXPORT_C gboolean
+lm_connection_open (LmConnection *connection,
+ LmResultFunction function,
+ gpointer user_data,
+ GDestroyNotify notify,
+ GError **error)
+{
+ lm_verbose("[lm_connection_open]: open...");
+ g_return_val_if_fail (connection != NULL, FALSE);
+
+ connection->open_cb = _lm_utils_new_callback ((gpointer)function,
+ user_data, notify);
+ connection->blocking = FALSE;
+ lm_verbose("[lm_connection_open]: calling connection_do_open...");
+ return connection_do_open (connection, error);
+}
+
+/**
+ * lm_connection_open_and_block:
+ * @connection: an #LmConnection to open
+ * @error: location to store error, or %NULL
+ *
+ * Opens @connection and waits until the stream is setup.
+ *
+ * Return value: #TRUE if no errors where encountered during opening and stream setup successfully, #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_open_and_block (LmConnection *connection, GError **error)
+{
+ gboolean result;
+ LmConnectionState state;
+
+ g_return_val_if_fail (connection != NULL, FALSE);
+
+ connection->open_cb = NULL;
+ connection->blocking = TRUE;
+
+ result = connection_do_open (connection, error);
+
+ if (result == FALSE) {
+ return FALSE;
+ }
+
+ while ((state = lm_connection_get_state (connection)) == LM_CONNECTION_STATE_OPENING) {
+ if (g_main_context_pending (connection->context)) {
+ g_main_context_iteration (connection->context, TRUE);
+ } else {
+ /* Sleep for 1 millisecond */
+ g_usleep (1000);
+ }
+ }
+
+ if (lm_connection_is_open (connection)) {
+ connection_start_keep_alive (connection);
+ return TRUE;
+ }
+
+ /* Need to set the error here: LM-15 */
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_FAILED,
+ "Opening the connection failed");
+
+ return FALSE;
+}
+
+/**
+ * lm_connection_cancel_open:
+ * @connection: an #LmConnection to cancel opening on
+ *
+ * Cancels the open operation of a connection. The connection should be in the state #LM_CONNECTION_STATE_OPENING.
+ **/
+EXPORT_C void
+lm_connection_cancel_open (LmConnection *connection)
+{
+ g_return_if_fail (connection != NULL);
+
+ lm_verbose("[lm_connection_cancel_open]: inside..");
+ if (connection->open_cb) {
+ _lm_utils_free_callback (connection->open_cb);
+ connection->open_cb = NULL;
+ }
+
+ connection->cancel_open = TRUE;
+
+#ifdef HAVE_ASYNCNS
+ lm_verbose("[lm_connection_cancel_open] called in HAVE_ASYNCNS");
+ _asyncns_cancel(connection->socket);
+#endif
+}
+
+/**
+ * lm_connection_close:
+ * @connection: #LmConnection to close
+ * @error: location to store error, or %NULL
+ *
+ * A synchronous call to close the connection. When returning the connection is considered to be closed and can be opened again with lm_connection_open().
+ *
+ * Return value: Returns #TRUE if no errors where detected, otherwise #FALSE.
+ **/
+EXPORT_C gboolean
+lm_connection_close (LmConnection *connection,
+ GError **error)
+{
+ gboolean no_errors = TRUE;
+
+ g_return_val_if_fail (connection != NULL, FALSE);
+
+#ifdef HAVE_ASYNCNS
+ _asyncns_cancel (connection->socket);
+#endif
+
+ if (connection->state == LM_CONNECTION_STATE_CLOSED) {
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ "Connection is not open, call lm_connection_open() first");
+ return FALSE;
+ }
+
+ lm_verbose ("Disconnecting from: %s:%d\n",
+ connection->server, connection->port);
+
+ if (lm_connection_is_open (connection)) {
+ if (!connection_send (connection, "</stream:stream>", -1, error)) {
+ no_errors = FALSE;
+ }
+
+ lm_socket_flush (connection->socket);
+ }
+
+ connection_do_close (connection);
+ connection_signal_disconnect (connection, LM_DISCONNECT_REASON_OK);
+
+ return no_errors;
+}
+
+static void
+connection_sasl_auth_finished (LmSASL *sasl,
+ LmConnection *connection,
+ gboolean success,
+ const gchar *reason)
+{
+ if (!success) {
+ lm_verbose ("SASL authentication failed, closing connection\n");
+ connection_call_auth_cb (connection, FALSE);
+ return;
+ }
+
+ connection_send_stream_header (connection);
+ UNUSED_FORMAL_PARAM(sasl);
+ UNUSED_FORMAL_PARAM(reason);
+ lm_verbose("\n exiting SASL auth finished method");
+}
+
+/**
+ * lm_connection_authenticate:
+ * @connection: #LmConnection to authenticate.
+ * @username: Username used to authenticate.
+ * @password: Password corresponding to @username.
+ * @resource: Resource used for this connection.
+ * @function: Callback called when authentication is finished.
+ * @user_data: Userdata passed to @function when called.
+ * @notify: Destroy function to free the memory used by @user_data, can be NULL.
+ * @error: location to store error, or %NULL
+ *
+ * Tries to authenticate a user against the server. The #LmResult in the result callback @function will say whether it succeeded or not.
+ *
+ * Return value: #TRUE if no errors where detected while sending the authentication message, #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_authenticate (LmConnection *connection,
+ const gchar *username,
+ const gchar *password,
+ const gchar *resource,
+ LmResultFunction function,
+ gpointer user_data,
+ GDestroyNotify notify,
+ GError **error)
+{
+ g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (username != NULL, FALSE);
+ g_return_val_if_fail (password != NULL, FALSE);
+ g_return_val_if_fail (resource != NULL, FALSE);
+
+ if (!lm_connection_is_open (connection)) {
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ "Connection is not open, call lm_connection_open() first");
+ return FALSE;
+ }
+ lm_verbose("\n[lm_connection_authenticate] inside...\n");
+ connection->state = LM_CONNECTION_STATE_AUTHENTICATING;
+
+ connection->auth_cb = _lm_utils_new_callback ((gpointer)function,
+ user_data,
+ notify);
+
+ connection->resource = g_strdup (resource);
+ connection->effective_jid = g_strdup_printf ("%s/%s",
+ connection->jid, connection->resource);
+
+ if (connection->use_sasl) {
+ lm_verbose("[lm_connection_authenticate]: conn->use_sasl is true. calling lm_sasl_authenticate\n");
+ lm_sasl_authenticate (connection->sasl,
+ username, password,
+ connection->server,
+ connection_sasl_auth_finished);
+
+ connection->features_cb =
+ lm_message_handler_new (connection_features_cb,
+ NULL, NULL);
+ lm_connection_register_message_handler (connection,
+ connection->features_cb,
+ LM_MESSAGE_TYPE_STREAM_FEATURES,
+ LM_HANDLER_PRIORITY_FIRST);
+
+ lm_verbose("[lm_connection_authenticate]: connection->use_sasl is true. So NOT calling create_auth_req_msg\n");
+ return TRUE;
+ }
+
+ return _lm_connection_old_auth (connection, username, password,
+ resource, error);
+}
+
+gboolean
+_lm_connection_old_auth (LmConnection *connection, const gchar *username,
+ const gchar *password, const gchar *resource, GError **error)
+{
+ LmMessage *m;
+ AuthReqData *data;
+ LmMessageHandler *handler;
+ gboolean result;
+
+
+ m = connection_create_auth_req_msg (username);
+
+ data = g_new0 (AuthReqData, 1);
+ data->username = g_strdup (username);
+ data->password = g_strdup (password);
+ data->resource = g_strdup (resource);
+
+ handler = lm_message_handler_new (connection_auth_req_reply,
+ data,
+ (GDestroyNotify) auth_req_data_free);
+ result = lm_connection_send_with_reply (connection, m, handler, error);
+
+ lm_message_handler_unref (handler);
+ lm_message_unref (m);
+
+ return result;
+}
+
+/**
+ * lm_connection_authenticate_and_block:
+ * @connection: an #LmConnection
+ * @username: Username used to authenticate.
+ * @password: Password corresponding to @username.
+ * @resource: Resource used for this connection.
+ * @error: location to store error, or %NULL
+ *
+ * Tries to authenticate a user against the server. This function blocks until a reply to the authentication attempt is returned and returns whether it was successful or not.
+ *
+ * Return value: #TRUE if no errors where detected and authentication was successful. #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_authenticate_and_block (LmConnection *connection,
+ const gchar *username,
+ const gchar *password,
+ const gchar *resource,
+ GError **error)
+{
+ gboolean result;
+
+ result = lm_connection_authenticate (connection, username, password,
+ resource, NULL, NULL, NULL, error);
+
+ if (!result)
+ return result;
+
+ while (lm_connection_get_state (connection) == LM_CONNECTION_STATE_AUTHENTICATING) {
+ if (g_main_context_pending (connection->context)) {
+ g_main_context_iteration (connection->context, TRUE);
+ } else {
+ /* Sleep for 1 millisecond */
+ g_usleep (1000);
+ }
+ }
+
+ switch (lm_connection_get_state (connection)) {
+ case LM_CONNECTION_STATE_AUTHENTICATED:
+ return TRUE;
+ //removing compilation error : not reachable statement
+ //break;
+ case LM_CONNECTION_STATE_OPEN:
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_AUTH_FAILED,
+ "Authentication failed");
+ return FALSE;
+ //removing compilation error : not reachable statement
+ //break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return FALSE;
+}
+
+/**
+ * lm_connection_get_keep_alive_rate:
+ * @connection: an #LmConnection
+ *
+ * Get the keep alive rate, in seconds. Zero is returned if no keep alive rate has been set.
+ *
+ * Since 1.3.5
+ **/
+guint
+lm_connection_get_keep_alive_rate (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, 0);
+
+ return connection->keep_alive_rate;
+}
+
+/**
+ * lm_connection_set_keep_alive_rate:
+ * @connection: an #LmConnection
+ * @rate: Number of seconds between keep alive packages are sent.
+ *
+ * Set the keep alive rate, in seconds. Set to 0 to prevent keep alive messages to be sent.
+ * A keep alive message is a single space character.
+ **/
+EXPORT_C void
+lm_connection_set_keep_alive_rate (LmConnection *connection, guint rate)
+{
+ g_return_if_fail (connection != NULL);
+ lm_verbose("Setting Keep Alive Rate");
+ connection_stop_keep_alive (connection);
+
+ if (rate == 0) {
+ connection->keep_alive_source = NULL;
+ return;
+ }
+
+ connection->keep_alive_rate = rate;
+
+ if (lm_connection_is_open (connection)) {
+ connection_start_keep_alive (connection);
+ }
+}
+
+/**
+ * lm_connection_is_open:
+ * @connection: #LmConnection to check if it is open.
+ *
+ * Check if the @connection is currently open.
+ *
+ * Return value: #TRUE if connection is open and #FALSE if it is closed.
+ **/
+EXPORT_C gboolean
+lm_connection_is_open (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, FALSE);
+
+ return connection->state >= LM_CONNECTION_STATE_OPEN;
+}
+
+/**
+ * lm_connection_is_authenticated:
+ * @connection: #LmConnection to check if it is authenticated
+ *
+ * Check if @connection is authenticated.
+ *
+ * Return value: #TRUE if connection is authenticated, #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_is_authenticated (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, FALSE);
+
+ return connection->state >= LM_CONNECTION_STATE_AUTHENTICATED;
+}
+
+/**
+ * lm_connection_get_server:
+ * @connection: an #LmConnection
+ *
+ * Fetches the server address that @connection is using.
+ *
+ * Return value: the server address
+ **/
+EXPORT_C const gchar *
+lm_connection_get_server (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ return connection->server;
+}
+
+/**
+ * lm_connection_set_server:
+ * @connection: an #LmConnection
+ * @server: Address of the server
+ *
+ * Sets the server address for @connection to @server. Notice that @connection
+ * can't be open while doing this.
+ **/
+EXPORT_C void
+lm_connection_set_server (LmConnection *connection, const gchar *server)
+{
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (server != NULL);
+
+ if (lm_connection_is_open (connection)) {
+ g_warning ("Can't change server address while connected");
+ return;
+ }
+
+ g_free (connection->server);
+ connection->server = _lm_utils_hostname_to_punycode (server);
+ connection->use_srv = FALSE;
+}
+
+/**
+ * lm_connection_get_jid:
+ * @connection: an #LmConnection
+ *
+ * Fetches the jid set for @connection is using.
+ *
+ * Return value: the jid
+ **/
+EXPORT_C const gchar *
+lm_connection_get_jid (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ return connection->jid;
+}
+
+/**
+ * lm_connection_get_full_jid:
+ * @connection: an #LmConnection
+ *
+ * Returns the full jid that server set for us after
+ * resource binding, complete with the resource.
+ *
+ * Return value: the jid
+ **/
+gchar *
+lm_connection_get_full_jid (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ return connection->effective_jid;
+}
+
+/**
+ * lm_connection_set_jid:
+ * @connection: an #LmConnection
+ * @jid: JID to be used for @connection
+ *
+ * Sets the JID to be used for @connection.
+ **/
+EXPORT_C void
+lm_connection_set_jid (LmConnection *connection, const gchar *jid)
+{
+ g_return_if_fail (connection != NULL);
+
+ if (lm_connection_is_open (connection)) {
+ g_warning ("Can't change JID while connected");
+ return;
+ }
+
+ g_free (connection->jid);
+ connection->jid = g_strdup (jid);
+}
+
+/**
+ * lm_connection_get_port:
+ * @connection: an #LmConnection
+ *
+ * Fetches the port that @connection is using.
+ *
+ * Return value:
+ **/
+EXPORT_C guint
+lm_connection_get_port (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, 0);
+
+ return connection->port;
+}
+
+/**
+ * lm_connection_set_port:
+ * @connection: an #LmConnection
+ * @port: server port
+ *
+ * Sets the server port that @connection will be using.
+ **/
+EXPORT_C void
+lm_connection_set_port (LmConnection *connection, guint port)
+{
+ g_return_if_fail (connection != NULL);
+
+ if (lm_connection_is_open (connection)) {
+ g_warning ("Can't change server port while connected");
+ return;
+ }
+
+ connection->port = port;
+}
+
+/**
+ * lm_connection_get_ssl:
+ * @connection: an #LmConnection
+ *
+ * Returns the SSL struct if the connection is using one.
+ *
+ * Return value: The ssl struct or %NULL if no proxy is used.
+ **/
+EXPORT_C LmSSL *
+lm_connection_get_ssl (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ return connection->ssl;
+}
+
+/**
+ * lm_connection_set_ssl:
+ * @connection: An #LmConnection
+ * @ssl: An #LmSSL
+ *
+ * Sets SSL struct or unset if @ssl is %NULL. If set @connection will use SSL to for the connection.
+ */
+EXPORT_C void
+lm_connection_set_ssl (LmConnection *connection, LmSSL *ssl)
+{
+ lm_verbose("[lm_connection_set_ssl]: inside...");
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (lm_ssl_is_supported () == TRUE);
+
+ if (connection->ssl) {
+ lm_ssl_unref (connection->ssl);
+ }
+
+ if (ssl) {
+ lm_verbose("[lm_connection_set_ssl]: setting of ssl success");
+ connection->ssl = lm_ssl_ref (ssl);
+ } else {
+ lm_verbose("[lm_connection_set_ssl]: setting of ssl failed");
+ connection->ssl = NULL;
+ }
+}
+
+/**
+ * lm_connection_get_proxy:
+ * @connection: an #LmConnection
+ *
+ * Returns the proxy if the connection is using one.
+ *
+ * Return value: The proxy or %NULL if no proxy is used.
+ **/
+EXPORT_C LmProxy *
+lm_connection_get_proxy (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ return connection->proxy;
+}
+
+/**
+ * lm_connection_set_proxy:
+ * @connection: an #LmConnection
+ * @proxy: an #LmProxy
+ *
+ * Sets the proxy to use for this connection. To unset pass #NULL.
+ *
+ **/
+EXPORT_C void
+lm_connection_set_proxy (LmConnection *connection, LmProxy *proxy)
+{
+ g_return_if_fail (connection != NULL);
+
+ if (lm_connection_is_open (connection)) {
+ g_warning ("Can't change server proxy while connected");
+ return;
+ }
+
+ if (connection->proxy) {
+ lm_proxy_unref (connection->proxy);
+ connection->proxy = NULL;
+ }
+
+ if (proxy && lm_proxy_get_type (proxy) != LM_PROXY_TYPE_NONE) {
+ connection->proxy = lm_proxy_ref (proxy);
+ }
+}
+
+/**
+ * lm_connection_send:
+ * @connection: #LmConnection to send message over.
+ * @message: #LmMessage to send.
+ * @error: location to store error, or %NULL
+ *
+ * Asynchronous call to send a message.
+ *
+ * Return value: Returns #TRUE if no errors where detected while sending, #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_send (LmConnection *connection,
+ LmMessage *message,
+ GError **error)
+{
+ gchar *xml_str;
+ gchar *ch;
+ gboolean result;
+
+ g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
+
+ xml_str = lm_message_node_to_string (message->node);
+ ch = strstr (xml_str, "</stream:stream>");
+ if (ch) {
+ *ch = '\0';
+ }
+
+ result = connection_send (connection, xml_str, -1, error);
+ g_free (xml_str);
+
+ return result;
+}
+
+/**
+ * lm_connection_send_with_reply:
+ * @connection: #LmConnection used to send message.
+ * @message: #LmMessage to send.
+ * @handler: #LmMessageHandler that will be used when a reply to @message arrives
+ * @error: location to store error, or %NULL
+ *
+ * Send a #LmMessage which will result in a reply.
+ *
+ * Return value: Returns #TRUE if no errors where detected while sending, #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_send_with_reply (LmConnection *connection,
+ LmMessage *message,
+ LmMessageHandler *handler,
+ GError **error)
+{
+ gchar *id;
+
+ g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
+ g_return_val_if_fail (handler != NULL, FALSE);
+
+ if (lm_message_node_get_attribute (message->node, "id")) {
+ id = g_strdup (lm_message_node_get_attribute (message->node,
+ "id"));
+ } else {
+ id = _lm_utils_generate_id ();
+ lm_message_node_set_attributes (message->node, "id", id, NULL);
+ }
+
+ g_hash_table_insert (connection->id_handlers,
+ id, lm_message_handler_ref (handler));
+ lm_verbose("[lm_connection_send_with_reply]: inside..calling lm_connection_send\n");
+ return lm_connection_send (connection, message, error);
+}
+
+/**
+ * lm_connection_send_with_reply_and_block:
+ * @connection: an #LmConnection
+ * @message: an #LmMessage
+ * @error: Set if error was detected during sending.
+ *
+ * Send @message and wait for return.
+ *
+ * Return value: The reply
+ **/
+EXPORT_C LmMessage *
+lm_connection_send_with_reply_and_block (LmConnection *connection,
+ LmMessage *message,
+ GError **error)
+{
+ gchar *id;
+ LmMessage *reply = NULL;
+
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (message != NULL, NULL);
+
+ if (connection->state < LM_CONNECTION_STATE_OPENING) {
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ "Connection is not open, call lm_connection_open() first");
+ return FALSE;
+ }
+
+
+ if (lm_message_node_get_attribute (message->node, "id")) {
+ id = g_strdup (lm_message_node_get_attribute (message->node,
+ "id"));
+ } else {
+ id = _lm_utils_generate_id ();
+ lm_message_node_set_attributes (message->node, "id", id, NULL);
+ }
+
+ lm_message_queue_detach (connection->queue);
+
+ lm_connection_send (connection, message, error);
+
+ while (!reply) {
+ const gchar *m_id;
+ guint n;
+
+ g_main_context_iteration (connection->context, TRUE);
+
+ if (lm_message_queue_is_empty (connection->queue)) {
+ continue;
+ }
+
+ for (n = 0; n < lm_message_queue_get_length (connection->queue); n++) {
+ LmMessage *m;
+
+ m = (LmMessage *) lm_message_queue_peek_nth (connection->queue, n);
+
+ m_id = lm_message_node_get_attribute (m->node, "id");
+
+ if (m_id && strcmp (m_id, id) == 0) {
+ reply = m;
+ lm_message_queue_pop_nth (connection->queue, n);
+ break;
+ }
+ }
+ }
+
+ g_free (id);
+ lm_message_queue_attach (connection->queue, connection->context);
+
+ return reply;
+}
+
+/**
+ * lm_connection_register_message_handler:
+ * @connection: Connection to register a handler for.
+ * @handler: Message handler to register.
+ * @type: Message type that @handler will handle.
+ * @priority: The priority in which to call @handler.
+ *
+ * Registers a #LmMessageHandler to handle incoming messages of a certain type.
+ * To unregister the handler call lm_connection_unregister_message_handler().
+ **/
+EXPORT_C void
+lm_connection_register_message_handler (LmConnection *connection,
+ LmMessageHandler *handler,
+ LmMessageType type,
+ LmHandlerPriority priority)
+{
+ HandlerData *hd;
+
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (handler != NULL);
+ g_return_if_fail (type != LM_MESSAGE_TYPE_UNKNOWN);
+
+ hd = g_new0 (HandlerData, 1);
+ hd->priority = priority;
+ hd->handler = lm_message_handler_ref (handler);
+
+ connection->handlers[type] = g_slist_insert_sorted (connection->handlers[type],
+ hd,
+ (GCompareFunc) connection_handler_compare_func);
+}
+
+/**
+ * lm_connection_unregister_message_handler:
+ * @connection: Connection to unregister a handler for.
+ * @handler: The handler to unregister.
+ * @type: What type of messages to unregister this handler for.
+ *
+ * Unregisters a handler for @connection. @handler will no longer be called
+ * when incoming messages of @type arrive.
+ **/
+EXPORT_C void
+lm_connection_unregister_message_handler (LmConnection *connection,
+ LmMessageHandler *handler,
+ LmMessageType type)
+{
+ GSList *l;
+
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (handler != NULL);
+ g_return_if_fail (type != LM_MESSAGE_TYPE_UNKNOWN);
+
+ for (l = connection->handlers[type]; l; l = l->next) {
+ HandlerData *hd = (HandlerData *) l->data;
+
+ if (handler == hd->handler) {
+ connection->handlers[type] = g_slist_remove_link (connection->handlers[type], l);
+ g_slist_free (l);
+ lm_message_handler_unref (hd->handler);
+ g_free (hd);
+ break;
+ }
+ }
+}
+
+/**
+ * lm_connection_set_disconnect_function:
+ * @connection: Connection to register disconnect callback for.
+ * @function: Function to be called when @connection is closed.
+ * @user_data: User data passed to @function.
+ * @notify: Function that will be called with @user_data when @user_data needs to be freed. Pass #NULL if it shouldn't be freed.
+ *
+ * Set the callback that will be called when a connection is closed.
+ **/
+EXPORT_C void
+lm_connection_set_disconnect_function (LmConnection *connection,
+ LmDisconnectFunction function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ g_return_if_fail (connection != NULL);
+
+ if (connection->disconnect_cb) {
+ _lm_utils_free_callback (connection->disconnect_cb);
+ }
+
+ if (function) {
+ connection->disconnect_cb = _lm_utils_new_callback ((gpointer)function,
+ user_data,
+ notify);
+ } else {
+ connection->disconnect_cb = NULL;
+ }
+}
+
+/**
+ * lm_connection_send_raw:
+ * @connection: Connection used to send
+ * @str: The string to send, the entire string will be sent.
+ * @error: Set if error was detected during sending.
+ *
+ * Asynchronous call to send a raw string. Useful for debugging and testing.
+ *
+ * Return value: Returns #TRUE if no errors was detected during sending,
+ * #FALSE otherwise.
+ **/
+EXPORT_C gboolean
+lm_connection_send_raw (LmConnection *connection,
+ const gchar *str,
+ GError **error)
+{
+ g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (str != NULL, FALSE);
+
+ return connection_send (connection, str, -1, error);
+}
+/**
+ * lm_connection_get_state:
+ * @connection: Connection to get state on
+ *
+ * Returns the state of the connection.
+ *
+ * Return value: The state of the connection.
+ **/
+EXPORT_C LmConnectionState
+lm_connection_get_state (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL,
+ LM_CONNECTION_STATE_CLOSED);
+
+ return connection->state;
+}
+
+/**
+ * lm_connection_get_client_host:
+ * @connection: An #LmConnection
+ *
+ * Returns the local host name of the connection.
+ *
+ * Return value: A newly allocated string representing the local host name.
+ **/
+gchar *
+lm_connection_get_local_host (LmConnection *connection)
+{
+ return lm_socket_get_local_host (connection->socket);
+}
+
+/**
+ * lm_connection_ref:
+ * @connection: Connection to add a reference to.
+ *
+ * Add a reference on @connection. To remove a reference call
+ * lm_connection_unref().
+ *
+ * Return value: Returns the same connection.
+ **/
+EXPORT_C LmConnection*
+lm_connection_ref (LmConnection *connection)
+{
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ connection->ref_count++;
+
+ return connection;
+}
+
+/**
+ * lm_connection_unref:
+ * @connection: Connection to remove reference from.
+ *
+ * Removes a reference on @connection. If there are no references to
+ * @connection it will be freed and shouldn't be used again.
+ **/
+EXPORT_C void
+lm_connection_unref (LmConnection *connection)
+{
+ //g_return_if_fail (connection != NULL);
+ if(!connection)
+ return;
+ connection->ref_count--;
+
+ if (connection->ref_count == 0) {
+ connection_free (connection);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-debug.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,125 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "lm-debug.h"
+
+
+//#ifdef EMULATOR
+#ifndef LM_NO_DEBUG
+
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+
+GET_GLOBAL_VAR_FROM_TLS(debug_flags,lm_debug,LmLogLevelFlags)
+ #define debug_flags (*GET_WSD_VAR_NAME(debug_flags,lm_debug,g)())
+
+GET_GLOBAL_VAR_FROM_TLS(initialized,lm_debug,gboolean)
+ #define initialized (*GET_WSD_VAR_NAME(initialized,lm_debug,g)())
+
+GET_GLOBAL_VAR_FROM_TLS(log_handler_id,lm_debug,guint)
+ #define log_handler_id (*GET_WSD_VAR_NAME(log_handler_id,lm_debug,g)())
+
+#else //EMULATOR
+
+
+static LmLogLevelFlags debug_flags = 0;
+static gboolean initialized = FALSE;
+static guint log_handler_id = 0;
+#endif//EMULATOR
+
+
+static const GDebugKey debug_keys[] = {
+ {"VERBOSE", LM_LOG_LEVEL_VERBOSE},
+ {"NET", LM_LOG_LEVEL_NET},
+ {"PARSER", LM_LOG_LEVEL_PARSER},
+ {"SSL", LM_LOG_LEVEL_SSL},
+ {"SASL", LM_LOG_LEVEL_SASL},
+ {"ALL", LM_LOG_LEVEL_ALL}
+};
+
+#define NUM_DEBUG_KEYS (sizeof (debug_keys) / sizeof (GDebugKey))
+
+static void
+debug_log_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+
+
+ /*if (debug_flags & log_level) {
+ if (log_level & LM_LOG_LEVEL_VERBOSE) {
+ g_print ("*** ");
+ }
+ else if (log_level & LM_LOG_LEVEL_PARSER) {
+ g_print ("LM-PARSER: ");
+ }
+ else if (log_level & LM_LOG_LEVEL_SASL) {
+ g_print ("LM-SASL: ");
+ }
+ else if (log_level & LM_LOG_LEVEL_SSL) {
+ g_print ("LM-SSL: ");
+ }
+
+ g_print ("%s", message);*/
+ UNUSED_FORMAL_PARAM(log_domain);
+ UNUSED_FORMAL_PARAM(log_level);
+ UNUSED_FORMAL_PARAM(user_data);
+ lm_verbose (message);
+ //}
+}
+
+/**
+ * lm_debug_init
+ *
+ * Initialized the debug system.
+ **/
+void
+lm_debug_init (void)
+{
+ /*const gchar *env_lm_debug;
+
+ if (initialized) {
+ return;
+ }
+
+ env_lm_debug = g_getenv ("LM_DEBUG");
+ if (env_lm_debug) {
+ debug_flags = g_parse_debug_string (env_lm_debug, debug_keys,
+ NUM_DEBUG_KEYS);
+ }
+
+ log_handler_id = g_log_set_handler (LM_LOG_DOMAIN, LM_LOG_LEVEL_ALL,
+ debug_log_handler, NULL);
+
+ initialized = TRUE;*/
+
+}
+
+#else /* LM_NO_DEBUG */
+
+void
+lm_debug_init (void)
+{
+}
+
+#endif /* LM_NO_DEBUG */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-error.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gerror.h>
+#include "lm-error.h"
+
+EXPORT_C GQuark
+lm_error_quark (void)
+{
+ static GQuark q = 0;
+
+ if (q == 0) {
+ q = g_quark_from_static_string ("lm-error-quark");
+ }
+
+ return q;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-message-handler.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,160 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "lm-internals.h"
+#include "lm-message-handler.h"
+#include "lm-debug.h"
+struct LmMessageHandler {
+ gboolean valid;
+ gint ref_count;
+ LmHandleMessageFunction function;
+ gpointer user_data;
+ GDestroyNotify notify;
+};
+
+LmHandlerResult
+_lm_message_handler_handle_message (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message)
+{
+ g_return_val_if_fail (handler != NULL,
+ LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS);
+ lm_verbose("\nCalling handler in handler_handle_message\n");
+ if (!handler->valid) {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (handler->function) {
+ lm_verbose("In handler msg Node name: %s", message->node->name);
+ return (* handler->function) (handler, connection,
+ message, handler->user_data);
+ }
+ lm_verbose("could not call handler: go for more handlers\n");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+/**
+ * lm_message_handler_new:
+ * @function: a callback
+ * @user_data: user data passed to function
+ * @notify: function called when the message handler is freed
+ *
+ * Creates a new message handler. This can be set to handle incoming messages
+ * and when a message of the type the handler is registered to handle is
+ * received @function will be called and @user_data will be passed to it.
+ * @notify is called when the message handler is freed, that way any memory
+ * allocated by @user_data can be freed.
+ *
+ * Return value: a newly created message handler
+ **/
+EXPORT_C LmMessageHandler *
+lm_message_handler_new (LmHandleMessageFunction function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ LmMessageHandler *handler;
+
+ g_return_val_if_fail (function != NULL, NULL);
+
+ handler = g_new0 (LmMessageHandler, 1);
+
+ if (handler == NULL) {
+ return NULL;
+ }
+
+ handler->valid = TRUE;
+ handler->ref_count = 1;
+ handler->function = function;
+ handler->user_data = user_data;
+ handler->notify = notify;
+
+ return handler;
+}
+
+/**
+ * lm_message_handler_invalidate
+ * @handler: an #LmMessageHandler
+ *
+ * Invalidates the handler. Useful if you need to cancel a reply
+ **/
+EXPORT_C void
+lm_message_handler_invalidate (LmMessageHandler *handler)
+{
+ handler->valid = FALSE;
+}
+
+/**
+ * lm_message_handler_is_valid
+ * @handler: an #LmMessageHandler
+ *
+ * Fetches whether the handler is valid or not.
+ *
+ * Return value: #TRUE if @handler is valid, otherwise #FALSE
+ **/
+EXPORT_C gboolean
+lm_message_handler_is_valid (LmMessageHandler *handler)
+{
+ g_return_val_if_fail (handler != NULL, FALSE);
+
+ return handler->valid;
+}
+
+/**
+ * lm_message_handler_ref:
+ * @handler: an #LmMessageHandler
+ *
+ * Adds a reference to @handler.
+ *
+ * Return value: the message handler
+ **/
+EXPORT_C LmMessageHandler *
+lm_message_handler_ref (LmMessageHandler *handler)
+{
+ g_return_val_if_fail (handler != NULL, NULL);
+
+ handler->ref_count++;
+
+ return handler;
+}
+
+/**
+ * lm_message_handler_unref:
+ * @handler: an #LmMessagHandler
+ *
+ * Removes a reference from @handler. When no more references are present the
+ * handler is freed.
+ **/
+EXPORT_C void
+lm_message_handler_unref (LmMessageHandler *handler)
+{
+ g_return_if_fail (handler != NULL);
+
+ handler->ref_count --;
+
+ if (handler->ref_count == 0) {
+ if (handler->notify) {
+ (* handler->notify) (handler->user_data);
+ }
+ g_free (handler);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-message-node.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,506 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include "lm-internals.h"
+#include "lm-message-node.h"
+
+typedef struct {
+ gchar *key;
+ gchar *value;
+} KeyValuePair;
+
+static void message_node_free (LmMessageNode *node);
+static LmMessageNode * message_node_last_child (LmMessageNode *node);
+
+static void
+message_node_free (LmMessageNode *node)
+{
+ LmMessageNode *l;
+ GSList *list;
+
+ g_return_if_fail (node != NULL);
+
+ for (l = node->children; l;) {
+ LmMessageNode *next = l->next;
+
+ lm_message_node_unref (l);
+ l = next;
+ }
+
+ g_free (node->name);
+ g_free (node->value);
+
+ for (list = node->attributes; list; list = list->next) {
+ KeyValuePair *kvp = (KeyValuePair *) list->data;
+
+ g_free (kvp->key);
+ g_free (kvp->value);
+ g_free (kvp);
+ }
+
+ g_slist_free (node->attributes);
+ g_free (node);
+}
+
+static LmMessageNode *
+message_node_last_child (LmMessageNode *node)
+{
+ LmMessageNode *l;
+
+ g_return_val_if_fail (node != NULL, NULL);
+
+ if (!node->children) {
+ return NULL;
+ }
+
+ l = node->children;
+
+ while (l->next) {
+ l = l->next;
+ }
+
+ return l;
+}
+
+LmMessageNode *
+_lm_message_node_new (const gchar *name)
+{
+ LmMessageNode *node;
+
+ node = g_new0 (LmMessageNode, 1);
+
+ node->name = g_strdup (name);
+ node->value = NULL;
+ node->raw_mode = FALSE;
+ node->attributes = NULL;
+ node->next = NULL;
+ node->prev = NULL;
+ node->parent = NULL;
+ node->children = NULL;
+
+ node->ref_count = 1;
+
+ return node;
+}
+void
+_lm_message_node_add_child_node (LmMessageNode *node, LmMessageNode *child)
+{
+ LmMessageNode *prev;
+
+ g_return_if_fail (node != NULL);
+
+ prev = message_node_last_child (node);
+ lm_message_node_ref (child);
+
+ if (prev) {
+ prev->next = child;
+ child->prev = prev;
+ } else {
+ node->children = child;
+ }
+
+ child->parent = node;
+}
+
+/**
+ * lm_message_node_get_value:
+ * @node: an #LmMessageNode
+ *
+ * Retrieves the value of @node.
+ *
+ * Return value:
+ **/
+EXPORT_C const gchar *
+lm_message_node_get_value (LmMessageNode *node)
+{
+ g_return_val_if_fail (node != NULL, NULL);
+
+ return node->value;
+}
+
+/**
+ * lm_message_node_set_value:
+ * @node: an #LmMessageNode
+ * @value: the new value.
+ *
+ * Sets the value of @node. If a previous value is set it will be freed.
+ **/
+EXPORT_C void
+lm_message_node_set_value (LmMessageNode *node, const gchar *value)
+{
+ g_return_if_fail (node != NULL);
+
+ g_free (node->value);
+
+ if (!value) {
+ node->value = NULL;
+ return;
+ }
+
+ node->value = g_strdup (value);
+}
+
+/**
+ * lm_message_node_add_child:
+ * @node: an #LmMessageNode
+ * @name: the name of the new child
+ * @value: value of the new child
+ *
+ * Add a child node with @name and value set to @value.
+ *
+ * Return value: the newly created child
+ **/
+EXPORT_C LmMessageNode *
+lm_message_node_add_child (LmMessageNode *node,
+ const gchar *name,
+ const gchar *value)
+{
+ LmMessageNode *child;
+
+ g_return_val_if_fail (node != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ child = _lm_message_node_new (name);
+
+ lm_message_node_set_value (child, value);
+ _lm_message_node_add_child_node (node, child);
+ lm_message_node_unref (child);
+
+ return child;
+}
+
+/**
+ * lm_message_node_set_attributes:
+ * @node: an #LmMessageNode
+ * @name: the first attribute, should be followed by a string with the value
+ * @Varargs: The rest of the name/value pairs
+ *
+ * Sets a list of attributes. The arguments should be names and corresponding
+ * value and needs to be ended with %NULL.
+ **/
+EXPORT_C void
+lm_message_node_set_attributes (LmMessageNode *node,
+ const gchar *name,
+ ...)
+{
+ va_list args;
+
+ g_return_if_fail (node != NULL);
+
+ for (va_start (args, name);
+ name;
+ name = (const gchar *) va_arg (args, gpointer)) {
+ const gchar *value;
+
+ value = (const gchar *) va_arg (args, gpointer);
+
+ lm_message_node_set_attribute (node, name, value);
+
+ }
+
+ va_end (args);
+}
+
+/**
+ * lm_message_node_set_attribute:
+ * @node: an #LmMessageNode
+ * @name: name of attribute
+ * @value: value of attribute.
+ *
+ * Sets the attribute @name to @value.
+ **/
+EXPORT_C void
+lm_message_node_set_attribute (LmMessageNode *node,
+ const gchar *name,
+ const gchar *value)
+{
+ gboolean found = FALSE;
+ GSList *l;
+
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (value != NULL);
+
+ for (l = node->attributes; l; l = l->next) {
+ KeyValuePair *kvp = (KeyValuePair *) l->data;
+
+ if (strcmp (kvp->key, name) == 0) {
+ g_free (kvp->value);
+ kvp->value = g_strdup (value);
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ KeyValuePair *kvp;
+
+ kvp = g_new0 (KeyValuePair, 1);
+ kvp->key = g_strdup (name);
+ kvp->value = g_strdup (value);
+
+ node->attributes = g_slist_prepend (node->attributes, kvp);
+ }
+}
+
+/**
+ * lm_message_node_get_attribute:
+ * @node: an #LmMessageNode
+ * @name: the attribute name
+ *
+ * Fetches the attribute @name from @node.
+ *
+ * Return value: the attribute value or %NULL if not set
+ **/
+EXPORT_C const gchar *
+lm_message_node_get_attribute (LmMessageNode *node, const gchar *name)
+{
+ GSList *l;
+ const gchar *ret_val = NULL;
+
+ //g_return_val_if_fail (node != NULL, NULL);
+ //g_return_val_if_fail (name != NULL, NULL);
+
+ if(!node || !name)
+ return NULL;
+
+ for (l = node->attributes; l; l = l->next) {
+ KeyValuePair *kvp = (KeyValuePair *) l->data;
+
+ if (strcmp (kvp->key, name) == 0) {
+ ret_val = kvp->value;
+ }
+ }
+
+ return ret_val;
+}
+
+/**
+ * lm_message_node_get_child:
+ * @node: an #LmMessageNode
+ * @child_name: the childs name
+ *
+ * Fetches the child @child_name from @node. If child is not found as an
+ * immediate child of @node %NULL is returned.
+ *
+ * Return value: the child node or %NULL if not found
+ **/
+EXPORT_C LmMessageNode *
+lm_message_node_get_child (LmMessageNode *node, const gchar *child_name)
+{
+ LmMessageNode *l;
+
+ // g_return_val_if_fail (node != NULL, NULL);
+ // g_return_val_if_fail (child_name != NULL, NULL);
+
+ if(!node || !child_name)
+ return NULL;
+ for (l = node->children; l; l = l->next) {
+ if (strcmp (l->name, child_name) == 0) {
+ return l;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * lm_message_node_find_child:
+ * @node: A #LmMessageNode
+ * @child_name: The name of the child to find
+ *
+ * Locates a child among all children of @node. The entire tree will be search
+ * until a child with name @child_name is located.
+ *
+ * Return value: the located child or %NULL if not found
+ **/
+EXPORT_C LmMessageNode *
+lm_message_node_find_child (LmMessageNode *node,
+ const gchar *child_name)
+{
+ LmMessageNode *l;
+ LmMessageNode *ret_val = NULL;
+
+ //g_return_val_if_fail (node != NULL, NULL);
+ //g_return_val_if_fail (child_name != NULL, NULL);
+ if(!node || !child_name)
+ return NULL;
+ for (l = node->children; l; l = l->next) {
+ if (strcmp (l->name, child_name) == 0) {
+ return l;
+ }
+ if (l->children) {
+ ret_val = lm_message_node_find_child (l, child_name);
+ if (ret_val) {
+ return ret_val;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * lm_message_node_get_raw_mode:
+ * @node: an #LmMessageNode
+ *
+ * Checks if the nodes value should be sent as raw mode.
+ *
+ * Return value: %TRUE if nodes value should be sent as is and %FALSE if the value will be escaped before sending.
+ **/
+EXPORT_C gboolean
+lm_message_node_get_raw_mode (LmMessageNode *node)
+{
+ //g_return_val_if_fail (node != NULL, FALSE);
+
+ return node? node->raw_mode : 0 ;
+ //return node->raw_mode;
+}
+
+/**
+ * lm_message_node_set_raw_mode:
+ * @node: an #LmMessageNode
+ * @raw_mode: boolean specifying if node value should be escaped or not.
+ *
+ * Set @raw_mode to %TRUE if you don't want to escape the value. You need to make sure the value is valid XML yourself.
+ **/
+EXPORT_C void
+lm_message_node_set_raw_mode (LmMessageNode *node, gboolean raw_mode)
+{
+ //g_return_if_fail (node != NULL);
+ if(!node)
+ return;
+
+ node->raw_mode = raw_mode;
+}
+
+/**
+ * lm_message_node_ref:
+ * @node: an #LmMessageNode
+ *
+ * Adds a reference to @node.
+ *
+ * Return value: the node
+ **/
+EXPORT_C LmMessageNode *
+lm_message_node_ref (LmMessageNode *node)
+{
+ //g_return_val_if_fail (node != NULL, NULL);
+ if(!node)
+ return NULL;
+ node->ref_count++;
+
+ return node;
+}
+
+/**
+ * lm_message_node_unref:
+ * @node: an #LmMessageNode
+ *
+ * Removes a reference from @node. When no more references are present the
+ * node is freed. When freed lm_message_node_unref() will be called on all
+ * children. If caller needs to keep references to the children a call to
+ * lm_message_node_ref() needs to be done before the call to
+ *lm_message_unref().
+ **/
+EXPORT_C void
+lm_message_node_unref (LmMessageNode *node)
+{
+ //g_return_if_fail (node != NULL);
+ if(!node)
+ return;
+ node->ref_count--;
+
+ if (node->ref_count == 0) {
+ message_node_free (node);
+ }
+}
+
+/**
+ * lm_message_node_to_string:
+ * @node: an #LmMessageNode
+ *
+ * Returns an XML string representing the node. This is what is sent over the
+ * wire. This is used internally Loudmouth and is external for debugging
+ * purposes.
+ *
+ * Return value: an XML string representation of @node
+ **/
+EXPORT_C gchar *
+lm_message_node_to_string (LmMessageNode *node)
+{
+ GString *ret;
+ GSList *l;
+ LmMessageNode *child;
+
+ g_return_val_if_fail (node != NULL, NULL);
+
+ if (node->name == NULL) {
+ return g_strdup ("");
+ }
+
+ ret = g_string_new ("<");
+ g_string_append (ret, node->name);
+
+ for (l = node->attributes; l; l = l->next) {
+ KeyValuePair *kvp = (KeyValuePair *) l->data;
+
+ if (node->raw_mode == FALSE) {
+ gchar *escaped;
+
+ escaped = g_markup_escape_text (kvp->value, -1);
+ g_string_append_printf (ret, " %s=\"%s\"",
+ kvp->key, escaped);
+ g_free (escaped);
+ } else {
+ g_string_append_printf (ret, " %s=\"%s\"",
+ kvp->key, kvp->value);
+ }
+
+ }
+
+ g_string_append_c (ret, '>');
+
+ if (node->value) {
+ gchar *tmp;
+
+ if (node->raw_mode == FALSE) {
+ tmp = g_markup_escape_text (node->value, -1);
+ g_string_append (ret, tmp);
+ g_free (tmp);
+ } else {
+ g_string_append (ret, node->value);
+ }
+ }
+
+ for (child = node->children; child; child = child->next) {
+ gchar *child_str = lm_message_node_to_string (child);
+ g_string_append_c (ret, ' ');
+ g_string_append (ret, child_str);
+ g_free (child_str);
+ }
+
+ g_string_append_printf (ret, "</%s>\n", node->name);
+
+ return g_string_free (ret, FALSE);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-message-queue.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,234 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "lm-message-queue.h"
+#include "lm-debug.h"
+
+struct _LmMessageQueue {
+ GQueue *messages;
+
+ GMainContext *context;
+ GSource *source;
+
+ LmMessageQueueCallback callback;
+ gpointer user_data;
+
+ gint ref_count;
+};
+
+typedef struct {
+ GSource source;
+ LmMessageQueue *queue;
+} MessageQueueSource;
+
+static void message_queue_free (LmMessageQueue *queue);
+static gboolean message_queue_prepare_func (GSource *source,
+ gint *timeout);
+static gboolean message_queue_check_func (GSource *source);
+static gboolean message_queue_dispatch_func (GSource *source,
+ GSourceFunc callback,
+ gpointer user_data);
+
+static GSourceFuncs source_funcs = {
+ message_queue_prepare_func,
+ message_queue_check_func,
+ message_queue_dispatch_func,
+ NULL
+};
+
+static void
+foreach_free_message (LmMessage *m, gpointer user_data)
+{
+ lm_message_unref (m);
+ UNUSED_FORMAL_PARAM(user_data);
+}
+
+static void
+message_queue_free (LmMessageQueue *queue)
+{
+ lm_message_queue_detach (queue);
+
+ g_queue_foreach (queue->messages, (GFunc) foreach_free_message, NULL);
+ g_queue_free (queue->messages);
+
+ g_free (queue);
+}
+
+//Prepare has to return true for check method to be called.
+static gboolean
+message_queue_prepare_func (GSource *source, gint *timeout)
+{
+ LmMessageQueue *queue;
+
+ queue = ((MessageQueueSource *)source)->queue;
+ UNUSED_FORMAL_PARAM(timeout);
+ return !g_queue_is_empty (queue->messages);
+}
+
+//check has to return true for Dispatch method to be called.
+static gboolean
+message_queue_check_func (GSource *source)
+{
+// return FALSE;
+UNUSED_FORMAL_PARAM(source);
+return TRUE;
+}
+
+static gboolean
+message_queue_dispatch_func (GSource *source,
+ GSourceFunc callback,
+ gpointer user_data)
+{
+ LmMessageQueue *queue;
+
+ queue = ((MessageQueueSource *)source)->queue;
+
+ if (queue->callback) {
+ (queue->callback) (queue, queue->user_data);
+ }
+ UNUSED_FORMAL_PARAM(source);
+ UNUSED_FORMAL_PARAM(callback);
+ return TRUE;
+}
+
+LmMessageQueue *
+lm_message_queue_new (LmMessageQueueCallback callback,
+ gpointer user_data)
+{
+ LmMessageQueue *queue;
+
+ queue = g_new0 (LmMessageQueue, 1);
+
+ queue->messages = g_queue_new ();
+ queue->context = NULL;
+ queue->source = NULL;
+ queue->ref_count = 1;
+
+ queue->callback = callback;
+ queue->user_data = user_data;
+
+ return queue;
+}
+
+void
+lm_message_queue_attach (LmMessageQueue *queue, GMainContext *context)
+{
+ GSource *source;
+
+ if (queue->source) {
+ if (queue->context == context) {
+ /* Already attached */
+ return;
+ }
+ lm_message_queue_detach (queue);
+ }
+
+ if (context) {
+ queue->context = g_main_context_ref (context);
+ }
+
+ source = g_source_new (&source_funcs, sizeof (MessageQueueSource));
+ ((MessageQueueSource *)source)->queue = queue;
+ queue->source = source;
+
+ g_source_attach (source, queue->context);
+}
+
+void
+lm_message_queue_detach (LmMessageQueue *queue)
+{
+ if (queue->source) {
+ g_source_destroy (queue->source);
+ g_source_unref (queue->source);
+ }
+
+ if (queue->context) {
+ g_main_context_unref (queue->context);
+ }
+
+ queue->source = NULL;
+ queue->context = NULL;
+}
+
+void
+lm_message_queue_push_tail (LmMessageQueue *queue, LmMessage *m)
+{
+ g_return_if_fail (queue != NULL);
+ g_return_if_fail (m != NULL);
+
+ g_queue_push_tail (queue->messages, m);
+}
+
+LmMessage *
+lm_message_queue_peek_nth (LmMessageQueue *queue, guint n)
+{
+ g_return_val_if_fail (queue != NULL, NULL);
+
+ return (LmMessage *) g_queue_peek_nth (queue->messages, n);
+}
+
+LmMessage *
+lm_message_queue_pop_nth (LmMessageQueue *queue, guint n)
+{
+ g_return_val_if_fail (queue != NULL, NULL);
+
+ return (LmMessage *) g_queue_pop_nth (queue->messages, n);
+}
+
+guint
+lm_message_queue_get_length (LmMessageQueue *queue)
+{
+ g_return_val_if_fail (queue != NULL, 0);
+
+ return g_queue_get_length (queue->messages);
+}
+
+gboolean
+lm_message_queue_is_empty (LmMessageQueue *queue)
+{
+ g_return_val_if_fail (queue != NULL, TRUE);
+
+ return g_queue_is_empty (queue->messages);
+}
+
+LmMessageQueue *
+lm_message_queue_ref (LmMessageQueue *queue)
+{
+ g_return_val_if_fail (queue != NULL, NULL);
+
+ queue->ref_count++;
+
+ return queue;
+}
+
+void
+lm_message_queue_unref (LmMessageQueue *queue)
+{
+ g_return_if_fail (queue != NULL);
+
+ queue->ref_count--;
+
+ if (queue->ref_count <= 0) {
+ message_queue_free (queue);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-message.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,373 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include "lm-internals.h"
+#include "lm-message.h"
+
+#define PRIV(o) ((LmMessage *)o)->priv
+
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+
+GET_STATIC_ARRAY_FROM_TLS(type_names, lm_message, TypeNames)
+ #define type_names (GET_WSD_VAR_NAME(type_names, lm_message, s)())
+
+GET_STATIC_ARRAY_FROM_TLS(sub_type_names,lm_message,SubTypeNames)
+ #define sub_type_names (GET_WSD_VAR_NAME(sub_type_names,lm_message,s)())
+
+
+#else
+static struct TypeNames
+{
+ LmMessageType type;
+ const gchar *name;
+} type_names[] = {
+ { LM_MESSAGE_TYPE_MESSAGE, "message" },
+ { LM_MESSAGE_TYPE_PRESENCE, "presence" },
+ { LM_MESSAGE_TYPE_IQ, "iq" },
+ { LM_MESSAGE_TYPE_STREAM, "stream:stream" },
+ { LM_MESSAGE_TYPE_STREAM_FEATURES, "stream:features" },
+ { LM_MESSAGE_TYPE_STREAM_ERROR, "stream:error" },
+ { LM_MESSAGE_TYPE_AUTH, "auth" },
+ { LM_MESSAGE_TYPE_CHALLENGE, "challenge" },
+ { LM_MESSAGE_TYPE_RESPONSE, "response" },
+ { LM_MESSAGE_TYPE_SUCCESS, "success" },
+ { LM_MESSAGE_TYPE_FAILURE, "failure" },
+ { LM_MESSAGE_TYPE_PROCEED, "proceed" },
+ { LM_MESSAGE_TYPE_STARTTLS, "starttls" },
+ { LM_MESSAGE_TYPE_UNKNOWN, NULL }
+};
+
+static struct SubTypeNames
+{
+ LmMessageSubType type;
+ const gchar *name;
+} sub_type_names[] = {
+ { LM_MESSAGE_SUB_TYPE_NORMAL, "normal" },
+ { LM_MESSAGE_SUB_TYPE_CHAT, "chat" },
+ { LM_MESSAGE_SUB_TYPE_GROUPCHAT, "groupchat" },
+ { LM_MESSAGE_SUB_TYPE_HEADLINE, "headline" },
+ { LM_MESSAGE_SUB_TYPE_UNAVAILABLE, "unavailable" },
+ { LM_MESSAGE_SUB_TYPE_PROBE, "probe" },
+ { LM_MESSAGE_SUB_TYPE_SUBSCRIBE, "subscribe" },
+ { LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE, "unsubscribe" },
+ { LM_MESSAGE_SUB_TYPE_SUBSCRIBED, "subscribed" },
+ { LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED, "unsubscribed" },
+ { LM_MESSAGE_SUB_TYPE_GET, "get" },
+ { LM_MESSAGE_SUB_TYPE_SET, "set" },
+ { LM_MESSAGE_SUB_TYPE_RESULT, "result" },
+ { LM_MESSAGE_SUB_TYPE_ERROR, "error" }
+};
+#endif
+
+struct LmMessagePriv {
+ LmMessageType type;
+ LmMessageSubType sub_type;
+ gint ref_count;
+};
+
+static LmMessageType
+message_type_from_string (const gchar *type_str)
+{
+ gint i;
+
+ if (!type_str) {
+ return LM_MESSAGE_TYPE_UNKNOWN;
+ }
+
+ for (i = LM_MESSAGE_TYPE_MESSAGE;
+ i < LM_MESSAGE_TYPE_UNKNOWN;
+ ++i) {
+ if (strcmp (type_str, type_names[i].name) == 0) {
+ return type_names[i].type;
+ }
+ }
+
+ return LM_MESSAGE_TYPE_UNKNOWN;
+}
+
+
+const gchar *
+_lm_message_type_to_string (LmMessageType type)
+{
+ if (type < LM_MESSAGE_TYPE_MESSAGE ||
+ type > LM_MESSAGE_TYPE_STARTTLS) {
+ type = LM_MESSAGE_TYPE_UNKNOWN;
+ }
+
+ return type_names[type].name;
+}
+
+static LmMessageSubType
+message_sub_type_from_string (const gchar *type_str)
+{
+ gint i;
+
+ if (!type_str) {
+ return LM_MESSAGE_SUB_TYPE_NOT_SET;
+ }
+
+ for (i = LM_MESSAGE_SUB_TYPE_NORMAL;
+ i <= LM_MESSAGE_SUB_TYPE_ERROR;
+ ++i) {
+ if (g_ascii_strcasecmp (type_str,
+ sub_type_names[i].name) == 0) {
+ return i;
+ }
+ }
+
+ return LM_MESSAGE_SUB_TYPE_NOT_SET;
+}
+
+const gchar *
+_lm_message_sub_type_to_string (LmMessageSubType type)
+{
+ if (type < LM_MESSAGE_SUB_TYPE_NORMAL ||
+ type > LM_MESSAGE_SUB_TYPE_ERROR) {
+ return NULL;
+ }
+
+ return sub_type_names[type].name;
+}
+
+static LmMessageSubType
+message_sub_type_when_unset (LmMessageType type) {
+ LmMessageSubType sub_type = LM_MESSAGE_SUB_TYPE_NORMAL;
+
+ switch (type) {
+ case LM_MESSAGE_TYPE_MESSAGE:
+ /* A message without type should be handled like a message with
+ * type=normal, but we won't set it to that since then the user
+ * will not know if it's set or not.
+ */
+ sub_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
+ break;
+ case LM_MESSAGE_TYPE_PRESENCE:
+ sub_type = LM_MESSAGE_SUB_TYPE_AVAILABLE;
+ break;
+ case LM_MESSAGE_TYPE_IQ:
+ sub_type = LM_MESSAGE_SUB_TYPE_GET;
+ break;
+ default:
+ break;
+ }
+
+ return sub_type;
+}
+
+LmMessage *
+_lm_message_new_from_node (LmMessageNode *node)
+{
+ LmMessage *m;
+ LmMessageType type;
+ LmMessageSubType sub_type;
+ const gchar *sub_type_str;
+
+ type = message_type_from_string (node->name);
+
+ if (type == LM_MESSAGE_TYPE_UNKNOWN) {
+ return NULL;
+ }
+
+ sub_type_str = lm_message_node_get_attribute (node, "type");
+ if (sub_type_str) {
+ sub_type = message_sub_type_from_string (sub_type_str);
+ } else {
+ sub_type = message_sub_type_when_unset (type);
+ }
+
+ m = g_new0 (LmMessage, 1);
+ m->priv = g_new0 (LmMessagePriv, 1);
+
+ PRIV(m)->ref_count = 1;
+ PRIV(m)->type = type;
+ PRIV(m)->sub_type = sub_type;
+
+ m->node = lm_message_node_ref (node);
+
+ return m;
+}
+
+/**
+ * lm_message_new:
+ * @to: receipient jid
+ * @type: message type
+ *
+ * Creates a new #LmMessage which can be sent with lm_connection_send() or
+ * lm_connection_send_with_reply(). If @to is %NULL the message is sent to the
+ * server. The returned message should be unreferenced with lm_message_unref()
+ * when caller is finished with it.
+ *
+ * Return value: a newly created #LmMessage
+ **/
+EXPORT_C LmMessage *
+lm_message_new (const gchar *to, LmMessageType type)
+{
+ LmMessage *m;
+ gchar *id;
+
+ m = g_new0 (LmMessage, 1);
+ m->priv = g_new0 (LmMessagePriv, 1);
+
+ PRIV(m)->ref_count = 1;
+ PRIV(m)->type = type;
+ PRIV(m)->sub_type = message_sub_type_when_unset (type);
+
+ m->node = _lm_message_node_new (_lm_message_type_to_string (type));
+
+ id = _lm_utils_generate_id ();
+ lm_message_node_set_attribute (m->node, "id", id);
+ g_free (id);
+
+ if (to) {
+ lm_message_node_set_attribute (m->node, "to", to);
+ }
+
+ if (type == LM_MESSAGE_TYPE_IQ) {
+ lm_message_node_set_attribute (m->node, "type", "get");
+ }
+
+ return m;
+}
+
+/**
+ * lm_message_new_with_sub_type:
+ * @to: receipient jid
+ * @type: message type
+ * @sub_type: message sub type
+ *
+ * Creates a new #LmMessage with sub type set. See lm_message_new() for more
+ * information.
+ *
+ * Return value: a newly created #LmMessage
+ **/
+EXPORT_C LmMessage *
+lm_message_new_with_sub_type (const gchar *to,
+ LmMessageType type,
+ LmMessageSubType sub_type)
+{
+ LmMessage *m;
+ const gchar *type_str;
+
+ m = lm_message_new (to, type);
+
+ type_str = _lm_message_sub_type_to_string (sub_type);
+
+ if (type_str) {
+ lm_message_node_set_attributes (m->node,
+ "type", type_str, NULL);
+ PRIV(m)->sub_type = sub_type;
+ }
+
+ return m;
+}
+
+/**
+ * lm_message_get_type:
+ * @message: an #LmMessage
+ *
+ * Fetches the type of @message.
+ *
+ * Return value: the message type
+ **/
+EXPORT_C LmMessageType
+lm_message_get_type (LmMessage *message)
+{
+ g_return_val_if_fail (message != NULL, LM_MESSAGE_TYPE_UNKNOWN);
+
+ return PRIV(message)->type;
+}
+
+/**
+ * lm_message_get_sub_type:
+ * @message:
+ *
+ * Fetches the sub type of @message.
+ *
+ * Return value: the message sub type
+ **/
+EXPORT_C LmMessageSubType
+lm_message_get_sub_type (LmMessage *message)
+{
+ g_return_val_if_fail (message != NULL, LM_MESSAGE_TYPE_UNKNOWN);
+
+ return PRIV(message)->sub_type;
+}
+
+/**
+ * lm_message_get_node:
+ * @message: an #LmMessage
+ *
+ * Retrieves the root node from @message.
+ *
+ * Return value: an #LmMessageNode
+ **/
+EXPORT_C LmMessageNode *
+lm_message_get_node (LmMessage *message)
+{
+ g_return_val_if_fail (message != NULL, NULL);
+
+ return message->node;
+}
+
+/**
+ * lm_message_ref:
+ * @message: an #LmMessage
+ *
+ * Adds a reference to @message.
+ *
+ * Return value: the message
+ **/
+EXPORT_C LmMessage *
+lm_message_ref (LmMessage *message)
+{
+ g_return_val_if_fail (message != NULL, NULL);
+
+ PRIV(message)->ref_count++;
+
+ return message;
+}
+
+/**
+ * lm_message_unref:
+ * @message: an #LmMessage
+ *
+ * Removes a reference from @message. When no more references are present the
+ * message is freed.
+ **/
+EXPORT_C void
+lm_message_unref (LmMessage *message)
+{
+ //g_return_if_fail (message != NULL);
+ if(message==NULL)
+ return;
+
+ PRIV(message)->ref_count--;
+
+ if (PRIV(message)->ref_count == 0) {
+ lm_message_node_unref (message->node);
+ g_free (message->priv);
+ g_free (message);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-misc.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,116 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "lm-misc.h"
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+GET_STATIC_ARRAY_FROM_TLS(buf, lm_misc, gchar)
+ #define buf (GET_WSD_VAR_NAME(buf, lm_misc, s)())
+
+
+#endif
+
+static void
+misc_setup_source (GMainContext *context,
+ GSource *source,
+ GSourceFunc function,
+ gpointer data)
+{
+ g_source_set_callback (source, (GSourceFunc)function, data, NULL);
+ g_source_attach (source, context);
+ g_source_unref (source);
+}
+
+GSource *
+lm_misc_add_io_watch (GMainContext *context,
+ GIOChannel *channel,
+ GIOCondition condition,
+ GIOFunc function,
+ gpointer data)
+{
+ GSource *source;
+
+ g_return_val_if_fail (channel != NULL, 0);
+
+ source = g_io_create_watch (channel, condition);
+ misc_setup_source (context, source, (GSourceFunc) function, data);
+
+ return source;
+}
+
+GSource *
+lm_misc_add_idle (GMainContext *context,
+ GSourceFunc function,
+ gpointer data)
+{
+ GSource *source;
+
+ g_return_val_if_fail (function != NULL, 0);
+
+ source = g_idle_source_new ();
+ misc_setup_source (context, source, function, data);
+
+ return source;
+}
+
+GSource *
+lm_misc_add_timeout (GMainContext *context,
+ guint interval,
+ GSourceFunc function,
+ gpointer data)
+{
+ GSource *source;
+
+ g_return_val_if_fail (function != NULL, 0);
+
+ source = g_timeout_source_new (interval);
+ misc_setup_source (context, source, function, data);
+
+ return source;
+}
+
+const char *
+lm_misc_io_condition_to_str (GIOCondition condition)
+{
+#ifndef EMULATOR
+ static char buf[256];
+#endif
+
+ buf[0] = '\0';
+
+ if(condition & G_IO_ERR)
+ strcat(buf, "G_IO_ERR ");
+ if(condition & G_IO_HUP)
+ strcat(buf, "G_IO_HUP ");
+ if(condition & G_IO_NVAL)
+ strcat(buf, "G_IO_NVAL ");
+ if(condition & G_IO_IN)
+ strcat(buf, "G_IO_IN ");
+ if(condition & G_IO_OUT)
+ strcat(buf, "G_IO_OUT ");
+
+ return buf;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-parser.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,284 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "lm-debug.h"
+#include "lm-internals.h"
+#include "lm-message-node.h"
+#include "lm-parser.h"
+
+#define SHORT_END_TAG "/>"
+#define XML_MAX_DEPTH 5
+
+#define LM_PARSER(o) ((LmParser *) o)
+
+struct LmParser {
+ LmParserMessageFunction function;
+ gpointer user_data;
+ GDestroyNotify notify;
+
+ LmMessageNode *cur_root;
+ LmMessageNode *cur_node;
+
+ GMarkupParser *m_parser;
+ GMarkupParseContext *context;
+};
+
+
+/* Used while parsing */
+static void parser_start_node_cb (GMarkupParseContext *context,
+ const gchar *node_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error);
+static void parser_end_node_cb (GMarkupParseContext *context,
+ const gchar *node_name,
+ gpointer user_data,
+ GError **error);
+static void parser_text_cb (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
+static void parser_error_cb (GMarkupParseContext *context,
+ GError *error,
+ gpointer user_data);
+
+static void
+parser_start_node_cb (GMarkupParseContext *context,
+ const gchar *node_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
+{
+ LmParser *parser;
+ gint i;
+
+ parser = LM_PARSER (user_data);;
+
+
+/* parser->cur_depth++; */
+
+ if (!parser->cur_root) {
+ /* New toplevel element */
+ parser->cur_root = _lm_message_node_new (node_name);
+ parser->cur_node = parser->cur_root;
+ } else {
+ LmMessageNode *parent_node;
+
+ parent_node = parser->cur_node;
+
+ parser->cur_node = _lm_message_node_new (node_name);
+ _lm_message_node_add_child_node (parent_node,
+ parser->cur_node);
+ }
+
+ for (i = 0; attribute_names[i]; ++i) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_PARSER,
+ "ATTRIBUTE: %s = %s\n",
+ attribute_names[i],
+ attribute_values[i]);*/
+
+ lm_verbose ("[parser_start_node_cb]: ATTRIBUTE: %s = %s\n",
+ attribute_names[i],
+ attribute_values[i]);
+
+ lm_message_node_set_attributes (parser->cur_node,
+ attribute_names[i],
+ attribute_values[i],
+ NULL);
+ }
+
+ if (strcmp ("stream:stream", node_name) == 0) {
+ parser_end_node_cb (context,
+ "stream:stream",
+ user_data,
+ error);
+ }
+}
+
+static void
+parser_end_node_cb (GMarkupParseContext *context,
+ const gchar *node_name,
+ gpointer user_data,
+ GError **error)
+{
+ LmParser *parser;
+
+ parser = LM_PARSER (user_data);
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_PARSER,
+ "Trying to close node: %s\n", node_name);*/
+ lm_verbose ("[parser_end_node_cb]:Trying to close node: %s\n", node_name);
+ if (!parser->cur_node) {
+ /* FIXME: LM-1 should look at this */
+ return;
+ }
+
+ if (strcmp (parser->cur_node->name, node_name) != 0) {
+ if (strcmp (node_name, "stream:stream")) {
+ g_print ("Got an stream:stream end\n");
+ }
+ g_warning ("Trying to close node that isn't open: %s",
+ node_name);
+ return;
+ }
+
+ if (parser->cur_node == parser->cur_root) {
+ LmMessage *m;
+
+ m = _lm_message_new_from_node (parser->cur_root);
+
+ if (!m) {
+ g_warning ("Couldn't create message: %s\n",
+ parser->cur_root->name);
+ return;
+ }
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_PARSER,
+ "Have a new message\n");*/
+ lm_verbose("[parser_end_node_cb]: Have a new message\n");
+ if (parser->function) {
+ (* parser->function) (parser, m, parser->user_data);
+ }
+
+ lm_message_unref (m);
+ lm_message_node_unref (parser->cur_root);
+
+
+ parser->cur_node = parser->cur_root = NULL;
+ } else {
+ LmMessageNode *tmp_node;
+ tmp_node = parser->cur_node;
+ parser->cur_node = parser->cur_node->parent;
+
+ lm_message_node_unref (tmp_node);
+ }
+ UNUSED_FORMAL_PARAM(context);
+ UNUSED_FORMAL_PARAM(error);
+}
+
+static void
+parser_text_cb (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ LmParser *parser;
+
+ g_return_if_fail (user_data != NULL);
+
+ parser = LM_PARSER (user_data);
+
+ if (parser->cur_node && strcmp (text, "") != 0) {
+ lm_message_node_set_value (parser->cur_node, text);
+ }
+ UNUSED_FORMAL_PARAM(context);
+ UNUSED_FORMAL_PARAM(error);
+ UNUSED_FORMAL_PARAM(text_len);
+}
+
+static void
+parser_error_cb (GMarkupParseContext *context,
+ GError *error,
+ gpointer user_data)
+{
+ g_return_if_fail (user_data != NULL);
+ g_return_if_fail (error != NULL);
+
+ g_warning ("Parsing failed: %s\n", error->message);
+ UNUSED_FORMAL_PARAM(context);
+}
+
+EXPORT_C LmParser *
+lm_parser_new (LmParserMessageFunction function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ LmParser *parser;
+
+ parser = g_new0 (LmParser, 1);
+ if (!parser) {
+ return NULL;
+ }
+
+ parser->m_parser = g_new0 (GMarkupParser, 1);
+ if (!parser->m_parser) {
+ g_free (parser);
+ return NULL;
+ }
+
+ parser->function = function;
+ parser->user_data = user_data;
+ parser->notify = notify;
+
+ parser->m_parser->start_element = parser_start_node_cb;
+ parser->m_parser->end_element = parser_end_node_cb;
+ parser->m_parser->text = parser_text_cb;
+ parser->m_parser->error = parser_error_cb;
+
+ parser->context = g_markup_parse_context_new (parser->m_parser, 0,
+ parser, NULL);
+
+ parser->cur_root = NULL;
+ parser->cur_node = NULL;
+
+ return parser;
+}
+
+EXPORT_C void
+lm_parser_parse (LmParser *parser, const gchar *string)
+{
+ g_return_if_fail (parser != NULL);
+
+ if (!parser->context) {
+ parser->context = g_markup_parse_context_new (parser->m_parser, 0,
+ parser, NULL);
+ }
+
+ if (g_markup_parse_context_parse (parser->context, string,
+ (gssize)strlen (string), NULL)) {
+ } else {
+ g_markup_parse_context_free (parser->context);
+ parser->context = NULL;
+ }
+}
+
+EXPORT_C void
+lm_parser_free (LmParser *parser)
+{
+ if (parser->notify) {
+ (* parser->notify) (parser->user_data);
+ }
+
+ if (parser->context) {
+ g_markup_parse_context_free (parser->context);
+ }
+ g_free (parser->m_parser);
+ g_free (parser);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-proxy.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,490 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2004 Imendio AB
+ * Copyright (C) 2004 Josh Beam <josh@3ddrome.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <string.h>
+
+#ifndef G_OS_WIN32
+
+#include <unistd.h>
+#include <sys/socket.h>
+
+#else /* G_OS_WIN32 */
+
+#include <winsock2.h>
+
+#endif /* G_OS_WIN32 */
+
+#include "lm-internals.h"
+#include "lm-proxy.h"
+#include "lm-debug.h"
+#include "lm-utils.h"
+
+struct _LmProxy {
+ LmProxyType type;
+ gchar *server;
+ guint port;
+ gchar *username;
+ gchar *password;
+ guint io_watch;
+
+ gint ref_count;
+};
+
+static void proxy_free (LmProxy *proxy);
+static gboolean proxy_http_negotiate (LmProxy *proxy,
+ gint fd,
+ const gchar *server,
+ guint port);
+static gboolean proxy_negotiate (LmProxy *proxy,
+ gint fd,
+ const gchar *server,
+ guint port);
+static gboolean proxy_http_read_cb (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data);
+static gboolean proxy_read_cb (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data);
+
+static void
+proxy_free (LmProxy *proxy)
+{
+ g_free (proxy->server);
+ g_free (proxy->username);
+ g_free (proxy->password);
+
+ g_free (proxy);
+}
+
+static gboolean
+proxy_http_negotiate (LmProxy *proxy, gint fd, const gchar *server, guint port)
+{
+ gchar *str;
+
+ if (proxy->username && proxy->password) {
+ gchar *tmp1;
+ gchar *tmp2;
+
+ tmp1 = g_strdup_printf ("%s:%s",
+ proxy->username,
+ proxy->password);
+ tmp2 = _lm_utils_base64_encode (tmp1);
+ g_free (tmp1);
+
+ str = g_strdup_printf ("CONNECT %s:%u HTTP/1.1\r\nHost: %s:%u\r\nProxy-Authorization: Basic %s\r\n\r\n",
+ server, port,
+ server, port,
+ tmp2);
+ g_free (tmp2);
+ } else {
+ str = g_strdup_printf ("CONNECT %s:%u HTTP/1.1\r\nHost: %s:%u\r\n\r\n",
+ server, port,
+ server, port);
+ }
+
+ send (fd, str, strlen (str), 0);
+ g_free (str);
+ return TRUE;
+}
+
+/* returns TRUE when connected through proxy */
+static gboolean
+proxy_http_read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ gchar buf[512];
+ gsize bytes_read;
+ GError *error = NULL;
+
+ g_io_channel_read_chars (source, buf, 512, &bytes_read, &error);
+
+ if (bytes_read < 16) {
+ return FALSE;
+ }
+
+ if (strncmp (buf, "HTTP/1.1 200", 12) != 0 &&
+ strncmp (buf, "HTTP/1.0 200", 12) != 0) {
+ return FALSE;
+ }
+
+ if (strncmp (buf + (bytes_read - 4), "\r\n\r\n", 4) != 0) {
+ return FALSE;
+ }
+ UNUSED_FORMAL_PARAM(condition);
+ UNUSED_FORMAL_PARAM(data);
+ return TRUE;
+}
+
+static gboolean
+proxy_read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ LmConnectData *connect_data;
+ LmConnection *connection;
+ LmProxy *proxy;
+ gboolean retval = FALSE;
+
+ connect_data = (LmConnectData *) data;
+ connection = connect_data->connection;
+ proxy = lm_connection_get_proxy (connection);
+
+ g_return_val_if_fail (proxy != NULL, FALSE);
+
+ if (lm_connection_is_open (connection)) {
+ return FALSE;
+ }
+
+ switch (lm_proxy_get_type (proxy)) {
+ default:
+ case LM_PROXY_TYPE_NONE:
+ g_assert_not_reached ();
+ break;
+ case LM_PROXY_TYPE_HTTP:
+ retval = proxy_http_read_cb (source, condition, data);
+ break;
+ }
+
+ if (retval == TRUE) {
+ g_source_remove (proxy->io_watch);
+ _lm_socket_succeeded ((LmConnectData *) data);
+ }
+ //retval is false
+ //route call to connect_cb
+ else
+ {
+ _lm_socket_failed_with_error(connect_data, _LM_SOCK_EINVAL);
+ }
+ return FALSE;
+}
+
+gboolean
+proxy_negotiate (LmProxy *proxy, gint fd, const gchar *server, guint port)
+{
+ g_return_val_if_fail (proxy != NULL, FALSE);
+
+ switch (proxy->type) {
+ case LM_PROXY_TYPE_NONE:
+ return TRUE;
+ case LM_PROXY_TYPE_HTTP:
+ return proxy_http_negotiate (proxy, fd, server, port);
+ default:
+ g_assert_not_reached ();
+ }
+
+ return FALSE;
+}
+
+gboolean
+_lm_proxy_connect_cb (GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ LmConnection *connection;
+ LmConnectData *connect_data;
+ LmProxy *proxy;
+ int error;
+ socklen_t len;
+
+ connect_data = (LmConnectData *) data;
+ connection = connect_data->connection;
+ proxy = lm_connection_get_proxy (connection);
+
+ g_return_val_if_fail (proxy != NULL, FALSE);
+
+ if (condition == G_IO_ERR) {
+ len = sizeof (error);
+ _lm_sock_get_error (connect_data->fd, &error, &len);
+ _lm_socket_failed_with_error (connect_data, error);
+ return FALSE;
+ } else if (condition == G_IO_OUT) {
+ if (!proxy_negotiate (lm_connection_get_proxy (connection), connect_data->fd, lm_connection_get_server (connection), lm_connection_get_port (connection))) {
+ _lm_socket_failed (connect_data);
+ return FALSE;
+ }
+
+ proxy->io_watch = g_io_add_watch (connect_data->io_channel,
+ G_IO_IN|G_IO_ERR,
+ (GIOFunc) proxy_read_cb,
+ connect_data);
+ } else {
+ g_assert_not_reached ();
+ }
+ UNUSED_FORMAL_PARAM(source);
+ return FALSE;
+}
+
+/**
+ * lm_proxy_new
+ * @type: the type of the new proxy
+ *
+ * Creates a new Proxy. Used #lm_connection_set_proxy to make a connection
+ * user this proxy.
+ *
+ * Return value: a newly create proxy
+ **/
+EXPORT_C LmProxy *
+lm_proxy_new (LmProxyType type)
+{
+ LmProxy *proxy;
+
+ proxy = g_new0 (LmProxy, 1);
+
+ proxy->ref_count = 1;
+ proxy->type = type;
+
+ switch (proxy->type) {
+ case LM_PROXY_TYPE_HTTP:
+ proxy->port = 8000;
+ break;
+ default:
+ proxy->port = 0;
+ }
+
+ return proxy;
+}
+
+/**
+ * lm_proxy_new_with_server
+ * @type: the type of the new proxy
+ * @server: the proxy server
+ * @port: the proxy server port
+ *
+ * Creates a new Proxy. Use #lm_connection_set_proxy to make a connection
+ * user this proxy.
+ *
+ * Return value: a newly create proxy
+ **/
+EXPORT_C LmProxy *
+lm_proxy_new_with_server (LmProxyType type,
+ const gchar *server,
+ guint port)
+{
+ LmProxy *proxy;
+
+ proxy = lm_proxy_new (type);
+ lm_proxy_set_server (proxy, server);
+ lm_proxy_set_port (proxy, port);
+
+ return proxy;
+}
+
+/**
+ * lm_proxy_get_type
+ * @proxy: an #LmProxy
+ *
+ * Fetches the proxy type
+ *
+ * Return value: the type
+ **/
+EXPORT_C LmProxyType
+lm_proxy_get_type (LmProxy *proxy)
+{
+ g_return_val_if_fail (proxy != NULL, LM_PROXY_TYPE_NONE);
+
+ return proxy->type;
+}
+
+/**
+ * lm_proxy_set_type
+ * @proxy: an #LmProxy
+ * @type: an LmProxyType
+ *
+ * Sets the proxy type for @proxy to @type.
+ **/
+EXPORT_C void
+lm_proxy_set_type (LmProxy *proxy, LmProxyType type)
+{
+ g_return_if_fail (proxy != NULL);
+
+ proxy->type = type;
+}
+
+/**
+ * lm_proxy_get_server:
+ * @proxy: an #LmProxy
+ *
+ * Fetches the server address that @proxy is using.
+ *
+ * Return value: the proxy server address
+ **/
+EXPORT_C const gchar *
+lm_proxy_get_server (LmProxy *proxy)
+{
+ g_return_val_if_fail (proxy != NULL, NULL);
+
+ return proxy->server;
+}
+
+/**
+ * lm_proxy_set_server:
+ * @proxy: an #LmProxy
+ * @server: Address of the proxy server
+ *
+ * Sets the server address for @proxy to @server.
+ **/
+EXPORT_C void
+lm_proxy_set_server (LmProxy *proxy, const gchar *server)
+{
+ g_return_if_fail (proxy != NULL);
+ g_return_if_fail (server != NULL);
+
+ g_free (proxy->server);
+ proxy->server = _lm_utils_hostname_to_punycode (server);
+}
+
+/**
+ * lm_proxy_get_port:
+ * @proxy: an #LmProxy
+ *
+ * Fetches the port that @proxy is using.
+ *
+ * Return value: The port
+ **/
+EXPORT_C guint
+lm_proxy_get_port (LmProxy *proxy)
+{
+ g_return_val_if_fail (proxy != NULL, 0);
+
+ return proxy->port;
+}
+
+/**
+ * lm_proxy_set_port:
+ * @proxy: an #LmProxy
+ * @port: proxy server port
+ *
+ * Sets the server port that @proxy will be using.
+ **/
+EXPORT_C void
+lm_proxy_set_port (LmProxy *proxy, guint port)
+{
+ g_return_if_fail (proxy != NULL);
+
+ proxy->port = port;
+}
+
+/**
+ * lm_proxy_get_username:
+ * @proxy: an #LmProxy
+ *
+ * Fetches the username that @proxy is using.
+ *
+ * Return value: the username
+ **/
+EXPORT_C const gchar *
+lm_proxy_get_username (LmProxy *proxy)
+{
+ g_return_val_if_fail (proxy != NULL, NULL);
+
+ return proxy->username;
+}
+
+/**
+ * lm_proxy_set_username:
+ * @proxy: an #LmProxy
+ * @username: Username
+ *
+ * Sets the username for @proxy to @username or %NULL to unset.
+ **/
+EXPORT_C void
+lm_proxy_set_username (LmProxy *proxy, const gchar *username)
+{
+ g_return_if_fail (proxy != NULL);
+
+ g_free (proxy->username);
+
+ if (username) {
+ proxy->username = g_strdup (username);
+ } else {
+ proxy->username = NULL;
+ }
+}
+/**
+ * lm_proxy_get_password:
+ * @proxy: an #LmProxy
+ *
+ * Fetches the password that @proxy is using.
+ *
+ * Return value: the proxy password
+ **/
+EXPORT_C const gchar *
+lm_proxy_get_password (LmProxy *proxy)
+{
+ g_return_val_if_fail (proxy != NULL, NULL);
+
+ return proxy->password;
+}
+
+/**
+ * lm_proxy_set_password:
+ * @proxy: an #LmProxy
+ * @password: Password
+ *
+ * Sets the password for @proxy to @password or %NULL to unset.
+ **/
+EXPORT_C void
+lm_proxy_set_password (LmProxy *proxy, const gchar *password)
+{
+ g_return_if_fail (proxy != NULL);
+
+ g_free (proxy->password);
+
+ if (password) {
+ proxy->password = g_strdup (password);
+ } else {
+ proxy->password = NULL;
+ }
+}
+
+/**
+ * lm_proxy_ref:
+ * @proxy: an #LmProxy
+ *
+ * Adds a reference to @proxy.
+ *
+ * Return value: the proxy
+ **/
+EXPORT_C LmProxy *
+lm_proxy_ref (LmProxy *proxy)
+{
+ g_return_val_if_fail (proxy != NULL, NULL);
+
+ proxy->ref_count++;
+ return proxy;
+}
+
+/**
+ * lm_proxy_unref
+ * @proxy: an #LmProxy
+ *
+ * Removes a reference from @proxy. When no more references are present
+ * @proxy is freed.
+ **/
+EXPORT_C void
+lm_proxy_unref (LmProxy *proxy)
+{
+ g_return_if_fail (proxy != NULL);
+
+ proxy->ref_count--;
+
+ if (proxy->ref_count == 0) {
+ proxy_free (proxy);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-sasl.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,876 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
+//hack - to get over compilation error
+#include <glib_global.h>
+#include "lm-sock.h"
+#include "lm-debug.h"
+#include "lm-error.h"
+#include "lm-internals.h"
+#include "lm-message-queue.h"
+#include "lm-misc.h"
+#include "lm-ssl-internals.h"
+#include "lm-parser.h"
+#include "lm-sha.h"
+#include "lm-connection.h"
+#include "lm-utils.h"
+#include "lm-socket.h"
+#include "lm-sasl.h"
+
+#include "md5.h"
+#include "base64.h"
+
+typedef enum {
+ AUTH_TYPE_PLAIN = 1,
+ AUTH_TYPE_DIGEST = 2
+} AuthType;
+
+typedef enum {
+ SASL_AUTH_STATE_NO_MECH,
+ SASL_AUTH_STATE_PLAIN_STARTED,
+ SASL_AUTH_STATE_DIGEST_MD5_STARTED,
+ SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE,
+ SASL_AUTH_STATE_DIGEST_MD5_SENT_FINAL_RESPONSE,
+} SaslAuthState;
+
+struct _LmSASL {
+ LmConnection *connection;
+ AuthType auth_type;
+ SaslAuthState state;
+ gchar *username;
+ gchar *password;
+ gchar *server;
+ gchar *digest_md5_rspauth;
+ LmMessageHandler *features_cb;
+ LmMessageHandler *challenge_cb;
+ LmMessageHandler *success_cb;
+ LmMessageHandler *failure_cb;
+
+ gboolean features_received;
+ gboolean start_auth;
+
+ LmSASLResultHandler handler;
+};
+
+#define XMPP_NS_SASL_AUTH "urn:ietf:params:xml:ns:xmpp-sasl"
+
+static LmHandlerResult sasl_features_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data);
+
+static LmHandlerResult sasl_challenge_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data);
+
+static LmHandlerResult sasl_success_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data);
+
+static LmHandlerResult sasl_failure_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data);
+
+
+/* DIGEST-MD5 mechanism code from libgibber */
+
+static gchar *
+sasl_strndup_unescaped (const gchar *str, gsize len)
+{
+ const gchar *s;
+ gchar *d;
+ gchar *ret;
+
+ ret = g_malloc0 (len + 1);
+ for (s = str, d = ret ; s < (str + len) ; s++, d++) {
+ if (*s == '\\') s++;
+ *d = *s;
+ }
+
+ return ret;
+}
+
+static GHashTable *
+sasl_digest_md5_challenge_to_hash (const gchar * challenge)
+{
+ const gchar *keystart, *keyend, *valstart;
+ const gchar *c = challenge;
+ gchar *key, *val;
+ GHashTable *result;
+
+ result = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_free);
+
+ do {
+ while (g_ascii_isspace(*c)) c++;
+
+ keystart = c;
+ for (; *c != '\0' && *c != '='; c++);
+
+ if (*c == '\0' || c == keystart) goto error;
+
+ keyend = c;
+ c++;
+
+ if (*c == '"') {
+ c++;
+ valstart = c;
+ for (; *c != '\0' && *c != '"'; c++);
+ if (*c == '\0' || c == valstart) goto error;
+ val = sasl_strndup_unescaped (valstart, c - valstart);
+ c++;
+ } else {
+ valstart = c;
+ for (; *c != '\0' && *c != ','; c++);
+ if (c == valstart) goto error;
+ val = g_strndup (valstart, c - valstart);
+ }
+
+ key = g_strndup (keystart, keyend - keystart);
+
+ g_hash_table_insert (result, key, val);
+
+ if (*c == ',') c++;
+ } while (*c != '\0');
+
+ return result;
+error:
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "Failed to parse challenge: %s", challenge);*/
+ lm_verbose("[sasl_digest_md5_challenge_to_hash]:Failed to parse challenge: %s", challenge);
+ g_hash_table_destroy (result);
+ return NULL;
+}
+
+static gchar *
+sasl_md5_hex_hash (gchar *value, gsize len)
+{
+ md5_byte_t digest_md5[16];
+ md5_state_t md5_calc;
+ GString *str;
+ int i;
+
+ str = g_string_sized_new (32);
+
+ md5_init (&md5_calc);
+ md5_append (&md5_calc, (const md5_byte_t *)value, len);
+ md5_finish (&md5_calc, digest_md5);
+
+ for (i = 0 ; i < 16 ; i++) {
+ g_string_append_printf (str, "%02x", digest_md5[i]);
+ }
+
+ return g_string_free (str, FALSE);
+}
+
+static gchar *
+sasl_digest_md5_generate_cnonce(void)
+{
+ /* RFC 2831 recommends the the nonce to be either hexadecimal or base64 with
+ * at least 64 bits of entropy */
+#define NR 8
+ guint32 n[NR];
+ int i;
+
+ for (i = 0; i < NR; i++) {
+ n[i] = g_random_int();
+ }
+
+ return base64_encode ((gchar *)n, sizeof(n));
+}
+
+static gchar *
+sasl_md5_prepare_response (LmSASL *sasl, GHashTable *challenge)
+{
+ GString *response;
+ const gchar *realm, *nonce;
+ gchar *a1, *a1h, *a2, *a2h, *kd, *kdh;
+ gchar *cnonce = NULL;
+ gchar *tmp;
+ md5_byte_t digest_md5[16];
+ md5_state_t md5_calc;
+ gsize len;
+
+ response = g_string_new ("");
+
+ if (sasl->username == NULL || sasl->password == NULL) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: no username or password provided", G_STRFUNC);*/
+ lm_verbose("[sasl_md5_prepare_response]: %s: no username or password provided", G_STRFUNC);
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "no username/password provided");
+ }
+ goto error;
+ }
+
+ nonce = g_hash_table_lookup (challenge, "nonce");
+ if (nonce == NULL || nonce == '\0') {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: server didn't provide a nonce in the challenge",
+ G_STRFUNC);*/
+ lm_verbose("[sasl_md5_prepare_response]: %s: server didn't provide a nonce in the challenge", G_STRFUNC);
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "server error");
+ }
+ goto error;
+ }
+
+ cnonce = sasl_digest_md5_generate_cnonce ();
+
+ /* FIXME challenge can contain multiple realms */
+ realm = g_hash_table_lookup (challenge, "realm");
+ if (realm == NULL) {
+ realm = sasl->server;
+ }
+
+ /* FIXME properly escape values */
+ g_string_append_printf (response, "username=\"%s\"", sasl->username);
+ g_string_append_printf (response, ",realm=\"%s\"", realm);
+ g_string_append_printf (response, ",digest-uri=\"xmpp/%s\"", realm);
+ g_string_append_printf (response, ",nonce=\"%s\",nc=00000001", nonce);
+ g_string_append_printf (response, ",cnonce=\"%s\"", cnonce);
+ /* FIXME should check if auth is in the cop challenge val */
+ g_string_append_printf (response, ",qop=auth,charset=utf-8");
+
+ tmp = g_strdup_printf ("%s:%s:%s",
+ sasl->username, realm, sasl->password);
+ md5_init (&md5_calc);
+ md5_append (&md5_calc, (const md5_byte_t *)tmp, strlen(tmp));
+ md5_finish (&md5_calc, digest_md5);
+ g_free (tmp);
+
+ a1 = g_strdup_printf ("0123456789012345:%s:%s", nonce, cnonce);
+ len = strlen (a1);
+ memcpy (a1, digest_md5, 16);
+ a1h = sasl_md5_hex_hash (a1, len);
+
+ a2 = g_strdup_printf ("AUTHENTICATE:xmpp/%s", realm);
+ a2h = sasl_md5_hex_hash (a2, strlen(a2));
+
+ kd = g_strdup_printf ("%s:%s:00000001:%s:auth:%s",
+ a1h, nonce, cnonce, a2h);
+ kdh = sasl_md5_hex_hash (kd, strlen(kd));
+ g_string_append_printf (response, ",response=%s", kdh);
+
+ g_free (kd);
+ g_free (kdh);
+ g_free (a2);
+ g_free (a2h);
+
+ /* Calculate the response we expect from the server */
+ a2 = g_strdup_printf (":xmpp/%s", realm);
+ a2h = sasl_md5_hex_hash (a2, strlen(a2));
+
+ kd = g_strdup_printf ("%s:%s:00000001:%s:auth:%s", a1h, nonce, cnonce, a2h);
+ g_free (sasl->digest_md5_rspauth);
+ sasl->digest_md5_rspauth = sasl_md5_hex_hash (kd, strlen(kd));
+
+ g_free (a1);
+ g_free (a1h);
+ g_free (a2);
+ g_free (a2h);
+ g_free (kd);
+
+out:
+ g_free (cnonce);
+ if (response) {
+ return g_string_free (response, FALSE);
+ } else {
+ return NULL;
+ }
+
+error:
+ g_string_free (response, TRUE);
+ response = NULL;
+ goto out;
+}
+
+static gboolean
+sasl_digest_md5_send_initial_response (LmSASL *sasl, GHashTable *challenge)
+{
+ LmMessage *msg;
+ gchar *response;
+ gchar *response64;
+ int result;
+
+ response = sasl_md5_prepare_response(sasl, challenge);
+ if (response == NULL) {
+ return FALSE;
+ }
+
+ response64 = base64_encode ((gchar *)response, strlen(response));
+
+ msg = lm_message_new (NULL, LM_MESSAGE_TYPE_RESPONSE);
+ lm_message_node_set_attributes (msg->node,
+ "xmlns", XMPP_NS_SASL_AUTH,
+ NULL);
+ lm_message_node_set_value (msg->node, response64);
+
+ result = lm_connection_send (sasl->connection, msg, NULL);
+
+ g_free (response);
+ g_free (response64);
+ lm_message_unref (msg);
+
+ if (!result) {
+ return FALSE;
+ }
+
+ sasl->state = SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE;
+
+ return TRUE;
+}
+
+static gboolean
+sasl_digest_md5_check_server_response(LmSASL *sasl, GHashTable *challenge)
+{
+ LmMessage *msg;
+ const gchar *rspauth;
+ int result;
+
+ rspauth = g_hash_table_lookup (challenge, "rspauth");
+ if (rspauth == NULL) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ "%s: server sent an invalid reply (no rspauth)\n",
+ G_STRFUNC);*/
+ lm_verbose("%s: server sent an invalid reply (no rspauth)\n",G_STRFUNC);
+
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ TRUE, "server error");
+ }
+ return FALSE;
+ }
+
+ if (strcmp (sasl->digest_md5_rspauth, rspauth) != 0) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ "%s: server sent an invalid reply (rspauth not matching)\n",
+ G_STRFUNC);*/
+ lm_verbose("%s: server sent an invalid reply (rspauth not matching)\n",
+ G_STRFUNC);
+
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ TRUE, "server error");
+ }
+ return FALSE;
+ }
+
+ msg = lm_message_new (NULL, LM_MESSAGE_TYPE_RESPONSE);
+ lm_message_node_set_attributes (msg->node,
+ "xmlns", XMPP_NS_SASL_AUTH,
+ NULL);
+
+ result = lm_connection_send (sasl->connection, msg, NULL);
+ lm_message_unref (msg);
+
+ if (!result) {
+ g_warning ("Failed to send SASL response\n");
+ return FALSE;
+ }
+
+ sasl->state = SASL_AUTH_STATE_DIGEST_MD5_SENT_FINAL_RESPONSE;
+
+ return TRUE;
+}
+
+static gboolean
+sasl_digest_md5_handle_challenge (LmSASL *sasl, LmMessageNode *node)
+{
+ const gchar *encoded;
+ gchar *challenge;
+ gsize len;
+ GHashTable *h;
+
+ encoded = lm_message_node_get_value (node);
+ if (!encoded) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: got empty challenge!", G_STRFUNC);*/
+ lm_verbose("[sasl_digest_md5_handle_challenge]: %s: got empty challenge!", G_STRFUNC);
+ return FALSE;
+ }
+
+ challenge = (gchar *) base64_decode (encoded, &len);
+ h = sasl_digest_md5_challenge_to_hash (challenge);
+ g_free(challenge);
+
+ if (!h) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: server sent an invalid challenge", G_STRFUNC);*/
+ lm_verbose("[sasl_digest_md5_handle_challenge]: %s: server sent an invalid challenge", G_STRFUNC);
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "server error");
+ }
+ return FALSE;
+ }
+
+ switch (sasl->state) {
+ case SASL_AUTH_STATE_DIGEST_MD5_STARTED:
+ sasl_digest_md5_send_initial_response (sasl, h);
+ break;
+ case SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE:
+ sasl_digest_md5_check_server_response (sasl, h);
+ break;
+ default:
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: server sent a challenge at the wrong time",
+ G_STRFUNC);*/
+ lm_verbose( "[sasl_digst_md5_handle_challenge]: %s: server sent a challenge at the wrong time",
+ G_STRFUNC);
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "server error");
+ }
+
+ return FALSE;
+ }
+
+ g_hash_table_destroy(h);
+
+ return TRUE;
+}
+
+static LmHandlerResult
+sasl_challenge_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmSASL *sasl;
+ const gchar *ns;
+
+ ns = lm_message_node_get_attribute (message->node, "xmlns");
+ if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ sasl = (LmSASL *) user_data;
+
+ switch (sasl->auth_type) {
+ case AUTH_TYPE_PLAIN:
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ "%s: server sent challenge for PLAIN mechanism",
+ G_STRFUNC);*/
+ lm_verbose("[sasl_challenge_cb]: %s: server sent challenge for PLAIN mechanism",G_STRFUNC);
+
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "server error");
+ }
+ break;
+ case AUTH_TYPE_DIGEST:
+ sasl_digest_md5_handle_challenge (sasl, message->node);
+ break;
+ default:
+ g_warning ("Wrong auth type");
+ break;
+ }
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(connection);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static LmHandlerResult
+sasl_success_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmSASL *sasl;
+ const gchar *ns;
+
+ ns = lm_message_node_get_attribute (message->node, "xmlns");
+ if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ sasl = (LmSASL *) user_data;
+
+ switch (sasl->auth_type) {
+ case AUTH_TYPE_PLAIN:
+ if (sasl->state != SASL_AUTH_STATE_PLAIN_STARTED) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: server sent success before finishing auth",
+ G_STRFUNC);*/
+ lm_verbose("[sasl_success_cb]: %s: server sent success before finishing auth", G_STRFUNC);
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "server error");
+ }
+ }
+ break;
+ case AUTH_TYPE_DIGEST:
+ if (sasl->state != SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE &&
+ sasl->state != SASL_AUTH_STATE_DIGEST_MD5_SENT_FINAL_RESPONSE) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: server sent success before finishing auth",
+ G_STRFUNC);*/
+ lm_verbose("[sasl_success_cb]: %s: server sent success before finishing auth", G_STRFUNC);
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection,
+ FALSE, "server error");
+ }
+ }
+ break;
+ default:
+ g_warning ("Wrong auth type");
+ break;
+ }
+
+/* g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: SASL authentication successful", G_STRFUNC);*/
+ lm_verbose("[sasl_success_cb]: %s: SASL authentication successful", G_STRFUNC);
+
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection, TRUE, NULL);
+ }
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(connection);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+
+}
+
+static LmHandlerResult
+sasl_failure_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmSASL *sasl;
+ const gchar *ns;
+ const gchar *reason = "unknown reason";
+ lm_verbose("[sasl_failure_cb]: inside sasl_failure_cb\n");
+ ns = lm_message_node_get_attribute (message->node, "xmlns");
+ if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ sasl = (LmSASL *) user_data;
+
+ if (message->node->children) {
+ const gchar *r;
+
+ r = lm_message_node_get_value (message->node->children);
+ if (r) {
+ reason = r;
+ }
+ }
+ lm_verbose("[sasl_failure_cb]: %s: SASL authentication failed: %s\n", G_STRFUNC, reason);
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: SASL authentication failed: %s", G_STRFUNC, reason);*/
+
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection, FALSE, reason);
+ }
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(connection);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+
+static gboolean
+sasl_start (LmSASL *sasl)
+{
+ LmMessage *auth_msg;
+ gboolean result;
+ const char *mech = NULL;
+
+ auth_msg = lm_message_new (NULL, LM_MESSAGE_TYPE_AUTH);
+ lm_verbose("[sasl_start]: inside sasl_start\n");
+ if (sasl->auth_type == AUTH_TYPE_PLAIN) {
+ GString *str;
+ gchar *cstr;
+
+ str = g_string_new ("");
+
+ mech = "PLAIN";
+ sasl->state = SASL_AUTH_STATE_PLAIN_STARTED;
+ lm_verbose("[sasl_start]: inside sasl_start: auth type is PLAIN\n");
+ if (sasl->username == NULL || sasl->password == NULL) {
+ lm_verbose("[sasl_start]: no username or password provided\n");
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: no username or password provided",
+ G_STRFUNC);*/
+ if (sasl->handler) {
+ sasl->handler (sasl, sasl->connection, FALSE, "no username/password provided");
+ }
+
+ return FALSE;
+ }
+
+ g_string_append_c (str, '\0');
+ g_string_append (str, sasl->username);
+ g_string_append_c (str, '\0');
+ g_string_append (str, sasl->password);
+ cstr = base64_encode ((gchar *)str->str, str->len);
+
+ lm_message_node_set_value (auth_msg->node, cstr);
+
+ g_string_free (str, TRUE);
+ g_free (cstr);
+
+ /* Here we say the Google magic word. Bad Google. */
+ lm_message_node_set_attributes (auth_msg->node,
+ "xmlns:ga", "http://www.google.com/talk/protocol/auth",
+ "ga:client-uses-full-bind-result", "true",
+ NULL);
+
+ }
+ else if (sasl->auth_type == AUTH_TYPE_DIGEST) {
+ mech = "DIGEST-MD5";
+ sasl->state = SASL_AUTH_STATE_DIGEST_MD5_STARTED;
+ }
+
+ lm_message_node_set_attributes (auth_msg->node,
+ "xmlns", XMPP_NS_SASL_AUTH,
+ "mechanism", mech,
+ NULL);
+
+ result = lm_connection_send (sasl->connection, auth_msg, NULL);
+ lm_message_unref (auth_msg);
+
+ if (!result) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+sasl_set_auth_type (LmSASL *sasl, LmMessageNode *mechanisms)
+{
+ LmMessageNode *m;
+ const gchar *ns;
+
+ sasl->auth_type = 0;
+ lm_verbose("[sasl_set_auth_type]: inside sasl_set_auth_type\n");
+ ns = lm_message_node_get_attribute (mechanisms, "xmlns");
+ if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) {
+ return FALSE;
+ }
+
+ for (m = mechanisms->children; m; m = m->next) {
+ const gchar *name;
+
+ name = lm_message_node_get_value (m);
+
+ if (!name) {
+ continue;
+ }
+ if (strcmp (name, "PLAIN") == 0) {
+ sasl->auth_type |= AUTH_TYPE_PLAIN;
+ continue;
+ }
+ if (strcmp (name, "DIGEST-MD5") == 0) {
+ sasl->auth_type |= AUTH_TYPE_DIGEST;
+ continue;
+ }
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: unknown SASL auth mechanism: %s", G_STRFUNC, name);*/
+ lm_verbose ("[sasl_set_auth_type]: %s: unknown SASL auth mechanism: %s", G_STRFUNC, name);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+sasl_authenticate (LmSASL *sasl)
+{
+ lm_verbose ("[sasl_authenticate]: inside sasl_authenticate\n");
+ if (sasl->auth_type == 0) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
+ "%s: no supported SASL auth mechanisms found",
+ G_STRFUNC);*/
+ lm_verbose ("[sasl_authenticate]: %s: no supported SASL auth mechanisms found",G_STRFUNC);
+
+ return FALSE;
+ }
+
+ /* Prefer DIGEST */
+ if (sasl->auth_type & AUTH_TYPE_DIGEST) {
+ sasl->auth_type = AUTH_TYPE_DIGEST;
+ return sasl_start (sasl);
+ }
+ else if (sasl->auth_type & AUTH_TYPE_PLAIN) {
+ sasl->auth_type = AUTH_TYPE_PLAIN;
+ return sasl_start (sasl);
+ }
+
+ return FALSE;
+}
+
+static LmHandlerResult
+sasl_features_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmMessageNode *mechanisms;
+ LmSASL *sasl;
+
+ lm_verbose ("\n[sasl_feature_cb]: Stream features received\n\n");
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, "Stream features received\n");
+ mechanisms = lm_message_node_find_child (message->node, "mechanisms");
+ if (!mechanisms) {
+ gchar* childname = NULL;
+ lm_message_node_get_child(message->node,childname);
+ lm_verbose("[sasl_feature_cb]: Child name of stream:features %s\n", message->node->children->name);
+ lm_verbose("[sasl_feature_cb]: Child pointer of stream:features %u\n", message->node->children);
+ lm_verbose ("[sasl_feature_cb]: mechanisms empty:LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS \n");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+ lm_verbose("[sasl_features_cb]: Mechanisms not null\n");
+
+ sasl = (LmSASL *) user_data;
+ sasl->features_received = TRUE;
+
+ sasl_set_auth_type (sasl, mechanisms);
+
+ if (sasl->start_auth) {
+ lm_verbose ("[sasl_feature_cb]: Going to call sasl_authenticate\n");
+ sasl_authenticate (sasl);
+ }
+ UNUSED_FORMAL_PARAM(handler);
+ UNUSED_FORMAL_PARAM(connection);
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+LmSASL *
+lm_sasl_new (LmConnection *connection)
+{
+ LmSASL *sasl;
+
+ sasl = g_new0 (LmSASL, 1);
+
+ sasl->connection = connection;
+ sasl->features_received = FALSE;
+ sasl->start_auth = FALSE;
+
+ sasl->features_cb = lm_message_handler_new (sasl_features_cb,
+ sasl,
+ NULL);
+ lm_verbose ("[lm_sasl_new]: inside \n");
+ lm_connection_register_message_handler (connection,
+ sasl->features_cb,
+ LM_MESSAGE_TYPE_STREAM_FEATURES,
+ LM_HANDLER_PRIORITY_LAST);
+ return sasl;
+}
+
+void
+lm_sasl_authenticate (LmSASL *sasl,
+ const gchar *username,
+ const gchar *password,
+ const gchar *server,
+ LmSASLResultHandler handler)
+{
+ sasl->username = g_strdup (username);
+ sasl->password = g_strdup (password);
+ sasl->server = g_strdup (server);
+ sasl->handler = handler;
+
+ sasl->challenge_cb = lm_message_handler_new (sasl_challenge_cb,
+ sasl,
+ NULL);
+ lm_connection_register_message_handler (sasl->connection,
+ sasl->challenge_cb,
+ LM_MESSAGE_TYPE_CHALLENGE,
+ LM_HANDLER_PRIORITY_FIRST);
+
+ sasl->success_cb = lm_message_handler_new (sasl_success_cb,
+ sasl,
+ NULL);
+ lm_connection_register_message_handler (sasl->connection,
+ sasl->success_cb,
+ LM_MESSAGE_TYPE_SUCCESS,
+ LM_HANDLER_PRIORITY_FIRST);
+
+ sasl->failure_cb = lm_message_handler_new (sasl_failure_cb,
+ sasl,
+ NULL);
+ lm_connection_register_message_handler (sasl->connection,
+ sasl->failure_cb,
+ LM_MESSAGE_TYPE_FAILURE,
+ LM_HANDLER_PRIORITY_FIRST);
+
+ if (sasl->features_received) {
+ lm_verbose("[lm_sasl_authenticate]: calling sasl_authenticate\n");
+ sasl_authenticate (sasl);
+ } else {
+ sasl->start_auth = TRUE;
+ }
+}
+
+void
+lm_sasl_free (LmSASL *sasl)
+{
+ g_return_if_fail (sasl != NULL);
+
+ g_free (sasl->username);
+ g_free (sasl->password);
+ g_free (sasl->server);
+
+ if (sasl->features_cb) {
+ lm_connection_unregister_message_handler (sasl->connection,
+ sasl->features_cb,
+ LM_MESSAGE_TYPE_STREAM_FEATURES);
+ }
+
+ if (sasl->challenge_cb) {
+ lm_connection_unregister_message_handler (sasl->connection,
+ sasl->challenge_cb,
+ LM_MESSAGE_TYPE_CHALLENGE);
+ }
+
+ if (sasl->success_cb) {
+ lm_connection_unregister_message_handler (sasl->connection,
+ sasl->success_cb,
+ LM_MESSAGE_TYPE_SUCCESS);
+ }
+
+ if (sasl->failure_cb) {
+ lm_connection_unregister_message_handler (sasl->connection,
+ sasl->failure_cb,
+ LM_MESSAGE_TYPE_FAILURE);
+ }
+
+ g_free (sasl);
+}
+
+
+void
+lm_sasl_get_auth_params (LmSASL *sasl, const gchar **username,
+ const gchar **password)
+{
+ *username = sasl->username;
+ *password = sasl->password;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-sha.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,635 @@
+/*-
+ * Copyright (c) 2001, 2002 Allan Saddi <allan@saddi.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/*
+ * Define WORDS_BIGENDIAN if compiling on a big-endian architecture.
+ *
+ * Define SHA1_TEST to test the implementation using the NIST's
+ * sample messages. The output should be:
+ *
+ * a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d
+ * 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1
+ * 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <stdio.h>
+#include <glib.h>
+
+#include "lm-sha.h"
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+GET_STATIC_ARRAY_FROM_TLS(ret_val, lm_sha, gchar)
+ #define ret_val (GET_WSD_VAR_NAME(ret_val, lm_sha, s)())
+#endif
+
+
+
+#define SHA1_HASH_SIZE 20
+
+/* Hash size in 32-bit words */
+#define SHA1_HASH_WORDS 5
+
+struct _SHA1Context {
+ guint64 totalLength;
+ guint32 hash[SHA1_HASH_WORDS];
+ guint32 bufferLength;
+ union {
+ guint32 words[16];
+ guint8 bytes[64];
+ } buffer;
+};
+
+typedef struct _SHA1Context SHA1Context;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static void SHA1Init (SHA1Context *sc);
+static void SHA1Update (SHA1Context *sc, const void *udata, guint32 len);
+static void SHA1Final (SHA1Context *sc, guint8 hash[SHA1_HASH_SIZE]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* !lint */
+
+#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
+
+#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define F_20_39(x, y, z) ((x) ^ (y) ^ (z))
+#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
+#define F_60_79(x, y, z) ((x) ^ (y) ^ (z))
+
+#define DO_ROUND(F, K) { \
+ temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \
+ e = d; \
+ d = c; \
+ c = ROTL(b, 30); \
+ b = a; \
+ a = temp; \
+}
+
+#define K_0_19 0x5a827999L
+#define K_20_39 0x6ed9eba1L
+#define K_40_59 0x8f1bbcdcL
+#define K_60_79 0xca62c1d6L
+
+#ifndef RUNTIME_ENDIAN
+
+#ifdef WORDS_BIGENDIAN
+
+#define BYTESWAP(x) (x)
+#define BYTESWAP64(x) (x)
+
+#else /* WORDS_BIGENDIAN */
+
+#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
+ (ROTL((x), 8) & 0x00ff00ffL))
+#define BYTESWAP64(x) _byteswap64(x)
+
+static inline guint64 _byteswap64(guint64 x)
+{
+ guint32 a = x >> 32;
+ guint32 b = (guint32) x;
+ return ((guint64) BYTESWAP(b) << 32) | (guint64) BYTESWAP(a);
+}
+
+#endif /* WORDS_BIGENDIAN */
+
+#else /* !RUNTIME_ENDIAN */
+
+static int littleEndian;
+
+#define BYTESWAP(x) _byteswap(x)
+#define BYTESWAP64(x) _byteswap64(x)
+
+#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
+ (ROTL((x), 8) & 0x00ff00ffL))
+#define _BYTESWAP64(x) __byteswap64(x)
+
+static inline guint64 __byteswap64(guint64 x)
+{
+ guint32 a = x >> 32;
+ guint32 b = (guint32) x;
+ return ((guint64) _BYTESWAP(b) << 32) | (guint64) _BYTESWAP(a);
+}
+
+static inline guint32 _byteswap(guint32 x)
+{
+ if (!littleEndian)
+ return x;
+ else
+ return _BYTESWAP(x);
+}
+
+static inline guint64 _byteswap64(guint64 x)
+{
+ if (!littleEndian)
+ return x;
+ else
+ return _BYTESWAP64(x);
+}
+
+static inline void setEndian(void)
+{
+ union {
+ guint32 w;
+ guint8 b[4];
+ } endian;
+
+ endian.w = 1L;
+ littleEndian = endian.b[0] != 0;
+}
+
+#endif /* !RUNTIME_ENDIAN */
+
+static const guint8 padding[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static void
+SHA1Init (SHA1Context *sc)
+{
+#ifdef RUNTIME_ENDIAN
+ setEndian ();
+#endif /* RUNTIME_ENDIAN */
+
+#ifdef G_OS_WIN32
+ sc->totalLength = 0L;
+#else
+ sc->totalLength = 0LL;
+#endif
+ sc->hash[0] = 0x67452301L;
+ sc->hash[1] = 0xefcdab89L;
+ sc->hash[2] = 0x98badcfeL;
+ sc->hash[3] = 0x10325476L;
+ sc->hash[4] = 0xc3d2e1f0L;
+ sc->bufferLength = 0L;
+}
+
+static void
+burnStack (int size)
+{
+ char buf[128];
+
+ memset (buf, 0, sizeof (buf));
+ size -= sizeof (buf);
+ if (size > 0)
+ burnStack (size);
+}
+
+static void
+SHA1Guts (SHA1Context *sc, const guint32 *cbuf)
+{
+ guint32 buf[80];
+ guint32 *W, *W3, *W8, *W14, *W16;
+ guint32 a, b, c, d, e, temp;
+ int i;
+
+ W = buf;
+
+ for (i = 15; i >= 0; i--) {
+ *(W++) = BYTESWAP(*cbuf);
+ cbuf++;
+ }
+
+ W16 = &buf[0];
+ W14 = &buf[2];
+ W8 = &buf[8];
+ W3 = &buf[13];
+
+ for (i = 63; i >= 0; i--) {
+ *W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++);
+ *W = ROTL(*W, 1);
+ W++;
+ }
+
+ a = sc->hash[0];
+ b = sc->hash[1];
+ c = sc->hash[2];
+ d = sc->hash[3];
+ e = sc->hash[4];
+
+ W = buf;
+
+#ifndef SHA1_UNROLL
+#define SHA1_UNROLL 20
+#endif /* !SHA1_UNROLL */
+
+#if SHA1_UNROLL == 1
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_0_19, K_0_19);
+
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_20_39, K_20_39);
+
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_40_59, K_40_59);
+
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_60_79, K_60_79);
+#elif SHA1_UNROLL == 2
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 4
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 5
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 10
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 20
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+#else /* SHA1_UNROLL */
+#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20!
+#endif
+
+ sc->hash[0] += a;
+ sc->hash[1] += b;
+ sc->hash[2] += c;
+ sc->hash[3] += d;
+ sc->hash[4] += e;
+}
+
+static void
+SHA1Update (SHA1Context *sc, const void *udata, guint32 len)
+{
+ guint32 bufferBytesLeft;
+ guint32 bytesToCopy;
+ int needBurn = 0;
+ guint8 *data = (guint8 *)udata;
+
+#ifdef SHA1_FAST_COPY
+ if (sc->bufferLength) {
+ bufferBytesLeft = 64L - sc->bufferLength;
+
+ bytesToCopy = bufferBytesLeft;
+ if (bytesToCopy > len)
+ bytesToCopy = len;
+
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy);
+
+ sc->totalLength += bytesToCopy * 8L;
+
+ sc->bufferLength += bytesToCopy;
+ data += bytesToCopy;
+ len -= bytesToCopy;
+
+ if (sc->bufferLength == 64L) {
+ SHA1Guts (sc, sc->buffer.words);
+ needBurn = 1;
+ sc->bufferLength = 0L;
+ }
+ }
+
+ while (len > 63) {
+ sc->totalLength += 512L;
+
+ SHA1Guts (sc, data);
+ needBurn = 1;
+
+ data += 64L;
+ len -= 64L;
+ }
+
+ if (len) {
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, len);
+
+ sc->totalLength += len * 8L;
+
+ sc->bufferLength += len;
+ }
+#else /* SHA1_FAST_COPY */
+ while (len) {
+ bufferBytesLeft = 64L - sc->bufferLength;
+
+ bytesToCopy = bufferBytesLeft;
+ if (bytesToCopy > len)
+ bytesToCopy = len;
+
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy);
+
+ sc->totalLength += bytesToCopy * 8L;
+
+ sc->bufferLength += bytesToCopy;
+ data += bytesToCopy;
+ len -= bytesToCopy;
+
+ if (sc->bufferLength == 64L) {
+ SHA1Guts (sc, sc->buffer.words);
+ needBurn = 1;
+ sc->bufferLength = 0L;
+ }
+ }
+#endif /* SHA1_FAST_COPY */
+
+ if (needBurn)
+ burnStack (sizeof (guint32[86]) + sizeof (guint32 *[5]) + sizeof (int));
+}
+
+static void
+SHA1Final (SHA1Context *sc, guint8 hash[SHA1_HASH_SIZE])
+{
+ guint32 bytesToPad;
+ guint64 lengthPad;
+ int i;
+
+ bytesToPad = 120L - sc->bufferLength;
+ if (bytesToPad > 64L)
+ bytesToPad -= 64L;
+
+ lengthPad = BYTESWAP64(sc->totalLength);
+
+ SHA1Update (sc, padding, bytesToPad);
+ SHA1Update (sc, &lengthPad, 8L);
+
+ if (hash) {
+ for (i = 0; i < SHA1_HASH_WORDS; i++) {
+#ifdef SHA1_FAST_COPY
+ *((guint32 *) hash) = BYTESWAP(sc->hash[i]);
+#else /* SHA1_FAST_COPY */
+ hash[0] = (guint8) (sc->hash[i] >> 24);
+ hash[1] = (guint8) (sc->hash[i] >> 16);
+ hash[2] = (guint8) (sc->hash[i] >> 8);
+ hash[3] = (guint8) sc->hash[i];
+#endif /* SHA1_FAST_COPY */
+ hash += 4;
+ }
+ }
+}
+
+#ifdef G_OS_WIN32
+#define snprintf _snprintf
+#endif
+
+const gchar *
+lm_sha_hash (const gchar *str)
+{
+#ifndef EMULATOR
+ static gchar ret_val[41];
+#endif
+ SHA1Context ctx;
+ guint8 hash[SHA1_HASH_SIZE];
+ gchar *ch;
+ guint i;
+
+ SHA1Init (&ctx);
+ SHA1Update (&ctx, str, strlen (str));
+ SHA1Final (&ctx, hash);
+
+ ch = ret_val;
+
+ for (i = 0; i < SHA1_HASH_SIZE; ++i) {
+ snprintf (ch, 3, "%02x", hash[i]);
+ ch += 2;
+ }
+
+ return (const gchar *) ret_val;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-sock.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,392 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+//#include <glib.h>
+//#include <glib/gi18n.h>
+
+#ifndef G_OS_WIN32
+//#include <libc/netinet/net_types.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+//#include <libc/netinet/ip.h>
+//#include <libc/netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+// hack - to compile without the error of n_long not defined
+#define LM_SHUTDOWN SHUT_RDWR
+
+#else /* G_OS_WIN32 */
+
+#include <winsock2.h>
+#define LM_SHUTDOWN SD_BOTH
+
+#endif /* G_OS_WIN32 */
+
+#include "lm-internals.h"
+#include "lm-connection.h"
+#include "lm-sock.h"
+#include "lm-debug.h"
+
+#define IPV6_MAX_ADDRESS_LEN 46 /* 45 + '\0' */
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+
+GET_GLOBAL_VAR_FROM_TLS(initialised,lm_sock,gboolean)
+ #define initialised (*GET_WSD_VAR_NAME(initialised,lm_sock,g)())
+
+#else
+static gboolean initialised = FALSE;
+#endif
+gboolean
+_lm_sock_library_init (void)
+{
+#ifdef G_OS_WIN32
+ WORD version;
+ WSADATA data;
+ int error;
+#endif /* G_OS_WIN32 */
+
+ if (initialised) {
+ return TRUE;
+ }
+
+ lm_verbose ("Socket library initialising...\n");
+
+#ifdef G_OS_WIN32
+ lm_verbose ("Checking for winsock 2.0 or above...\n");
+
+ version = MAKEWORD (2, 0);
+
+ error = WSAStartup (version, &data);
+ if (error != 0) {
+ g_printerr ("WSAStartup() failed, error:%d\n", error);
+ return FALSE;
+ }
+
+ /* Confirm that the WinSock DLL supports 2.0.
+ * Note that if the DLL supports versions greater
+ * than 2.0 in addition to 2.0, it will still return
+ * 2.0 in wVersion since that is the version we
+ * requested.
+ */
+ if (LOBYTE (data.wVersion) != 2 ||
+ HIBYTE (data.wVersion) != 0) {
+ /* Tell the user that we could not find a usable
+ * WinSock DLL.
+ */
+ g_printerr ("Socket library version is not sufficient!\n");
+ WSACleanup ();
+ return FALSE;
+ }
+#endif /* G_OS_WIN32 */
+
+ initialised = TRUE;
+
+ return TRUE;
+}
+
+void
+_lm_sock_library_shutdown (void)
+{
+ if (!initialised) {
+ return;
+ }
+
+ lm_verbose ("Socket library shutting down...\n");
+
+#ifdef G_OS_WIN32
+ WSACleanup ();
+#endif /* G_OS_WIN32 */
+
+ initialised = FALSE;
+}
+
+void
+_lm_sock_set_blocking (LmSocketT sock,
+ gboolean block)
+{
+ int res;
+
+#ifndef G_OS_WIN32
+ res = fcntl (sock, F_SETFL, block ? 0 : O_NONBLOCK);
+#else /* G_OS_WIN32 */
+ u_long mode = (block ? 0 : 1);
+ res = ioctlsocket (sock, FIONBIO, &mode);
+#endif /* G_OS_WIN32 */
+
+ if (res != 0) {
+ // g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ // "Could not set connection to be %s\n",
+ // block ? "blocking" : "non-blocking");
+ lm_verbose ("[_lm_sock_set_blocking]: Could not set connection to be %s\n",
+ block ? "blocking" : "non-blocking");
+ }
+}
+
+void
+_lm_sock_shutdown (LmSocketT sock)
+{
+ shutdown (sock, LM_SHUTDOWN);
+}
+
+void
+_lm_sock_close (LmSocketT sock)
+{
+#ifndef G_OS_WIN32
+ close (sock);
+#else /* G_OS_WIN32 */
+ closesocket (sock);
+#endif /* G_OS_WIN32 */
+}
+
+LmSocketT
+_lm_sock_makesocket (int af,
+ int type,
+ int protocol)
+{
+ int optval = 1;
+ int sock_fd = -1;
+ unsigned int optlen = sizeof(optval);
+ sock_fd = socket (af, type, protocol);
+ setsockopt(sock_fd,SOL_SOCKET,SO_REUSEADDR|SO_REUSEPORT,&optval,optlen);
+
+ return (LmSocketT)sock_fd;
+}
+
+int
+_lm_sock_connect (LmSocketT sock,
+ const struct sockaddr *name,
+ int namelen)
+{
+ return connect (sock, name, namelen);
+}
+
+gboolean
+_lm_sock_is_blocking_error (int err)
+{
+#ifndef G_OS_WIN32
+ return (err == _LM_SOCK_EINPROGRESS);
+#else /* G_OS_WIN32 */
+ return (err == _LM_SOCK_EINPROGRESS ||
+ err == _LM_SOCK_EWOULDBLOCK ||
+ err == _LM_SOCK_EINVAL);
+#endif /* G_OS_WIN32 */
+}
+
+gboolean
+_lm_sock_is_blocking_success (int err)
+{
+ //Bug fixed by MRT from week 50 devlong onwards
+ return (err == _LM_SOCK_EEXISTS);
+ //Error EEXIST = 17 is not expected here. But It should be mrt error 107
+ //fix take later
+ //Before week 50 SDK
+ //return (err == _LM_SOCK_EALREADY || err == _LM_SOCK_EISCONN);
+}
+
+int
+_lm_sock_get_last_error (void)
+{
+#ifndef G_OS_WIN32
+ return errno;
+#else /* G_OS_WIN32 */
+ return WSAGetLastError ();
+#endif /* G_OS_WIN32 */
+}
+
+void
+_lm_sock_get_error (LmSocketT sock,
+ void *error,
+ socklen_t *len)
+{
+ getsockopt (sock, SOL_SOCKET, SO_ERROR, (void*) error, len);
+}
+
+const gchar *
+_lm_sock_get_error_str (int err)
+{
+#ifndef G_OS_WIN32
+ return strerror (err);
+#else /* G_OS_WIN32 */
+ switch (err) {
+ case WSAEINTR: return _("Connect interrupted and canceled");
+ case WSAEACCES: return _("Permission denied");
+ case WSAEFAULT: return _("Bad address");
+ case WSAEINVAL: return _("Invalid argument");
+ case WSAEMFILE: return _("Too many open sockets");
+ case WSAEWOULDBLOCK: return _("Resource temporarily unavailable");
+ case WSAEINPROGRESS: return _("Operation now in progress");
+ case WSAEALREADY: return _("Operation already in progress");
+ case WSAENOTSOCK: return _("Socket operation on nonsocket");
+ case WSAEDESTADDRREQ: return _("Destination address required");
+ case WSAEMSGSIZE: return _("Message too long");
+ case WSAEPROTOTYPE: return _("Protocol wrong type for socket");
+ case WSAENOPROTOOPT: return _("Bad protocol option");
+ case WSAEPROTONOSUPPORT: return _("Protocol not supported");
+ case WSAESOCKTNOSUPPORT: return _("Socket type not supported");
+ case WSAEOPNOTSUPP: return _("Operation not supported");
+ case WSAEPFNOSUPPORT: return _("Protocol family not supported");
+ case WSAEAFNOSUPPORT: return _("Address family not supported by protocol family");
+ case WSAEADDRINUSE: return _("Address already in use");
+ case WSAEADDRNOTAVAIL: return _("Can not assign requested address");
+ case WSAENETDOWN: return _("Network is down");
+ case WSAENETUNREACH: return _("Network is unreachable");
+ case WSAENETRESET: return _("Network dropped connection on reset");
+ case WSAECONNABORTED: return _("Software caused connection abort");
+ case WSAECONNRESET: return _("Connection reset by peer");
+ case WSAENOBUFS: return _("No buffer space available");
+ case WSAEISCONN: return _("Socket is already connected");
+ case WSAENOTCONN: return _("Socket is not connected");
+ case WSAESHUTDOWN: return _("Can not send after socket shutdown");
+ case WSAETIMEDOUT: return _("Connection timed out");
+ case WSAECONNREFUSED: return _("Connection refused");
+ case WSAEHOSTDOWN: return _("Host is down");
+ case WSAEHOSTUNREACH: return _("No route to host");
+ case WSAEPROCLIM: return _("Too many processes");
+ case WSASYSNOTREADY: return _("Network subsystem is unavailable");
+ case WSAVERNOTSUPPORTED: return _("Winsock library version is out of range ");
+ case WSANOTINITIALISED: return _("Successful WSAStartup not yet performed");
+ case WSAEDISCON: return _("Graceful shutdown in progress");
+ case WSATYPE_NOT_FOUND: return _("Class type not found");
+ case WSAHOST_NOT_FOUND: return _("Host not found");
+ case WSATRY_AGAIN: return _("Nonauthoritative host not found");
+ case WSANO_RECOVERY: return _("This is a nonrecoverable error");
+ case WSANO_DATA: return _("Valid name, no data record of requested type");
+ case WSA_INVALID_HANDLE: return _("Specified event object handle is invalid");
+ case WSA_INVALID_PARAMETER: return _("One or more parameters are invalid");
+ case WSA_IO_INCOMPLETE: return _("Overlapped I/O event object no in signaled state");
+ case WSA_IO_PENDING: return _("Overlapped operations will complete later");
+ case WSA_NOT_ENOUGH_MEMORY: return _("Insufficient memory available");
+ case WSA_OPERATION_ABORTED: return _("Overlapped operation aborted");
+ /* os dependent */
+ case WSASYSCALLFAILURE: return _("System call failure");
+ }
+
+ return _("Unknown");
+#endif /* G_OS_WIN32 */
+}
+
+const gchar *
+_lm_sock_addrinfo_get_error_str (int err)
+{
+ switch (err) {
+ case EAI_AGAIN:
+ return ("The nameserver failed to return an "
+ "address, try again later");
+ case EAI_BADFLAGS:
+ return ("Internal error trying to obtain remote address");
+ case EAI_FAIL:
+ return ("The nameserver encountered errors "
+ "looking up this address");
+ /* EAI_NODATA is apparently missing on FreeBSD. On recent GNU libc,
+ * it requires _GNU_SOURCE to be defined; in the unlikely case that
+ * that GNU libc returns this value we'll return the default message */
+#ifdef EAI_NODATA
+ case EAI_NODATA:
+ return _("The remote host exists but no address "
+ "is available");
+#endif
+ case EAI_NONAME:
+ return ("The remote address is unknown");
+ case EAI_FAMILY:
+ case EAI_SERVICE:
+ case EAI_SOCKTYPE:
+ return ("The remote address is not obtainable "
+ "for that socket type.");
+ default:
+ break;
+ }
+
+ return ("The remote address could not be obtained ");
+}
+
+#ifdef USE_TCP_KEEPALIVES
+gboolean
+_lm_sock_set_keepalive (LmSocketT sock, int delay)
+{
+ int opt;
+
+ lm_verbose ("[_lm_sock_set_keepalive]: USE_TCP_KEEPALIVES Enabled\n");
+
+ opt = 1;
+ if (setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof (opt)) < 0) {
+ return FALSE;
+ }
+
+ //opt = 3; /* 3 keepalives before considering connection dead */
+ /*if (setsockopt (sock, IPPROTO_TCP, TCP_KEEPCNT, &opt, sizeof (opt)) < 0) {
+ return FALSE;
+ }
+
+ opt = delay;
+ if (setsockopt (sock, IPPROTO_TCP, TCP_KEEPIDLE, &opt, sizeof (opt)) < 0) {
+ return FALSE;
+ }
+
+ opt = delay;
+ if (setsockopt (sock, IPPROTO_TCP, TCP_KEEPINTVL, &opt, sizeof (opt)) < 0) {
+ return FALSE;
+ }*/
+ UNUSED_FORMAL_PARAM(delay);
+ return TRUE;
+}
+#endif /* USE_TCP_KEEPALIVES */
+
+gchar *
+_lm_sock_get_local_host (LmSocketT sock)
+{
+ struct sockaddr addr_info;
+ void *sock_addr;
+ socklen_t namelen;
+ char addrbuf[IPV6_MAX_ADDRESS_LEN];
+ const char *host;
+
+ namelen = sizeof (struct sockaddr);
+ if (getsockname (sock, &addr_info, &namelen)) {
+ return NULL;
+ }
+
+ switch (addr_info.sa_family) {
+ case AF_INET:
+
+ sock_addr = & (((struct sockaddr_in *) &addr_info)->sin_addr);
+ break;
+ case AF_INET6:
+ sock_addr = & (((struct sockaddr_in6 *) &addr_info)->sin6_addr);
+ break;
+ default:
+ return NULL;
+ }
+ /* inet_ntoa has been obsoleted in favour of inet_ntop */
+ host = inet_ntop (addr_info.sa_family,
+ sock_addr,
+ addrbuf,
+ IPV6_MAX_ADDRESS_LEN);
+
+ return g_strdup (host);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-socket.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1251 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ * and/or its subsidiary/subsidiaries. All rights reserved.
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <sys/types.h>
+
+/* Needed on Mac OS X */
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+/* Needed on Mac OS X */
+#if HAVE_ARPA_NAMESER_COMPAT_H
+#include <arpa/nameser_compat.h>
+#endif
+
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+#include "lm-debug.h"
+#include "lm-internals.h"
+#include "lm-misc.h"
+#include "lm-ssl.h"
+#include "lm-ssl-internals.h"
+#include "lm-proxy.h"
+#include "lm-socket.h"
+#include "lm-sock.h"
+#include "lm-error.h"
+
+#ifdef HAVE_ASYNCNS
+#include <asyncns.h>
+#define freeaddrinfo(x) asyncns_freeaddrinfo(x)
+#endif
+
+#define IN_BUFFER_SIZE 1024
+#define MIN_PORT 1
+#define MAX_PORT 65536
+//#define SRV_LEN 8192
+#define SRV_LEN 512 // check the actual value needed here! - meco
+
+struct _LmSocket {
+ LmConnection *connection;
+ GMainContext *context;
+
+ gchar *domain;
+ gchar *server;
+ guint port;
+
+ gboolean blocking;
+
+ LmSSL *ssl;
+ gboolean ssl_started;
+ LmProxy *proxy;
+
+ GIOChannel *io_channel;
+ GSource *watch_in;
+ GSource *watch_err;
+ GSource *watch_hup;
+
+ LmSocketT fd;
+
+ GSource *watch_connect;
+
+ gboolean cancel_open;
+
+ GSource *watch_out;
+ GString *out_buf;
+
+ LmConnectData *connect_data;
+
+ IncomingDataFunc data_func;
+ SocketClosedFunc closed_func;
+ ConnectResultFunc connect_func;
+ gpointer user_data;
+
+ guint ref_count;
+
+#ifdef HAVE_ASYNCNS
+ GSource *watch_resolv;
+ asyncns_query_t *resolv_query;
+ asyncns_t *asyncns_ctx;
+ GIOChannel *resolv_channel;
+#endif
+};
+
+static void socket_free (LmSocket *socket);
+static gboolean socket_do_connect (LmConnectData *connect_data);
+static gboolean socket_connect_cb (GIOChannel *source,
+ GIOCondition condition,
+ LmConnectData *connect_data);
+static gboolean socket_in_event (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket);
+static gboolean socket_hup_event (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket);
+static gboolean socket_error_event (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket);
+static gboolean socket_buffered_write_cb (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket);
+static gboolean socket_parse_srv_response (unsigned char *srv,
+ int srv_len,
+ gchar **out_server,
+ guint *out_port);
+static void socket_close_io_channel (GIOChannel *io_channel);
+
+static void
+socket_free (LmSocket *socket)
+{
+ g_free (socket->server);
+ g_free (socket->domain);
+
+ if (socket->ssl) {
+ lm_ssl_unref (socket->ssl);
+ }
+
+ if (socket->proxy) {
+ lm_proxy_unref (socket->proxy);
+ }
+
+ if (socket->out_buf) {
+ g_string_free (socket->out_buf, TRUE);
+ }
+
+ g_free (socket);
+}
+
+gint
+lm_socket_do_write (LmSocket *socket, const gchar *buf, gint len)
+{
+ gint b_written;
+ gint err;
+ if (socket->ssl_started) {
+ b_written = _lm_ssl_send (socket->ssl, buf, len);
+ } else {
+ GIOStatus io_status = G_IO_STATUS_AGAIN;
+ gsize bytes_written;
+
+ while (io_status == G_IO_STATUS_AGAIN) {
+ io_status = g_io_channel_write_chars (socket->io_channel,
+ buf, len,
+ &bytes_written,
+ NULL);
+ }
+
+ b_written = bytes_written;
+
+ if (io_status != G_IO_STATUS_NORMAL) {
+ b_written = -1;
+ }
+ }
+
+ err = _lm_sock_get_last_error ();
+ lm_verbose("[lm_socket_do_write]: socket write last error: %d\n\n",err);
+ return b_written;
+}
+
+static gboolean
+socket_read_incoming (LmSocket *socket,
+ gchar *buf,
+ gsize buf_size,
+ gsize *bytes_read,
+ gboolean *hangup,
+ gint *reason)
+{
+ GIOStatus status;
+
+ *hangup = FALSE;
+
+ if (socket->ssl_started) {
+ status = _lm_ssl_read (socket->ssl,
+ buf, buf_size - 1, bytes_read);
+ } else {
+ status = g_io_channel_read_chars (socket->io_channel,
+ buf, buf_size - 1,
+ bytes_read,
+ NULL);
+ }
+
+//added by prima
+ if (status != G_IO_STATUS_NORMAL ) {
+ switch (status) {
+ case G_IO_STATUS_EOF:
+ *reason = LM_DISCONNECT_REASON_HUP;
+ break;
+ case G_IO_STATUS_AGAIN:
+ /* No data readable but we didn't hangup */
+ return FALSE;
+ // break;
+ case G_IO_STATUS_ERROR:
+ *reason = LM_DISCONNECT_REASON_ERROR;
+ break;
+ default:
+ *reason = LM_DISCONNECT_REASON_UNKNOWN;
+ }
+
+ /* Notify connection_in_event that we hangup the connection */
+ *hangup = TRUE;
+
+ return FALSE;
+ }
+
+ if(*bytes_read>0)
+ {
+ buf[*bytes_read] = '\0';
+ return TRUE;
+ }
+
+ /* There is more data to be read */
+ return FALSE;
+ //return TRUE;
+}
+
+static gboolean
+socket_in_event (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket)
+{
+ gchar buf[IN_BUFFER_SIZE];
+ gsize bytes_read = 0;
+ gboolean read_anything = FALSE;
+ gboolean hangup = 0;
+ gint reason = 0;
+
+ if (!socket->io_channel) {
+ lm_verbose ( "[socket_in_event]:Error in io_channel\n");
+ return FALSE;
+ }
+
+ while (/*(condition & G_IO_IN) && */socket_read_incoming (socket, buf, IN_BUFFER_SIZE,
+ &bytes_read, &hangup, &reason)) {
+
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "\nRECV [%d]:\n",
+ // (int)bytes_read);
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ // "-----------------------------------\n");
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "'%s'\n", buf);
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ // "-----------------------------------\n");
+
+ lm_verbose ("\n[socket_in_event]: RECV [%d]:\n", (int)bytes_read);
+ lm_verbose ("-----------------------------------\n");
+ lm_verbose ("'%s'\n", buf);
+ lm_verbose ( "-----------------------------------\n");
+ lm_verbose ("Read: %d chars\n", (int)bytes_read);
+
+ (socket->data_func) (socket, buf, socket->user_data);
+
+ read_anything = TRUE;
+
+ //condition = g_io_channel_get_buffer_condition (socket->io_channel);
+ }
+
+ /* If we have read something, delay the hangup so that the data can be
+ * processed. */
+ if (hangup && !read_anything) {
+ (socket->closed_func) (socket, reason, socket->user_data);
+ lm_verbose ( "[socket_in_event]:Error in hangup && !read_anything\n");
+ return FALSE;
+ }
+lm_verbose ( "[socket_in_event]:Returning TRUE\n");
+ return TRUE;
+}
+
+static gboolean
+socket_hup_event (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket)
+{
+ lm_verbose ("HUP event: %d->'%s'\n",
+ condition, lm_misc_io_condition_to_str (condition));
+
+ if (!socket->io_channel) {
+ return FALSE;
+ }
+
+ (socket->closed_func) (socket, LM_DISCONNECT_REASON_HUP,
+ socket->user_data);
+
+ return TRUE;
+}
+
+static gboolean
+socket_error_event (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket)
+{
+ gint err =0;
+ lm_verbose ("[socket_error_event]: ERROR event: %d->'%s'\n",
+ condition, lm_misc_io_condition_to_str (condition));
+
+ err = _lm_sock_get_last_error ();
+ lm_verbose("[socket_error_event]: socket write last error: %d\n\n",err);
+ if (!socket->io_channel) {
+ return FALSE;
+ }
+
+ (socket->closed_func) (socket, LM_DISCONNECT_REASON_ERROR,
+ socket->user_data);
+
+ return TRUE;
+}
+
+static gboolean
+_lm_socket_ssl_init (LmSocket *socket, gboolean delayed)
+{
+ GError *error = NULL;
+ const gchar *ssl_verify_domain = NULL;
+
+ lm_verbose ("[_lm_socket_ssl_init] Setting up SSL...\n");
+
+ _lm_ssl_initialize (socket->ssl);
+
+#ifdef HAVE_GNUTLS
+ /* GNU TLS requires the socket to be blocking */
+ _lm_sock_set_blocking (socket->fd, TRUE);
+#endif
+
+ /* If we're using StartTLS, the correct thing is to verify against
+ * the domain. If we're using old SSL, we should verify against the
+ * hostname. */
+ if (delayed)
+ ssl_verify_domain = socket->domain;
+ else
+ ssl_verify_domain = socket->server;
+
+ if (!_lm_ssl_begin (socket->ssl, socket->fd, ssl_verify_domain, &error)) {
+ lm_verbose ("Could not begin SSL\n");
+
+ if (error) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "%s\n", error->message);
+ */
+ lm_verbose("[_lm_socket_ssl_init]: %s\n", error->message);
+ g_error_free (error);
+ }
+ lm_verbose("\n[_lm_socket_ssl_init]: shutting down the socket");
+ _lm_sock_shutdown (socket->fd);
+ _lm_sock_close (socket->fd);
+
+ if (!delayed && socket->connect_func) {
+ lm_verbose("\n[_lm_socket_ssl_init]: calling the socket connect callback if ssl begin failed");
+ (socket->connect_func) (socket, FALSE, socket->user_data);
+ }
+
+ return FALSE;
+ }
+
+#ifdef HAVE_GNUTLS
+ _lm_sock_set_blocking (socket->fd, FALSE);
+#endif
+
+ socket->ssl_started = TRUE;
+
+ return TRUE;
+}
+
+gboolean
+lm_socket_starttls (LmSocket *socket)
+{
+ g_return_val_if_fail (lm_ssl_get_use_starttls (socket->ssl) == TRUE, FALSE);
+
+ return _lm_socket_ssl_init (socket, TRUE);
+}
+
+
+
+void
+_lm_socket_succeeded (LmConnectData *connect_data)
+{
+ LmSocket *socket;
+
+ socket = connect_data->socket;
+
+ lm_verbose ("\n[_lm_socket_succeeded]:inside.. \n");
+ if (socket->watch_connect) {
+ g_source_destroy (socket->watch_connect);
+ socket->watch_connect = NULL;
+ }
+
+ /* Need some way to report error/success */
+ if (socket->cancel_open) {
+ lm_verbose ("Cancelling connection...\n");
+ if (socket->connect_func) {
+ (socket->connect_func) (socket, FALSE, socket->user_data);
+ }
+ return;
+ }
+
+ socket->fd = connect_data->fd;
+ socket->io_channel = connect_data->io_channel;
+
+ freeaddrinfo (connect_data->resolved_addrs);
+ socket->connect_data = NULL;
+ g_free (connect_data);
+
+ /* old-style ssl should be started immediately */
+ if (socket->ssl && (lm_ssl_get_use_starttls (socket->ssl) == FALSE)) {
+ if (!_lm_socket_ssl_init (socket, FALSE)) {
+ return;
+ }
+ }
+
+ socket->watch_in =
+ lm_misc_add_io_watch (socket->context,
+ socket->io_channel,
+ G_IO_IN,
+ (GIOFunc) socket_in_event,
+ socket);
+
+ /* FIXME: if we add these, we don't get ANY
+ * response from the server, this is to do with the way that
+ * windows handles watches, see bug #331214.
+ */
+#ifndef G_OS_WIN32
+ socket->watch_err =
+ lm_misc_add_io_watch (socket->context,
+ socket->io_channel,
+ G_IO_ERR,
+ (GIOFunc) socket_error_event,
+ socket);
+
+ socket->watch_hup =
+ lm_misc_add_io_watch (socket->context,
+ socket->io_channel,
+ G_IO_HUP,
+ (GIOFunc) socket_hup_event,
+ socket);
+#endif
+
+ if (socket->connect_func) {
+ (socket->connect_func) (socket, TRUE, socket->user_data);
+ }
+}
+
+gboolean
+_lm_socket_failed_with_error (LmConnectData *connect_data, int error)
+{
+ LmSocket *socket;
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Connection failed: %s (error %d)\n",
+ _lm_sock_get_error_str (error), error);*/
+ lm_verbose( "[_lm_socket_failed_with_error]: Connection failed: %s (error %d)\n",_lm_sock_get_error_str (error), error);
+
+ socket = lm_socket_ref (connect_data->socket);
+
+ connect_data->current_addr = connect_data->current_addr->ai_next;
+
+ if (socket->watch_connect) {
+ g_source_destroy (socket->watch_connect);
+ socket->watch_connect = NULL;
+ }
+
+ if (connect_data->io_channel != NULL) {
+ socket_close_io_channel (connect_data->io_channel);
+ }
+
+ if (connect_data->current_addr == NULL) {
+ if (socket->connect_func) {
+ (socket->connect_func) (socket, FALSE, socket->user_data);
+ }
+ lm_verbose("\n\n[_lm_socket_failed_with_error]: connect_data->current_addr ==NULL");
+ /* if the user callback called connection_close(), this is already freed */
+ if (socket->connect_data != NULL) {
+ freeaddrinfo (connect_data->resolved_addrs);
+ socket->connect_data = NULL;
+ g_free (connect_data);
+ }
+ } else {
+ /* try to connect to the next host */
+ lm_verbose("\n\n[_lm_socket_failed_with_error]: !!!!Trying to connect to the next host after socket connect failed with error\n");
+ return socket_do_connect (connect_data);
+ }
+
+ lm_socket_unref(socket);
+
+ return FALSE;
+}
+
+gboolean
+_lm_socket_failed (LmConnectData *connect_data)
+{
+ return _lm_socket_failed_with_error (connect_data,
+ _lm_sock_get_last_error());
+}
+
+static gboolean
+socket_connect_cb (GIOChannel *source,
+ GIOCondition condition,
+ LmConnectData *connect_data)
+{
+ LmSocket *socket;
+ struct addrinfo *addr;
+ int err;
+ socklen_t len;
+ LmSocketT fd;
+ gboolean result = FALSE;
+
+ socket = lm_socket_ref (connect_data->socket);
+ addr = connect_data->current_addr;
+ fd = g_io_channel_unix_get_fd (source);
+ lm_verbose("\n[socket_connect_cb]: Inside socket_connect_cb\n");
+ if (condition == G_IO_ERR) {
+ len = sizeof (err);
+ _lm_sock_get_error (fd, &err, &len);
+ if (!_lm_sock_is_blocking_error (err)) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Connection failed.\n");*/
+ lm_verbose( "[socket_conect_cb]: Connection failed.\n");
+
+ /* error condition, but might be possible to recover
+ * from it (by connecting to the next host) */
+ if (!_lm_socket_failed_with_error (connect_data, err)) {
+ socket->watch_connect = NULL;
+ goto out;
+ }
+ }
+ }
+
+ if (_lm_connection_async_connect_waiting (socket->connection)) {
+ gint res;
+
+ fd = g_io_channel_unix_get_fd (source);
+ lm_verbose("\n[socket_conect_cb]: Async waiting calling _lm_sock_connect again\n");
+ res = _lm_sock_connect (fd, addr->ai_addr, (int)addr->ai_addrlen);
+ if (res < 0) {
+ err = _lm_sock_get_last_error ();
+ if (_lm_sock_is_blocking_success (err)) {
+ _lm_connection_set_async_connect_waiting (socket->connection, FALSE);
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Connection success (1).\n");*/
+ lm_verbose("[socket_connect_cb]: connection success");
+ _lm_socket_succeeded (connect_data);
+ }
+
+ if (_lm_connection_async_connect_waiting (socket->connection) &&
+ !_lm_sock_is_blocking_error (err)) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Connection failed.\n");*/
+ lm_verbose("[socket_conect_cb]: connection failed");
+ _lm_sock_close (connect_data->fd);
+ _lm_socket_failed_with_error (connect_data, err);
+
+ socket->watch_connect = NULL;
+ goto out;
+ }
+ }
+ } else {
+ /* for blocking sockets, G_IO_OUT means we are connected */
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Connection success (2).\n");*/
+ lm_verbose("[socket_conect_cb]: Connection success (2).\n");
+ _lm_socket_succeeded (connect_data);
+ }
+
+ result = TRUE;
+
+ out:
+ lm_socket_unref(socket);
+
+ return result;
+}
+
+static gboolean
+socket_do_connect (LmConnectData *connect_data)
+{
+ LmSocket *socket;
+ LmSocketT fd;
+ int res, err;
+ int port;
+ char name[NI_MAXHOST];
+ char portname[NI_MAXSERV];
+ struct addrinfo *addr;
+
+ socket = connect_data->socket;
+ addr = connect_data->current_addr;
+
+ if (socket->proxy) {
+ port = htons (lm_proxy_get_port (socket->proxy));
+ } else {
+ port = htons (socket->port);
+ }
+
+ ((struct sockaddr_in *) addr->ai_addr)->sin_port = port;
+
+ res = getnameinfo (addr->ai_addr,
+ (socklen_t)addr->ai_addrlen,
+ name, sizeof (name),
+ portname, sizeof (portname),
+ NI_NUMERICHOST | NI_NUMERICSERV);
+
+ if (res < 0) {
+ return _lm_socket_failed (connect_data);
+ }
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Trying %s port %s...\n", name, portname);*/
+ lm_verbose("[socket_do_connect]: Trying %s port %s...\n", name, portname);
+ lm_verbose("[socket_do_connect]: calling make socket\n");
+ fd = _lm_sock_makesocket (addr->ai_family,
+ addr->ai_socktype,
+ addr->ai_protocol);
+ lm_verbose("[socket_do_connet]: called make socket and fd");
+ lm_verbose("[socket_do_connect]: The value of FD is :%d",fd);
+ if (!_LM_SOCK_VALID (fd)) {
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Failed making socket, error:%d...\n",
+ _lm_sock_get_last_error ());*/
+ lm_verbose( "[socket_do_connect]: Failed making socket, error:[%d]...\n", _lm_sock_get_last_error ());
+
+ return _lm_socket_failed (connect_data);
+ }
+
+ /* Even though it says _unix_new(), it is supported by glib on
+ * win32 because glib does some cool stuff to find out if it
+ * can treat it as a FD or a windows SOCKET.
+ */
+ connect_data->fd = fd;
+ connect_data->io_channel = g_io_channel_unix_new (fd);
+
+ g_io_channel_set_encoding (connect_data->io_channel, NULL, NULL);
+ g_io_channel_set_buffered (connect_data->io_channel, FALSE);
+
+ //_lm_sock_set_blocking (connect_data->fd, socket->blocking);
+
+ if (socket->proxy) {
+ socket->watch_connect =
+ lm_misc_add_io_watch (socket->context,
+ connect_data->io_channel,
+ G_IO_OUT|G_IO_ERR,
+ (GIOFunc) _lm_proxy_connect_cb,
+ connect_data);
+ } else {
+ socket->watch_connect =
+ lm_misc_add_io_watch (socket->context,
+ connect_data->io_channel,
+ G_IO_OUT|G_IO_ERR,
+ (GIOFunc) socket_connect_cb,
+ connect_data);
+ }
+
+ _lm_connection_set_async_connect_waiting (socket->connection, !socket->blocking);
+ lm_verbose("\n[socket_do_connect]: calling _lm_sock_connect\n");
+ _lm_sock_set_blocking (connect_data->fd, TRUE); //prima
+ errno =0;
+ res = _lm_sock_connect (connect_data->fd,
+ addr->ai_addr, (int)addr->ai_addrlen);
+ err = _lm_sock_get_last_error ();
+ lm_verbose("[socket_do_connect]: socket connect last error: [%d]\n",err);
+ if (res < 0) {
+ //err = _lm_sock_get_last_error ();
+ lm_verbose("[socket_do_connect]: socket connect last error: %d\n",err);
+ if (!_lm_sock_is_blocking_error (err)) {
+ _lm_sock_close (connect_data->fd);
+ return _lm_socket_failed_with_error (connect_data, err);
+ }
+ }
+ _lm_sock_set_blocking (connect_data->fd, FALSE);//prima
+ return TRUE;
+}
+
+gboolean
+lm_socket_output_is_buffered (LmSocket *socket,
+ const gchar *buffer,
+ gint len)
+{
+ if (socket->out_buf) {
+ lm_verbose ("Appending %d bytes to output buffer\n", len);
+ g_string_append_len (socket->out_buf, buffer, len);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+lm_socket_setup_output_buffer (LmSocket *socket, const gchar *buffer, gint len)
+{
+ lm_verbose ("OUTPUT BUFFER ENABLED\n");
+
+ socket->out_buf = g_string_new_len (buffer, len);
+
+ socket->watch_out =
+ lm_misc_add_io_watch (socket->context,
+ socket->io_channel,
+ G_IO_OUT,
+ (GIOFunc) socket_buffered_write_cb,
+ socket);
+}
+
+static gboolean
+socket_buffered_write_cb (GIOChannel *source,
+ GIOCondition condition,
+ LmSocket *socket)
+{
+ gint b_written;
+ GString *out_buf;
+ /* FIXME: Do the writing */
+
+ out_buf = socket->out_buf;
+ if (!out_buf) {
+ /* Should not be possible */
+ return FALSE;
+ }
+
+ b_written = lm_socket_do_write (socket, out_buf->str, out_buf->len);
+
+ if (b_written < 0) {
+ (socket->closed_func) (socket, LM_DISCONNECT_REASON_ERROR,
+ socket->user_data);
+ return FALSE;
+ }
+
+ g_string_erase (out_buf, 0, (gsize) b_written);
+ if (out_buf->len == 0) {
+ lm_verbose ("Output buffer is empty, going back to normal output\n");
+
+ if (socket->watch_out) {
+ g_source_destroy (socket->watch_out);
+ socket->watch_out = NULL;
+ }
+
+ g_string_free (out_buf, TRUE);
+ socket->out_buf = NULL;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+socket_parse_srv_response (unsigned char *srv,
+ int srv_len,
+ gchar **out_server,
+ guint *out_port)
+{
+/* int qdcount;
+ int ancount;
+ int len;
+ const unsigned char *pos;
+ unsigned char *end;
+ HEADER *head;
+ char name[256];
+ char pref_name[256];
+ guint pref_port = 0;
+ guint pref_prio = 9999;
+
+ pref_name[0] = 0;
+
+ pos = srv + sizeof (HEADER);
+ end = srv + srv_len;
+ head = (HEADER *) srv;
+
+ qdcount = ntohs (head->qdcount);
+ ancount = ntohs (head->ancount);
+
+ // Ignore the questions
+ while (qdcount-- > 0 && (len = dn_expand (srv, end, pos, name, 255)) >= 0) {
+ g_assert (len >= 0);
+ pos += len + QFIXEDSZ;
+ }
+
+ // Parse the answers
+ while (ancount-- > 0 && (len = dn_expand (srv, end, pos, name, 255)) >= 0) {
+ // Ignore the initial string
+ uint16_t pref, weight, port;
+
+ g_assert (len >= 0);
+ pos += len;
+ // Ignore type, ttl, class and dlen
+ pos += 10;
+ GETSHORT (pref, pos);
+ GETSHORT (weight, pos);
+ GETSHORT (port, pos);
+
+ len = dn_expand (srv, end, pos, name, 255);
+ if (pref < pref_prio) {
+ pref_prio = pref;
+ strcpy (pref_name, name);
+ pref_port = port;
+ }
+ pos += len;
+ }
+
+ if (pref_name[0]) {
+ *out_server = g_strdup (pref_name);
+ *out_port = pref_port;
+ return TRUE;
+ } */
+ return FALSE;
+}
+
+static void
+socket_close_io_channel (GIOChannel *io_channel)
+{
+ gint fd;
+
+ g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Freeing up IOChannel and file descriptor\n");
+
+ fd = g_io_channel_unix_get_fd (io_channel);
+
+ g_io_channel_unref (io_channel);
+
+ _lm_sock_close (fd);
+}
+
+static void
+_lm_socket_create_phase1 (LmSocket *socket, unsigned char *srv_ans, int len);
+static void
+_lm_socket_create_phase2 (LmSocket *socket, struct addrinfo *ans);
+
+#ifdef HAVE_ASYNCNS
+#define PHASE_1 0
+#define PHASE_2 1
+
+static gboolean
+_lm_socket_resolver_done (GSource *source,
+ GIOCondition condition,
+ gpointer data);
+
+
+static void
+_asyncns_done (LmSocket *socket)
+{
+ if (socket->resolv_channel != NULL) {
+ g_io_channel_unref (socket->resolv_channel);
+ socket->resolv_channel = NULL;
+ }
+
+ if (socket->watch_resolv) {
+ g_source_destroy(socket->watch_resolv);
+ socket->watch_resolv = NULL;
+ }
+
+ if (socket->asyncns_ctx) {
+ asyncns_free (socket->asyncns_ctx);
+ socket->asyncns_ctx = NULL;
+ }
+
+ socket->resolv_query = NULL;
+}
+
+void _asyncns_cancel (LmSocket *socket)
+{
+ if (socket == NULL)
+ return;
+
+ if (socket->asyncns_ctx) {
+ if (socket->resolv_query)
+ asyncns_cancel (socket->asyncns_ctx, socket->resolv_query);
+
+ _asyncns_done (socket);
+ }
+}
+
+static gboolean
+_asyncns_prep (LmSocket *socket, GError **error)
+{
+ if (socket->asyncns_ctx) {
+ return TRUE;
+ }
+
+ socket->asyncns_ctx = asyncns_new (1);
+ if (socket->asyncns_ctx == NULL) {
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_FAILED,
+ "can't initialise libasyncns");
+ return FALSE;
+ }
+
+ socket->resolv_channel =
+ g_io_channel_unix_new (asyncns_fd (socket->asyncns_ctx));
+
+ socket->watch_resolv =
+ lm_misc_add_io_watch (socket->context,
+ socket->resolv_channel,
+ G_IO_IN,
+ (GIOFunc) _lm_socket_resolver_done,
+ socket);
+
+ return TRUE;
+}
+
+static gboolean
+_lm_socket_resolver_done (GSource *source,
+ GIOCondition condition,
+ gpointer data)
+{
+ LmSocket *socket = lm_socket_ref ((LmSocket *) data);
+ struct addrinfo *ans;
+ unsigned char *srv_ans;
+ int err;
+ gboolean result = FALSE;
+
+ /* process pending data */
+ asyncns_wait (socket->asyncns_ctx, FALSE);
+
+ if (!asyncns_isdone (socket->asyncns_ctx, socket->resolv_query)) {
+ result = TRUE;
+ } else {
+ switch ((guint) asyncns_getuserdata (socket->asyncns_ctx, socket->resolv_query)) {
+ case PHASE_1:
+ err = asyncns_res_done (socket->asyncns_ctx, socket->resolv_query, &srv_ans);
+ socket->resolv_query = NULL;
+ _lm_socket_create_phase1 (socket, (err <= 0) ? NULL : srv_ans, err);
+ result = TRUE;
+ break;
+ case PHASE_2:
+ err = asyncns_getaddrinfo_done (socket->asyncns_ctx, socket->resolv_query, &ans);
+ socket->resolv_query = NULL;
+ _lm_socket_create_phase2 (socket, (err) ? NULL : ans);
+ _asyncns_done (socket);
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+ }
+
+ lm_socket_unref(socket);
+
+ return result;
+}
+
+#endif
+
+static void
+_lm_socket_create_phase1 (LmSocket *socket,
+ unsigned char *srv_ans,
+ int len)
+{
+ const char *remote_addr;
+ LmConnectData *data;
+ struct addrinfo req;
+#ifndef HAVE_ASYNCNS
+ struct addrinfo *ans;
+ int err;
+#endif
+
+ if (srv_ans != NULL) {
+ gchar *new_server;
+ guint new_port;
+ gboolean result;
+ result = socket_parse_srv_response (srv_ans, len,
+ &new_server,
+ &new_port);
+ if (result == TRUE) {
+ g_free (socket->server);
+ socket->server = new_server;
+ socket->port = new_port;
+ }
+ }
+
+ /* If server wasn't specified and SRV failed, use domain */
+ if (!socket->server) {
+ lm_verbose ("SRV lookup failed, trying jid domain\n");
+ socket->server = g_strdup (socket->domain);
+ }
+
+ if (socket->proxy) {
+ remote_addr = lm_proxy_get_server (socket->proxy);
+ } else {
+ remote_addr = socket->server;
+ }
+
+ /*g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+ "Going to connect to %s%s:%u\n", (socket->proxy) ? "proxy " : "",
+ remote_addr, socket->port);*/
+ lm_verbose( "[_lm_socket_create_phase1]: Going to connect to %s%s:%u\n", (socket->proxy) ? "proxy " : "",
+ remote_addr, socket->port);
+
+ data = g_new0 (LmConnectData, 1);
+
+ data->socket = socket;
+ data->connection = socket->connection;
+ data->fd = -1;
+ socket->connect_data = data;
+
+ memset (&req, 0, sizeof(req));
+ req.ai_family = AF_UNSPEC;
+ req.ai_socktype = SOCK_STREAM;
+ req.ai_protocol = IPPROTO_TCP;
+
+#ifdef HAVE_ASYNCNS
+ if (!_asyncns_prep (socket, NULL))
+ return;
+
+ socket->resolv_query =
+ asyncns_getaddrinfo (socket->asyncns_ctx,
+ remote_addr,
+ NULL,
+ &req);
+
+ asyncns_setuserdata (socket->asyncns_ctx,
+ socket->resolv_query,
+ (gpointer) PHASE_2);
+#else
+ err = getaddrinfo (remote_addr, NULL, &req, &ans);
+ lm_verbose( "[_lm_socket_create_phase1]: after getaddrinfo : %u\n", err);
+ _lm_socket_create_phase2 (socket, (err) ? NULL : ans);
+ if (err != 0) {
+ return;
+ }
+#endif
+}
+
+static void
+_lm_socket_create_phase2 (LmSocket *socket, struct addrinfo *ans)
+{
+ if (ans == NULL) {
+ lm_verbose ("error while resolving, bailing out\n");
+ if (socket->connect_func) {
+ (socket->connect_func) (socket, FALSE, socket->user_data);
+ }
+ g_free (socket->connect_data);
+ socket->connect_data = NULL;
+ return;
+ }
+
+ socket->connect_data->resolved_addrs = ans;
+ socket->connect_data->current_addr = ans;
+
+ socket_do_connect (socket->connect_data);
+}
+
+LmSocket *
+lm_socket_create (GMainContext *context,
+ IncomingDataFunc data_func,
+ SocketClosedFunc closed_func,
+ ConnectResultFunc connect_func,
+ gpointer user_data,
+ LmConnection *connection,
+ gboolean blocking,
+ const gchar *server,
+ const gchar *domain,
+ guint port,
+ LmSSL *ssl,
+ LmProxy *proxy,
+ GError **error)
+{
+ LmSocket *socket;
+
+#ifndef HAVE_ASYNCNS
+ unsigned char srv_ans[SRV_LEN];
+ int len;
+#endif
+ lm_verbose ("[lm_socket_create]: inside..");
+
+ g_return_val_if_fail (domain != NULL, NULL);
+ g_return_val_if_fail ((port >= MIN_PORT && port <= MAX_PORT), NULL);
+ g_return_val_if_fail (data_func != NULL, NULL);
+ g_return_val_if_fail (closed_func != NULL, NULL);
+ g_return_val_if_fail (connect_func != NULL, NULL);
+
+
+ socket = g_new0 (LmSocket, 1);
+ lm_verbose ("[lm_socket_create]: after g_new0 ");
+
+ socket->ref_count = 1;
+
+ socket->connection = connection;
+ socket->domain = g_strdup (domain);
+ socket->server = g_strdup (server);
+ socket->port = port;
+ socket->cancel_open = FALSE;
+ socket->ssl = ssl;
+ socket->ssl_started = FALSE;
+ socket->proxy = NULL;
+ socket->blocking = blocking;
+
+ if (context) {
+ socket->context = g_main_context_ref (context);
+ }
+
+ if (proxy) {
+ socket->proxy = lm_proxy_ref (proxy);
+ }
+
+ if (!server) {
+ /*char *srv;
+ srv = g_strdup_printf ("_xmpp-client._tcp.%s", socket->domain);
+ lm_verbose ("Performing a SRV lookup for %s\n", srv);
+
+#ifdef HAVE_ASYNCNS
+ if (!_asyncns_prep (socket, error))
+ return NULL;
+
+ socket->resolv_query =
+ asyncns_res_query (socket->asyncns_ctx, srv, C_IN, T_SRV);
+ asyncns_setuserdata (socket->asyncns_ctx, socket->resolv_query, (gpointer) PHASE_1);
+#else
+ res_init ();
+
+ len = res_query (srv, C_IN, T_SRV, srv_ans, SRV_LEN);
+ _lm_socket_create_phase1 (socket, (len < 1) ? NULL : srv_ans, len);
+ g_free (srv);
+#endif*/
+ } else {
+ lm_verbose ("SRV lookup disabled for %s\n", socket->server);
+ _lm_socket_create_phase1 (socket, NULL, 0);
+ }
+
+ if (socket->connect_data == NULL) {
+ /* Open failed synchronously, probably a DNS lookup problem */
+ lm_socket_unref(socket);
+
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_FAILED,
+ "Failed to resolve server");
+
+ return NULL;
+ }
+
+
+ /* If the connection fails synchronously, we don't want to call the
+ * connect_func to indicate an error, we return an error indication
+ * instead. So, we delay saving the functions until after we know
+ * we are going to return success.
+ */
+ socket->data_func = data_func;
+ socket->closed_func = closed_func;
+ socket->connect_func = connect_func;
+ socket->user_data = user_data;
+
+ return socket;
+}
+
+void
+lm_socket_flush (LmSocket *socket)
+{
+ g_return_if_fail (socket != NULL);
+ g_return_if_fail (socket->io_channel != NULL);
+
+ g_io_channel_flush (socket->io_channel, NULL);
+}
+
+void
+lm_socket_close (LmSocket *socket)
+{
+ LmConnectData *data;
+ int ret = 0;
+ g_return_if_fail (socket != NULL);
+
+ if (socket->watch_connect) {
+ g_source_destroy (socket->watch_connect);
+ socket->watch_connect = NULL;
+ }
+
+ _lm_sock_close(socket->fd);
+ data = socket->connect_data;
+ ret = errno; lm_verbose("\n\n[lm_socket_close]: The errno after close fd is: %d",ret);
+ if (data) {
+ freeaddrinfo (data->resolved_addrs);
+ socket->connect_data = NULL;
+ g_free (data);
+ }
+
+ if (socket->io_channel) {
+ if (socket->watch_in) {
+ g_source_destroy (socket->watch_in);
+ socket->watch_in = NULL;
+ }
+
+ if (socket->watch_err) {
+ g_source_destroy (socket->watch_err);
+ socket->watch_err = NULL;
+ }
+
+ if (socket->watch_hup) {
+ g_source_destroy (socket->watch_hup);
+ socket->watch_hup = NULL;
+ }
+
+ if (socket->watch_out) {
+ g_source_destroy (socket->watch_out);
+ socket->watch_out = NULL;
+ }
+
+ socket_close_io_channel (socket->io_channel);
+
+ socket->io_channel = NULL;
+ socket->fd = -1;
+ }
+}
+
+gchar *
+lm_socket_get_local_host (LmSocket *socket)
+{
+ return _lm_sock_get_local_host (socket->fd);
+}
+
+LmSocket *
+lm_socket_ref (LmSocket *socket)
+{
+ g_return_val_if_fail (socket != NULL, NULL);
+
+ socket->ref_count++;
+
+ return socket;
+}
+
+void
+lm_socket_unref (LmSocket *socket)
+{
+ g_return_if_fail (socket != NULL);
+
+ socket->ref_count--;
+
+ if (socket->ref_count <= 0) {
+ socket_free (socket);
+ }
+}
+
+gboolean
+lm_socket_set_keepalive (LmSocket *socket, int delay)
+{
+#ifdef USE_TCP_KEEPALIVES
+ return _lm_sock_set_keepalive (socket->fd, delay);
+#else
+ return FALSE;
+#endif /* USE_TCP_KEEPALIVES */
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-ssl-base.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "lm-ssl-base.h"
+#include "lm-ssl-internals.h"
+
+void
+_lm_ssl_base_init (LmSSLBase *base,
+ const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ base->ref_count = 1;
+ base->func = ssl_function;
+ base->func_data = user_data;
+ base->data_notify = notify;
+ base->fingerprint[0] = '\0';
+
+ if (expected_fingerprint) {
+ base->expected_fingerprint = g_strdup (expected_fingerprint);
+ } else {
+ base->expected_fingerprint = NULL;
+ }
+
+ if (!base->func) {
+ /* If user didn't provide an SSL func the default will be used
+ * this function will always tell the connection to continue.
+ */
+ base->func = _lm_ssl_func_always_continue;
+ }
+}
+
+void
+_lm_ssl_base_free_fields (LmSSLBase *base)
+{
+ g_free (base->expected_fingerprint);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-ssl-generic.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,249 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include "lm-debug.h"
+#include "lm-ssl.h"
+#include "lm-ssl-base.h"
+#include "lm-ssl-internals.h"
+
+LmSSLResponse
+_lm_ssl_func_always_continue (LmSSL *ssl,
+ LmSSLStatus status,
+ gpointer user_data)
+{
+ UNUSED_FORMAL_PARAM(ssl);
+ UNUSED_FORMAL_PARAM(status);
+ UNUSED_FORMAL_PARAM(user_data);
+ return LM_SSL_RESPONSE_CONTINUE;;
+}
+
+/* Define the SSL functions as noops if we compile without support */
+#ifndef HAVE_SSL
+
+LmSSL *
+_lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ return NULL;
+}
+
+void
+_lm_ssl_initialize (LmSSL *ssl)
+{
+ /* NOOP */
+}
+
+gboolean
+_lm_ssl_begin (LmSSL *ssl,
+ gint fd,
+ const gchar *server,
+ GError **error)
+{
+ return TRUE;
+}
+
+GIOStatus
+_lm_ssl_read (LmSSL *ssl,
+ gchar *buf,
+ gint len,
+ gsize *bytes_read)
+{
+ /* NOOP */
+ *bytes_read = 0;
+
+ return G_IO_STATUS_EOF;
+}
+
+gboolean
+_lm_ssl_send (LmSSL *ssl, const gchar *str, gint len)
+{
+ /* NOOP */
+ return TRUE;
+}
+void
+_lm_ssl_close (LmSSL *ssl)
+{
+ /* NOOP */
+}
+
+void
+_lm_ssl_free (LmSSL *ssl)
+{
+ /* NOOP */
+}
+
+#endif /* HAVE_SSL */
+
+
+
+/**
+ * lm_ssl_new:
+ * @expected_fingerprint: The expected fingerprint. @ssl_function will be called if there is a mismatch. %NULL if you are not interested in this check.
+ * @ssl_function: Callback called to inform the user of a problem during setting up the SSL connection and how to proceed. If %NULL is passed the default function that always continues will be used.
+ * @user_data: Data sent with the callback.
+ * @notify: Function to free @user_dataa when the connection is finished. %NULL if @user_data should not be freed.
+ *
+ * Creates a new SSL struct, call #lm_connection_set_ssl to use it.
+ *
+ * Return value: A new #LmSSL struct.
+ **/
+EXPORT_C LmSSL *
+lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ /* The implementation of this function will be different depending
+ * on which implementation is used
+ */
+ return _lm_ssl_new (expected_fingerprint,
+ ssl_function, user_data, notify);
+}
+
+/**
+ * lm_ssl_is_supported:
+ *
+ * Checks whether Loudmouth supports SSL or not.
+ *
+ * Return value: #TRUE if this installation of Loudmouth supports SSL, otherwise returns #FALSE.
+ **/
+EXPORT_C gboolean
+lm_ssl_is_supported (void)
+{
+#ifdef HAVE_SSL
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+
+/**
+ * lm_ssl_get_fingerprint:
+ * @ssl: an #LmSSL
+ *
+ * Returns the MD5 fingerprint of the remote server's certificate.
+ *
+ * Return value: A 16-byte array representing the fingerprint or %NULL if unknown.
+ **/
+EXPORT_C const gchar *
+lm_ssl_get_fingerprint (LmSSL *ssl)
+{
+ g_return_val_if_fail (ssl != NULL, NULL);
+
+ return LM_SSL_BASE(ssl)->fingerprint;
+}
+
+/**
+ * lm_ssl_ref:
+ * @ssl: an #LmSSL
+ *
+ * Adds a reference to @ssl.
+ *
+ * Return value: the ssl
+ **/
+EXPORT_C LmSSL *
+lm_ssl_ref (LmSSL *ssl)
+{
+ g_return_val_if_fail (ssl != NULL, NULL);
+
+ LM_SSL_BASE(ssl)->ref_count++;
+
+ return ssl;
+}
+
+/**
+ * lm_ssl_use_starttls:
+ * @ssl: an #LmSSL
+ *
+ * Set whether STARTTLS should be used.
+ **/
+EXPORT_C void
+lm_ssl_use_starttls (LmSSL *ssl,
+ gboolean use_starttls,
+ gboolean require_starttls)
+{
+ LmSSLBase *base;
+
+ base = LM_SSL_BASE (ssl);
+ base->use_starttls = use_starttls;
+ base->require_starttls = require_starttls;
+}
+
+/**
+ * lm_ssl_get_use_starttls:
+ *
+ * Return value: TRUE is @ssl is configured to use STARTTLS.
+ **/
+gboolean
+lm_ssl_get_use_starttls (LmSSL *ssl)
+{
+ LmSSLBase *base;
+
+ base = LM_SSL_BASE (ssl);
+ lm_verbose ("lm_ssl_get_use_starttls use_starttls[%d]\n", base->use_starttls);
+ return base->use_starttls;
+}
+
+/**
+ * lm_ssl_get_require_starttls:
+ *
+ * Return value: TRUE if @ssl requires that STARTTLS succeed.
+ **/
+gboolean
+lm_ssl_get_require_starttls (LmSSL *ssl)
+{
+ LmSSLBase *base;
+
+ base = LM_SSL_BASE (ssl);
+ return base->require_starttls;
+}
+
+/**
+ * lm_ssl_unref
+ * @ssl: an #LmSSL
+ *
+ * Removes a reference from @ssl. When no more references are present
+ * @ssl is freed.
+ **/
+EXPORT_C void
+lm_ssl_unref (LmSSL *ssl)
+{
+ LmSSLBase *base;
+
+ g_return_if_fail (ssl != NULL);
+
+ base = LM_SSL_BASE (ssl);
+
+ base->ref_count --;
+
+ if (base->ref_count == 0) {
+ if (base->data_notify) {
+ (* base->data_notify) (base->func_data);
+ }
+
+ _lm_ssl_free (ssl);
+ }
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-ssl-gnutls.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,312 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003-2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <glib.h>
+
+#include "lm-debug.h"
+#include "lm-error.h"
+#include "lm-ssl-base.h"
+#include "lm-ssl-internals.h"
+
+#ifdef HAVE_GNUTLS
+
+#include <gnutls/x509.h>
+
+#define CA_PEM_FILE "/etc/ssl/certs/ca-certificates.crt"
+
+struct _LmSSL {
+ LmSSLBase base;
+
+ gnutls_session gnutls_session;
+ gnutls_certificate_credentials gnutls_xcred;
+ gboolean started;
+};
+
+static gboolean ssl_verify_certificate (LmSSL *ssl,
+ const gchar *server);
+
+static gboolean
+ssl_verify_certificate (LmSSL *ssl, const gchar *server)
+{
+ LmSSLBase *base;
+ unsigned int status;
+ int rc;
+
+ base = LM_SSL_BASE (ssl);
+
+ /* This verification function uses the trusted CAs in the credentials
+ * structure. So you must have installed one or more CA certificates.
+ */
+ rc = gnutls_certificate_verify_peers2 (ssl->gnutls_session, &status);
+
+ if (rc == GNUTLS_E_NO_CERTIFICATE_FOUND) {
+ if (base->func (ssl,
+ LM_SSL_STATUS_NO_CERT_FOUND,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (rc != 0) {
+ if (base->func (ssl,
+ LM_SSL_STATUS_GENERIC_ERROR,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (rc == GNUTLS_E_NO_CERTIFICATE_FOUND) {
+ if (base->func (ssl,
+ LM_SSL_STATUS_NO_CERT_FOUND,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (status & GNUTLS_CERT_INVALID
+ || status & GNUTLS_CERT_REVOKED) {
+ if (base->func (ssl, LM_SSL_STATUS_UNTRUSTED_CERT,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (gnutls_certificate_expiration_time_peers (ssl->gnutls_session) < time (0)) {
+ if (base->func (ssl, LM_SSL_STATUS_CERT_EXPIRED,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (gnutls_certificate_activation_time_peers (ssl->gnutls_session) > time (0)) {
+ if (base->func (ssl, LM_SSL_STATUS_CERT_NOT_ACTIVATED,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (gnutls_certificate_type_get (ssl->gnutls_session) == GNUTLS_CRT_X509) {
+ const gnutls_datum* cert_list;
+ guint cert_list_size;
+ size_t digest_size;
+ gnutls_x509_crt cert;
+
+ cert_list = gnutls_certificate_get_peers (ssl->gnutls_session, &cert_list_size);
+ if (cert_list == NULL) {
+ if (base->func (ssl, LM_SSL_STATUS_NO_CERT_FOUND,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ gnutls_x509_crt_init (&cert);
+
+ if (gnutls_x509_crt_import (cert, &cert_list[0],
+ GNUTLS_X509_FMT_DER) != 0) {
+ if (base->func (ssl, LM_SSL_STATUS_NO_CERT_FOUND,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ if (!gnutls_x509_crt_check_hostname (cert, server)) {
+ if (base->func (ssl, LM_SSL_STATUS_CERT_HOSTNAME_MISMATCH,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ gnutls_x509_crt_deinit (cert);
+
+ digest_size = sizeof (base->fingerprint);
+
+ if (gnutls_fingerprint (GNUTLS_DIG_MD5, &cert_list[0],
+ base->fingerprint,
+ &digest_size) >= 0) {
+ if (base->expected_fingerprint &&
+ memcmp (base->expected_fingerprint,
+ base->fingerprint,
+ digest_size) &&
+ base->func (ssl,
+ LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+ else if (base->func (ssl, LM_SSL_STATUS_GENERIC_ERROR,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+/* From lm-ssl-protected.h */
+
+LmSSL *
+_lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ LmSSL *ssl;
+
+ ssl = g_new0 (LmSSL, 1);
+
+ _lm_ssl_base_init ((LmSSLBase *) ssl,
+ expected_fingerprint,
+ ssl_function, user_data, notify);
+
+ return ssl;
+}
+
+void
+_lm_ssl_initialize (LmSSL *ssl)
+{
+ gnutls_global_init ();
+ gnutls_certificate_allocate_credentials (&ssl->gnutls_xcred);
+ gnutls_certificate_set_x509_trust_file(ssl->gnutls_xcred,
+ CA_PEM_FILE,
+ GNUTLS_X509_FMT_PEM);
+}
+
+gboolean
+_lm_ssl_begin (LmSSL *ssl, gint fd, const gchar *server, GError **error)
+{
+ int ret;
+ gboolean auth_ok = TRUE;
+ const int cert_type_priority[] =
+ { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
+ const int compression_priority[] =
+ { GNUTLS_COMP_DEFLATE, GNUTLS_COMP_NULL, 0 };
+
+ gnutls_init (&ssl->gnutls_session, GNUTLS_CLIENT);
+ gnutls_set_default_priority (ssl->gnutls_session);
+ gnutls_certificate_type_set_priority (ssl->gnutls_session,
+ cert_type_priority);
+ gnutls_compression_set_priority (ssl->gnutls_session,
+ compression_priority);
+ gnutls_credentials_set (ssl->gnutls_session,
+ GNUTLS_CRD_CERTIFICATE,
+ ssl->gnutls_xcred);
+
+ gnutls_transport_set_ptr (ssl->gnutls_session,
+ (gnutls_transport_ptr_t) fd);
+
+ ret = gnutls_handshake (ssl->gnutls_session);
+
+ if (ret >= 0) {
+ auth_ok = ssl_verify_certificate (ssl, server);
+ }
+
+ if (ret < 0 || !auth_ok) {
+ char *errmsg;
+
+ gnutls_perror (ret);
+
+ if (!auth_ok) {
+ errmsg = "*** GNUTLS authentication error";
+ } else {
+ errmsg = "*** GNUTLS handshake failed";
+ }
+
+ g_set_error (error,
+ LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ errmsg);
+
+ return FALSE;
+ }
+ lm_verbose ("GNUTLS negotiated compression: %s",
+ gnutls_compression_get_name (gnutls_compression_get
+ (ssl->gnutls_session)));
+
+ ssl->started = TRUE;
+
+ return TRUE;
+}
+
+GIOStatus
+_lm_ssl_read (LmSSL *ssl, gchar *buf, gint len, gsize *bytes_read)
+{
+ GIOStatus status;
+ gint b_read;
+
+ *bytes_read = 0;
+ b_read = gnutls_record_recv (ssl->gnutls_session, buf, len);
+
+ if (b_read == GNUTLS_E_AGAIN) {
+ status = G_IO_STATUS_AGAIN;
+ }
+ else if (b_read == 0) {
+ status = G_IO_STATUS_EOF;
+ }
+ else if (b_read < 0) {
+ status = G_IO_STATUS_ERROR;
+ } else {
+ *bytes_read = (guint) b_read;
+ status = G_IO_STATUS_NORMAL;
+ }
+
+ return status;
+}
+
+gint
+_lm_ssl_send (LmSSL *ssl, const gchar *str, gint len)
+{
+ gint bytes_written;
+
+ bytes_written = gnutls_record_send (ssl->gnutls_session, str, len);
+
+ while (bytes_written < 0) {
+ if (bytes_written != GNUTLS_E_INTERRUPTED &&
+ bytes_written != GNUTLS_E_AGAIN) {
+ return -1;
+ }
+
+ bytes_written = gnutls_record_send (ssl->gnutls_session,
+ str, len);
+ }
+
+ return bytes_written;
+}
+
+void
+_lm_ssl_close (LmSSL *ssl)
+{
+ if (!ssl->started)
+ return;
+
+ gnutls_deinit (ssl->gnutls_session);
+ gnutls_certificate_free_credentials (ssl->gnutls_xcred);
+ gnutls_global_deinit ();
+}
+
+void
+_lm_ssl_free (LmSSL *ssl)
+{
+ _lm_ssl_base_free_fields (LM_SSL_BASE (ssl));
+ g_free (ssl);
+}
+
+#endif /* HAVE_GNUTLS */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-ssl-openssl.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,469 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ * and/or its subsidiary/subsidiaries. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "lm-debug.h"
+#include "lm-error.h"
+#include "lm-ssl-base.h"
+#include "lm-ssl-internals.h"
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+GET_STATIC_VAR_FROM_TLS(initialized, lm_ssl_openssl, gboolean)
+ #define initialized (*GET_WSD_VAR_NAME(initialized, lm_ssl_openssl, s) () )
+#endif
+#ifdef HAVE_OPENSSL
+
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
+#define LM_SSL_CN_MAX 63
+
+struct _LmSSL {
+ LmSSLBase base;
+
+ SSL_METHOD *ssl_method;
+ SSL_CTX *ssl_ctx;
+ SSL *ssl;
+ /*BIO *bio;*/
+};
+
+int ssl_verify_cb (int preverify_ok, X509_STORE_CTX *x509_ctx);
+
+static gboolean ssl_verify_certificate (LmSSL *ssl, const gchar *server);
+static GIOStatus ssl_io_status_from_return (LmSSL *ssl, gint error);
+
+/*static char _ssl_error_code[11];*/
+
+static void
+ssl_print_state (LmSSL *ssl, const char *func, int val)
+{
+ unsigned long errid;
+ const char *errmsg;
+
+ switch (SSL_get_error(ssl->ssl, val)) {
+ case SSL_ERROR_NONE:
+ g_warning ("%s(): %i / SSL_ERROR_NONE",
+ func, val);
+ break;
+ case SSL_ERROR_ZERO_RETURN:
+ g_warning ("%s(): %i / SSL_ERROR_ZERO_RETURN",
+ func, val);
+ break;
+ case SSL_ERROR_WANT_READ:
+ g_warning ("%s(): %i / SSL_ERROR_WANT_READ",
+ func, val);
+ break;
+ case SSL_ERROR_WANT_WRITE:
+ g_warning ("%s(): %i / SSL_ERROR_WANT_WRITE",
+ func, val);
+ break;
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ g_warning ("%s(): %i / SSL_ERROR_WANT_X509_LOOKUP",
+ func, val);
+ break;
+ case SSL_ERROR_SYSCALL:
+ g_warning ("%s(): %i / SSL_ERROR_SYSCALL",
+ func, val);
+ break;
+ case SSL_ERROR_SSL:
+ g_warning ("%s(): %i / SSL_ERROR_SSL",
+ func, val);
+ break;
+ }
+ do {
+ errid = ERR_get_error();
+ if (errid) {
+ errmsg = ERR_error_string(errid, NULL);
+ g_warning ("\t%s", errmsg);
+ }
+ } while (errid != 0);
+}
+
+/*static const char *
+ssl_get_x509_err (long verify_res)
+{
+ sprintf(_ssl_error_code, "%ld", verify_res);
+ return _ssl_error_code;
+}*/
+
+
+int
+ssl_verify_cb (int preverify_ok, X509_STORE_CTX *x509_ctx)
+{
+ /* As this callback doesn't get auxiliary pointer parameter we
+ * cannot really use this. However, we can retrieve results later. */
+ UNUSED_FORMAL_PARAM(preverify_ok);
+ UNUSED_FORMAL_PARAM(x509_ctx);
+ return 1;
+}
+
+static gboolean
+ssl_verify_certificate (LmSSL *ssl, const gchar *server)
+{
+ gboolean retval = TRUE;
+ LmSSLBase *base;
+ long verify_res;
+ unsigned int digest_len;
+ X509 *srv_crt;
+ gchar *cn;
+ X509_NAME *crt_subj;
+
+ return TRUE ; // hack - to bypass certificate verification error- Pankaj
+/*
+ base = LM_SSL_BASE(ssl);
+
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ // "%s: Cipher: %s/%s/%i\n",
+ // __FILE__,
+ // SSL_get_cipher_version(ssl->ssl),
+ // SSL_get_cipher_name(ssl->ssl),
+ // SSL_get_cipher_bits(ssl->ssl, NULL));
+
+ lm_verbose("\n[ssl_verify_certificate]:Cipher: %s/%s/%i\n",
+ SSL_get_cipher_version(ssl->ssl),
+ SSL_get_cipher_name(ssl->ssl),
+ SSL_get_cipher_bits(ssl->ssl, NULL));
+
+ verify_res = SSL_get_verify_result(ssl->ssl);
+ srv_crt = SSL_get_peer_certificate(ssl->ssl);
+ if (base->expected_fingerprint != NULL) {
+ X509_digest(srv_crt, EVP_md5(), (guchar *) base->fingerprint,
+ &digest_len);
+ if (memcmp(base->expected_fingerprint, base->fingerprint,
+ digest_len) != 0) {
+ if (base->func(ssl,
+ LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ return FALSE;
+ }
+ }
+ }
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ // "%s: SSL_get_verify_result() = %ld\n",
+ // __FILE__,
+ // verify_res);
+ lm_verbose("[ssl_verify_certificate]: SSL_get_verify_result() = %ld\n", verify_res);
+ switch (verify_res) {
+ case X509_V_OK:
+ break;
+ case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
+ // special case for self signed certificates?
+ case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
+ case X509_V_ERR_UNABLE_TO_GET_CRL:
+ case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
+ if (base->func(ssl,
+ LM_SSL_STATUS_NO_CERT_FOUND,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ retval = FALSE;
+ }
+ break;
+ case X509_V_ERR_INVALID_CA:
+ case X509_V_ERR_CERT_UNTRUSTED:
+ case X509_V_ERR_CERT_REVOKED:
+ if (base->func(ssl,
+ LM_SSL_STATUS_UNTRUSTED_CERT,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ retval = FALSE;
+ }
+ break;
+ case X509_V_ERR_CERT_NOT_YET_VALID:
+ case X509_V_ERR_CRL_NOT_YET_VALID:
+ if (base->func(ssl,
+ LM_SSL_STATUS_CERT_NOT_ACTIVATED,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ retval = FALSE;
+ }
+ break;
+ case X509_V_ERR_CERT_HAS_EXPIRED:
+ case X509_V_ERR_CRL_HAS_EXPIRED:
+ if (base->func(ssl,
+ LM_SSL_STATUS_CERT_EXPIRED,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ retval = FALSE;
+ }
+ break;
+ default:
+ if (base->func(ssl, LM_SSL_STATUS_GENERIC_ERROR,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ retval = FALSE;
+ }
+ }
+ //if (retval == FALSE) {
+ // g_set_error (error, LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ // ssl_get_x509_err(verify_res), NULL);
+ //}
+ crt_subj = X509_get_subject_name(srv_crt);
+ cn = (gchar *) g_malloc0(LM_SSL_CN_MAX + 1);
+
+ if (X509_NAME_get_text_by_NID(crt_subj, NID_commonName, cn, LM_SSL_CN_MAX) > 0) {
+ gchar *domain = cn;
+
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ // "%s: server = '%s', cn = '%s'\n",
+ // __FILE__, server, cn);
+ lm_verbose("%s: server = '%s', cn = '%s'\n",
+ __FILE__, server, cn);
+
+ if ((cn[0] == '*') && (cn[1] == '.')) {
+ domain = strstr (cn, server);
+ }
+
+ if ((domain == NULL) || (strncmp (server, domain, LM_SSL_CN_MAX) != 0)) {
+ if (base->func (ssl,
+ LM_SSL_STATUS_CERT_HOSTNAME_MISMATCH,
+ base->func_data) != LM_SSL_RESPONSE_CONTINUE) {
+ retval = FALSE;
+ }
+ }
+ } else {
+ g_warning ("X509_NAME_get_text_by_NID() failed");
+ }
+
+ //g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL,
+ // "%s:\n\tIssuer: %s\n\tSubject: %s\n\tFor: %s\n",
+ // __FILE__,
+ // X509_NAME_oneline(X509_get_issuer_name(srv_crt), NULL, 0),
+ // X509_NAME_oneline(X509_get_subject_name(srv_crt), NULL, 0),
+ // cn);
+
+ lm_verbose("%s:\n\tIssuer: %s\n\tSubject: %s\n\tFor: %s\n",
+ __FILE__,
+ X509_NAME_oneline(X509_get_issuer_name(srv_crt), NULL, 0),
+ X509_NAME_oneline(X509_get_subject_name(srv_crt), NULL, 0),
+ cn);
+
+ g_free(cn);
+
+ //return TRUE ; // hack - to bypass certificate verification error- Pankaj
+ return retval;
+ */
+}
+
+static GIOStatus
+ssl_io_status_from_return (LmSSL *ssl, gint ret)
+{
+ gint error;
+ GIOStatus status;
+
+ if (ret > 0) return G_IO_STATUS_NORMAL;
+
+ error = SSL_get_error(ssl->ssl, ret);
+ switch (error) {
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ status = G_IO_STATUS_AGAIN;
+ break;
+ case SSL_ERROR_ZERO_RETURN:
+ status = G_IO_STATUS_EOF;
+ break;
+ default:
+ status = G_IO_STATUS_ERROR;
+ }
+
+ return status;
+}
+
+/* From lm-ssl-protected.h */
+
+LmSSL *
+_lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ LmSSL *ssl;
+
+ ssl = g_new0 (LmSSL, 1);
+
+ _lm_ssl_base_init ((LmSSLBase *) ssl,
+ expected_fingerprint,
+ ssl_function, user_data, notify);
+
+ return ssl;
+}
+
+void
+_lm_ssl_initialize (LmSSL *ssl)
+{
+#ifndef EMULATOR
+ static gboolean initialized = FALSE;
+#endif
+ /*const char *cert_file = NULL;*/
+
+ if (!initialized) {
+ SSL_library_init();
+ /* FIXME: Is this needed when we are not in debug? */
+ SSL_load_error_strings();
+ initialized = TRUE;
+ }
+
+ ssl->ssl_method = TLSv1_client_method();
+ if (ssl->ssl_method == NULL) {
+ g_warning ("TLSv1_client_method() == NULL");
+ abort();
+ }
+ ssl->ssl_ctx = SSL_CTX_new(ssl->ssl_method);
+ if (ssl->ssl_ctx == NULL) {
+ g_warning ("SSL_CTX_new() == NULL");
+ abort();
+ }
+ /*if (access("/etc/ssl/cert.pem", R_OK) == 0)
+ cert_file = "/etc/ssl/cert.pem";
+ if (!SSL_CTX_load_verify_locations(ssl->ssl_ctx,
+ cert_file, "/etc/ssl/certs")) {
+ g_warning("SSL_CTX_load_verify_locations() failed");
+ }*/
+ SSL_CTX_set_default_verify_paths (ssl->ssl_ctx);
+ SSL_CTX_set_verify (ssl->ssl_ctx, SSL_VERIFY_PEER, ssl_verify_cb);
+}
+
+gboolean
+_lm_ssl_begin (LmSSL *ssl, gint fd, const gchar *server, GError **error)
+{
+ gint ssl_ret;
+ GIOStatus status;
+
+ if (!ssl->ssl_ctx) {
+ g_set_error (error,
+ LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "No SSL Context for OpenSSL");
+ return FALSE;
+ }
+
+ ssl->ssl = SSL_new(ssl->ssl_ctx);
+ if (ssl->ssl == NULL) {
+ g_warning ("SSL_new() == NULL");
+ g_set_error(error, LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "SSL_new()");
+ return FALSE;
+ }
+
+ if (!SSL_set_fd (ssl->ssl, fd)) {
+ g_warning ("SSL_set_fd() failed");
+ g_set_error(error, LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "SSL_set_fd()");
+ return FALSE;
+ }
+ /*ssl->bio = BIO_new_socket (fd, BIO_NOCLOSE);
+ if (ssl->bio == NULL) {
+ g_warning("BIO_new_socket() failed");
+ g_set_error(error, LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "BIO_new_socket()");
+ return FALSE;
+ }
+ SSL_set_bio(ssl->ssl, ssl->bio, ssl->bio);*/
+
+ do {
+ ssl_ret = SSL_connect(ssl->ssl);
+ if (ssl_ret <= 0) {
+ status = ssl_io_status_from_return(ssl, ssl_ret);
+ if (status != G_IO_STATUS_AGAIN) {
+ lm_verbose("[_lm_ssl_begin] errno for ssl connect:[%d], ssl_ret[%d]\n", errno, ssl_ret);
+ lm_verbose("\n[_lm_ssl_begin] ssl_io_status_from_return return status failed..:[%d]\n", status);
+ ssl_print_state(ssl, "SSL_connect",
+ ssl_ret);
+ g_set_error(error, LM_ERROR,
+ LM_ERROR_CONNECTION_OPEN,
+ "SSL_connect()");
+ return FALSE;
+ }
+ }
+ } while (ssl_ret <= 0);
+
+ lm_verbose("\n[_lm_ssl_begin] errno for ssl connect:[%d], ssl_ret[%d]\n", errno, ssl_ret);
+ // log
+ {
+ long verify_res;
+ verify_res = SSL_get_verify_result(ssl->ssl);
+ lm_verbose("[_lm_ssl_begin]: After SSL Connect : SSL_get_verify_result() = %ld\n", verify_res);
+ }
+
+ if (!ssl_verify_certificate (ssl, server)) {
+ g_set_error (error, LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "*** SSL certificate verification failed");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+GIOStatus
+_lm_ssl_read (LmSSL *ssl, gchar *buf, gint len, gsize *bytes_read)
+{
+ GIOStatus status;
+ gint ssl_ret;
+
+ *bytes_read = 0;
+ ssl_ret = SSL_read(ssl->ssl, buf, len);
+ status = ssl_io_status_from_return(ssl, ssl_ret);
+ if (status == G_IO_STATUS_NORMAL) {
+ *bytes_read = ssl_ret;
+ }
+
+ return status;
+}
+
+gint
+_lm_ssl_send (LmSSL *ssl, const gchar *str, gint len)
+{
+ GIOStatus status;
+ gint ssl_ret;
+
+ do {
+ ssl_ret = SSL_write(ssl->ssl, str, len);
+ if (ssl_ret <= 0) {
+ status = ssl_io_status_from_return(ssl, ssl_ret);
+ if (status != G_IO_STATUS_AGAIN)
+ return -1;
+ }
+ } while (ssl_ret <= 0);
+
+ return ssl_ret;
+}
+
+void
+_lm_ssl_close (LmSSL *ssl)
+{
+ if (ssl->ssl != NULL) {
+ SSL_shutdown(ssl->ssl);
+ SSL_free(ssl->ssl);
+ ssl->ssl = NULL;
+ }
+}
+
+void
+_lm_ssl_free (LmSSL *ssl)
+{
+ SSL_CTX_free(ssl->ssl_ctx);
+ ssl->ssl_ctx = NULL;
+
+ _lm_ssl_base_free_fields (LM_SSL_BASE(ssl));
+ g_free (ssl);
+}
+
+#endif /* HAVE_GNUTLS */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/lm-utils.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,231 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2003 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <glib.h>
+
+#ifndef G_OS_WIN32
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_IDN
+#include <stringprep.h>
+#include <punycode.h>
+#include <idna.h>
+#endif
+
+#include "lm-internals.h"
+#include "lm-utils.h"
+
+#ifdef EMULATOR
+#include "libloudmouth_wsd_solution.h"
+GET_STATIC_VAR_FROM_TLS(last_id, lm_utils, guint)
+ #define last_id (*GET_WSD_VAR_NAME(last_id, lm_utils, s)())
+
+GET_STATIC_ARRAY_FROM_TLS(base64chars, lm_utils, gchar)
+ #define base64chars (GET_WSD_VAR_NAME(base64chars, lm_utils, s)())
+#endif
+
+
+LmCallback *
+_lm_utils_new_callback (gpointer func,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ LmCallback *cb;
+
+ cb = g_new0 (LmCallback, 1);
+ cb->func = func;
+ cb->user_data = user_data;
+ cb->notify = notify;
+
+ return cb;
+}
+
+void
+_lm_utils_free_callback (LmCallback *cb)
+{
+ if (!cb) {
+ return;
+ }
+
+ if (cb->notify) {
+ (* cb->notify) (cb->user_data);
+ }
+ g_free (cb);
+}
+
+gchar *
+_lm_utils_generate_id (void)
+{
+#ifndef EMULATOR
+ static guint last_id = 0;
+#endif
+ GTimeVal tv;
+ glong val;
+
+ g_get_current_time (&tv);
+ val = (tv.tv_sec & tv.tv_usec) + last_id++;
+
+ return g_strdup_printf ("%ld%ld", val, tv.tv_usec);
+}
+
+gchar *
+_lm_utils_base64_encode (const gchar *s)
+{
+#ifndef EMULATOR
+
+ static const gchar *base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+#endif
+ guint i, j;
+ guint32 bits = 0;
+ guint maxlen = (strlen(s) * 2) + 3;
+ gchar *str;
+
+ str = g_malloc(maxlen);
+
+ j = 0;
+ for (i = 0; i < strlen(s); i++) {
+ bits <<= 8;
+ bits |= s[i] & 0xff;
+
+ if (!((i+1) % 3)) {
+ guint indices[4];
+
+ indices[0] = (bits >> 18) & 0x3f;
+ indices[1] = (bits >> 12) & 0x3f;
+ indices[2] = (bits >> 6) & 0x3f;
+ indices[3] = bits & 0x3f;
+ bits = 0;
+
+ str[j++] = base64chars[(indices[0])];
+ str[j++] = base64chars[(indices[1])];
+ str[j++] = base64chars[(indices[2])];
+ str[j++] = base64chars[(indices[3])];
+ }
+ }
+
+ if (j + 4 < maxlen) {
+ if ((i % 3) == 1) {
+ guint indices[2];
+
+ indices[0] = (bits >> 2) & 0x3f;
+ indices[1] = (bits << 4) & 0x3f;
+
+ str[j++] = base64chars[(indices[0])];
+ str[j++] = base64chars[(indices[1])];
+ str[j++] = '=';
+ str[j++] = '=';
+ } else if ((i % 3) == 2) {
+ guint indices[3];
+
+ indices[0] = (bits >> 10) & 0x3f;
+ indices[1] = (bits >> 4) & 0x3f;
+ indices[2] = (bits << 2) & 0x3f;
+
+ str[j++] = base64chars[(indices[0])];
+ str[j++] = base64chars[(indices[1])];
+ str[j++] = base64chars[(indices[2])];
+ str[j++] = '=';
+ }
+ }
+
+ str[j] = '\0';
+
+ return str;
+}
+
+gchar*
+_lm_utils_hostname_to_punycode (const gchar *hostname)
+{
+#ifdef HAVE_IDN
+ char *s;
+ uint32_t *q;
+ int rc;
+ gchar *result;
+
+ q = stringprep_utf8_to_ucs4 (hostname, -1, NULL);
+ if (q == NULL) {
+ return g_strdup (hostname);
+ }
+
+ rc = idna_to_ascii_4z (q, &s, IDNA_ALLOW_UNASSIGNED);
+ free(q);
+ if (rc != IDNA_SUCCESS) {
+ return g_strdup (hostname);
+ }
+
+ /* insures result is allocated through glib */
+ result = g_strdup(s);
+ free(s);
+
+ return result;
+#else
+ return g_strdup(hostname);
+#endif
+}
+
+/**
+ * lm_utils_get_localtime:
+ * @stamp: An XMPP timestamp
+ *
+ * Converts an XMPP timestamp to a struct tm showing local time.
+ *
+ * Return value: The local time struct.
+ **/
+EXPORT_C struct tm *
+lm_utils_get_localtime (const gchar *stamp)
+{
+ struct tm tm;
+ time_t t;
+ gint year, month;
+
+ g_return_val_if_fail (stamp != NULL, NULL);
+
+ /* 20021209T23:51:30 */
+
+ sscanf (stamp, "%4d%2d%2dT%2d:%2d:%2d",
+ &year, &month, &tm.tm_mday, &tm.tm_hour,
+ &tm.tm_min, &tm.tm_sec);
+
+ tm.tm_year = year - 1900;
+ tm.tm_mon = month - 1;
+ tm.tm_isdst = -1;
+
+ t = mktime (&tm);
+
+#if defined(HAVE_TM_GMTOFF)
+ t += tm.tm_gmtoff;
+#elif defined(HAVE_TIMEZONE)
+ t -= timezone;
+ if (tm.tm_isdst > 0) {
+ t += 3600;
+ }
+#endif
+
+ return localtime (&t);
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/src/md5.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,381 @@
+/*
+ Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.c is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order
+ either statically or dynamically; added missing #include <string.h>
+ in library.
+ 2002-03-11 lpd Corrected argument list for main(), and added int return
+ type, in test program and T value program.
+ 2002-02-21 lpd Added missing #include <stdio.h> in test program.
+ 2000-07-03 lpd Patched to eliminate warnings about "constant is
+ unsigned in ANSI C, signed in traditional"; made test program
+ self-checking.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
+ 1999-05-03 lpd Original version.
+ */
+
+#include "md5.h"
+#include <string.h>
+
+#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
+#ifdef ARCH_IS_BIG_ENDIAN
+# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
+#else
+# define BYTE_ORDER 0
+#endif
+
+#define T_MASK ((md5_word_t)~0)
+#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
+#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
+#define T3 0x242070db
+#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
+#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
+#define T6 0x4787c62a
+#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
+#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
+#define T9 0x698098d8
+#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
+#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
+#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
+#define T13 0x6b901122
+#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
+#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
+#define T16 0x49b40821
+#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
+#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
+#define T19 0x265e5a51
+#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
+#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
+#define T22 0x02441453
+#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
+#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
+#define T25 0x21e1cde6
+#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
+#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
+#define T28 0x455a14ed
+#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
+#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
+#define T31 0x676f02d9
+#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
+#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
+#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
+#define T35 0x6d9d6122
+#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
+#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
+#define T38 0x4bdecfa9
+#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
+#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
+#define T41 0x289b7ec6
+#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
+#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
+#define T44 0x04881d05
+#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
+#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
+#define T47 0x1fa27cf8
+#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
+#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
+#define T50 0x432aff97
+#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
+#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
+#define T53 0x655b59c3
+#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
+#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
+#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
+#define T57 0x6fa87e4f
+#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
+#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
+#define T60 0x4e0811a1
+#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
+#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
+#define T63 0x2ad7d2bb
+#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
+
+
+static void
+md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
+{
+ md5_word_t
+ a = pms->abcd[0], b = pms->abcd[1],
+ c = pms->abcd[2], d = pms->abcd[3];
+ md5_word_t t;
+#if BYTE_ORDER > 0
+ /* Define storage only for big-endian CPUs. */
+ md5_word_t X[16];
+#else
+ /* Define storage for little-endian or both types of CPUs. */
+ md5_word_t xbuf[16];
+ const md5_word_t *X;
+#endif
+
+ {
+#if BYTE_ORDER == 0
+ /*
+ * Determine dynamically whether this is a big-endian or
+ * little-endian machine, since we can use a more efficient
+ * algorithm on the latter.
+ */
+ static const int w = 1;
+
+ if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
+#endif
+#if BYTE_ORDER <= 0 /* little-endian */
+ {
+ /*
+ * On little-endian machines, we can process properly aligned
+ * data without copying it.
+ */
+ if (!((data - (const md5_byte_t *)0) & 3)) {
+ /* data are properly aligned */
+ X = (const md5_word_t *)data;
+ } else {
+ /* not aligned */
+ memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
+ }
+#endif
+#if BYTE_ORDER == 0
+ else /* dynamic big-endian */
+#endif
+#if BYTE_ORDER >= 0 /* big-endian */
+ {
+ /*
+ * On big-endian machines, we must arrange the bytes in the
+ * right order.
+ */
+ const md5_byte_t *xp = data;
+ int i;
+
+# if BYTE_ORDER == 0
+ X = xbuf; /* (dynamic only) */
+# else
+# define xbuf X /* (static only) */
+# endif
+ for (i = 0; i < 16; ++i, xp += 4)
+ xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+ }
+#endif
+ }
+
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+
+ /* Round 1. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
+#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + F(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 7, T1);
+ SET(d, a, b, c, 1, 12, T2);
+ SET(c, d, a, b, 2, 17, T3);
+ SET(b, c, d, a, 3, 22, T4);
+ SET(a, b, c, d, 4, 7, T5);
+ SET(d, a, b, c, 5, 12, T6);
+ SET(c, d, a, b, 6, 17, T7);
+ SET(b, c, d, a, 7, 22, T8);
+ SET(a, b, c, d, 8, 7, T9);
+ SET(d, a, b, c, 9, 12, T10);
+ SET(c, d, a, b, 10, 17, T11);
+ SET(b, c, d, a, 11, 22, T12);
+ SET(a, b, c, d, 12, 7, T13);
+ SET(d, a, b, c, 13, 12, T14);
+ SET(c, d, a, b, 14, 17, T15);
+ SET(b, c, d, a, 15, 22, T16);
+#undef SET
+
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + G(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, T17);
+ SET(d, a, b, c, 6, 9, T18);
+ SET(c, d, a, b, 11, 14, T19);
+ SET(b, c, d, a, 0, 20, T20);
+ SET(a, b, c, d, 5, 5, T21);
+ SET(d, a, b, c, 10, 9, T22);
+ SET(c, d, a, b, 15, 14, T23);
+ SET(b, c, d, a, 4, 20, T24);
+ SET(a, b, c, d, 9, 5, T25);
+ SET(d, a, b, c, 14, 9, T26);
+ SET(c, d, a, b, 3, 14, T27);
+ SET(b, c, d, a, 8, 20, T28);
+ SET(a, b, c, d, 13, 5, T29);
+ SET(d, a, b, c, 2, 9, T30);
+ SET(c, d, a, b, 7, 14, T31);
+ SET(b, c, d, a, 12, 20, T32);
+#undef SET
+
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + H(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, T33);
+ SET(d, a, b, c, 8, 11, T34);
+ SET(c, d, a, b, 11, 16, T35);
+ SET(b, c, d, a, 14, 23, T36);
+ SET(a, b, c, d, 1, 4, T37);
+ SET(d, a, b, c, 4, 11, T38);
+ SET(c, d, a, b, 7, 16, T39);
+ SET(b, c, d, a, 10, 23, T40);
+ SET(a, b, c, d, 13, 4, T41);
+ SET(d, a, b, c, 0, 11, T42);
+ SET(c, d, a, b, 3, 16, T43);
+ SET(b, c, d, a, 6, 23, T44);
+ SET(a, b, c, d, 9, 4, T45);
+ SET(d, a, b, c, 12, 11, T46);
+ SET(c, d, a, b, 15, 16, T47);
+ SET(b, c, d, a, 2, 23, T48);
+#undef SET
+
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + I(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, T49);
+ SET(d, a, b, c, 7, 10, T50);
+ SET(c, d, a, b, 14, 15, T51);
+ SET(b, c, d, a, 5, 21, T52);
+ SET(a, b, c, d, 12, 6, T53);
+ SET(d, a, b, c, 3, 10, T54);
+ SET(c, d, a, b, 10, 15, T55);
+ SET(b, c, d, a, 1, 21, T56);
+ SET(a, b, c, d, 8, 6, T57);
+ SET(d, a, b, c, 15, 10, T58);
+ SET(c, d, a, b, 6, 15, T59);
+ SET(b, c, d, a, 13, 21, T60);
+ SET(a, b, c, d, 4, 6, T61);
+ SET(d, a, b, c, 11, 10, T62);
+ SET(c, d, a, b, 2, 15, T63);
+ SET(b, c, d, a, 9, 21, T64);
+#undef SET
+
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
+ pms->abcd[0] += a;
+ pms->abcd[1] += b;
+ pms->abcd[2] += c;
+ pms->abcd[3] += d;
+}
+
+void
+md5_init(md5_state_t *pms)
+{
+ pms->count[0] = pms->count[1] = 0;
+ pms->abcd[0] = 0x67452301;
+ pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
+ pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+ pms->abcd[3] = 0x10325476;
+}
+
+void
+md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
+{
+ const md5_byte_t *p = data;
+ int left = nbytes;
+ int offset = (pms->count[0] >> 3) & 63;
+ md5_word_t nbits = (md5_word_t)(nbytes << 3);
+
+ if (nbytes <= 0)
+ return;
+
+ /* Update the message length. */
+ pms->count[1] += nbytes >> 29;
+ pms->count[0] += nbits;
+ if (pms->count[0] < nbits)
+ pms->count[1]++;
+
+ /* Process an initial partial block. */
+ if (offset) {
+ int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+ memcpy(pms->buf + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(pms, pms->buf);
+ }
+
+ /* Process full blocks. */
+ for (; left >= 64; p += 64, left -= 64)
+ md5_process(pms, p);
+
+ /* Process a final partial block. */
+ if (left)
+ memcpy(pms->buf, p, left);
+}
+
+void
+md5_finish(md5_state_t *pms, md5_byte_t digest[16])
+{
+ static const md5_byte_t pad[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ md5_byte_t data[8];
+ int i;
+
+ /* Save the length before padding. */
+ for (i = 0; i < 8; ++i)
+ data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ /* Pad to 56 bytes mod 64. */
+ md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ /* Append the length. */
+ md5_append(pms, data, 8);
+ for (i = 0; i < 16; ++i)
+ digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/bmarm/tstlmu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/bwins/tstlmu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,575 @@
+[Define]
+SERVER chat.gizmoproject.com
+USERNAME prima@chat.gizmoproject.com
+PASSWORD donna
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+
+UnexistGizmoJID testlmnokia1111@chat.gizmoproject.com
+OnlyDomainofJID @chat.gizmoproject.com
+UnexistGTalkJID abcd123_mk@gmail.com
+BadGizmoDomain prima@chat.gizmoooproject.com
+BadGtalkDomain nokiaprima@gmaiiil.com
+badpassword 12345
+badserver chat.gizmoprojeeeect.com
+UsernameWithBadServer testlmnokia@chat.gizmoprojeeeeect.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGPASSWORD thisisawrongpasswordandthetestcaseshouldnotfail
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+
+EMPTYCONTACT Emptycontact@chat.gizmoproject.com
+EMPTYPASSWORD test
+
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+
+PROXY_SERVER 172.16.9.181
+PROXY_PORT 8080
+[Enddefine]
+
+[Test]
+title 1. lm_connection_new
+create tstlm LmObj
+LmObj lm_connection_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 2. lm_connection_send
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 3. lm_fetching_contactlist
+create tstlm LmObj
+LmObj lm_fetching_contactlist SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 4. lm_fetching_presence
+create tstlm LmObj
+LmObj lm_fetching_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 5. lm_connection_new_with_context
+create tstlm LmObj
+LmObj lm_new_with_context
+delete LmObj
+[Endtest]
+
+[Test]
+title 6. lm_connection_open
+create tstlm LmObj
+LmObj lm_connection_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 7. lm_connection_closeWhenNotOpen
+create tstlm LmObj
+LmObj lm_connection_closeWhenNotOpen SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 8. lm_connection_authenticate
+create tstlm LmObj
+LmObj lm_authenticate SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 9. lm_connection_is_open
+create tstlm LmObj
+LmObj lm_connection_is_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 10. lm_connection_authenticate_withbadpassword
+create tstlm LmObj
+LmObj lm_authenticate_badpassword SERVER USERNAME badpassword RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 11. lm_connection_authenticate when connection is closed
+create tstlm LmObj
+LmObj lm_authenticate_connectionisnotcreated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 12. lm_connection_is_open_WhenConnectionIsClosed
+create tstlm LmObj
+LmObj lm_connection_is_open_WhenConnectionIsClosed SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 13. lm_connection_close
+create tstlm LmObj
+LmObj lm_connection_close SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 14. lm_connection_is_authenticated
+create tstlm LmObj
+LmObj lm_is_authenticated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 15. lm_connection_is_authenticated_WhenNot_Authenticated
+create tstlm LmObj
+LmObj lm_connection_is_authenticated_WhenNot_Authenticated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 16. lm_connection_set_get_server
+create tstlm LmObj
+LmObj lm_connection_set_get_server SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 17. lm_connection_set_get_port
+create tstlm LmObj
+LmObj lm_connection_set_get_port
+delete LmObj
+[Endtest]
+
+[Test]
+title 18. lm_connection_set_get_ssl
+create tstlm LmObj
+LmObj lm_connection_set_get_ssl
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 19. lm_connection_set_get_proxy
+create tstlm LmObj
+LmObj lm_connection_set_get_proxy
+delete LmObj
+[Endtest]
+
+[Test]
+title 20. lm_connection_set_get_jid
+create tstlm LmObj
+LmObj lm_connection_set_get_jid SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 21. lm_connection_set_jid_WithNull
+create tstlm LmObj
+LmObj lm_connection_set_jid_WithNull SERVER \0 PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 22. lm_connection_set_port_WithNULL
+create tstlm LmObj
+LmObj lm_connection_set_port_WithNULL
+delete LmObj
+[Endtest]
+
+[Test]
+title 23. lm_connection_set_server_withNULL
+create tstlm LmObj
+LmObj lm_connection_set_server_withNULL \0 USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 24. lm_connection_set_disconnect_function
+create tstlm LmObj
+LmObj set_disconnect_function SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 25. lm_connection_send_with_reply
+create tstlm LmObj
+LmObj lm_send_with_reply SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 26. lm_proxy_set_get_port
+create tstlm LmObj
+LmObj lm_proxy_set_get_port
+delete LmObj
+[Endtest]
+
+[Test]
+title 27. lm_proxy_set_get_type
+create tstlm LmObj
+LmObj lm_proxy_set_get_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 28. lm_proxy_set_get_server
+create tstlm LmObj
+LmObj lm_proxy_set_get_server
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 29. lm_proxy_set_get_username
+create tstlm LmObj
+LmObj lm_proxy_set_get_username
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 30. lm_proxy_set_get_password
+create tstlm LmObj
+LmObj lm_proxy_set_get_password
+delete LmObj
+[Endtest]
+
+[Test]
+title 31. lm_proxy_new
+create tstlm LmObj
+LmObj lm_proxy_new
+delete LmObj
+[Endtest]
+
+[Test]
+title 32. lm_proxy_new_with_server
+create tstlm LmObj
+LmObj lm_proxy_new_with_server
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 33. lm_proxy_ref
+create tstlm LmObj
+LmObj lm_proxy_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 34. lm_proxy_unref
+create tstlm LmObj
+LmObj lm_proxy_unref
+delete LmObj
+[Endtest]
+
+[Test]
+title 35. lm_ssl_new
+create tstlm LmObj
+LmObj lm_ssl_new
+delete LmObj
+[Endtest]
+
+[Test]
+title 36. lm_ssl_is_supported
+create tstlm LmObj
+LmObj lm_ssl_is_supported
+delete LmObj
+[Endtest]
+
+[Test]
+title 37. lm_ssl_get_fingerprint
+create tstlm LmObj
+LmObj lm_ssl_get_fingerprint
+delete LmObj
+[Endtest]
+
+[Test]
+title 38. lm_ssl_ref
+create tstlm LmObj
+LmObj lm_ssl_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 39. lm_ssl_unref
+create tstlm LmObj
+LmObj lm_ssl_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 40. lm_message_node_ref
+create tstlm LmObj
+LmObj lm_message_node_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 41. lm_message_node_unref
+create tstlm LmObj
+LmObj lm_message_node_unref
+delete LmObj
+[Endtest]
+
+[Test]
+title 42. lm_message_node_to_string
+create tstlm LmObj
+LmObj lm_message_node_to_string
+delete LmObj
+[Endtest]
+
+
+\\failed when run together. passed independantly
+[Test]
+title 43. lm_message_node_set_get_attributes
+create tstlm LmObj
+LmObj lm_message_node_set_get_attributes
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 44. lm_message_node_set_get_raw_mode
+create tstlm LmObj
+LmObj lm_message_node_set_get_raw_mode
+delete LmObj
+[Endtest]
+
+\\failed when run together. passed independantly
+[Test]
+title 45. lm_message_node_add_child
+create tstlm LmObj
+LmObj lm_message_node_add_child
+delete LmObj
+[Endtest]
+
+[Test]
+title 46. lm_message_node_get_child
+create tstlm LmObj
+LmObj lm_message_node_get_child
+delete LmObj
+[Endtest]
+
+[Test]
+title 47. lm_message_node_find_child
+create tstlm LmObj
+LmObj lm_message_node_find_child
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 48. lm_message_node_set_get_value
+create tstlm LmObj
+LmObj lm_message_node_set_get_value
+delete LmObj
+[Endtest]
+
+[Test]
+title 49. lm_message_handler_new
+create tstlm LmObj
+LmObj lm_message_handler_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 50. lm_message_handler_invalidate
+create tstlm LmObj
+LmObj lm_message_handler_invalidate
+delete LmObj
+[Endtest]
+
+[Test]
+title 51. lm_message_handler_is_valid
+create tstlm LmObj
+LmObj lm_message_handler_is_valid
+delete LmObj
+[Endtest]
+
+[Test]
+title 52. lm_message_handler_ref
+create tstlm LmObj
+LmObj lm_message_handler_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 53. lm_message_handler_unref
+create tstlm LmObj
+LmObj lm_message_handler_unref
+delete LmObj
+[Endtest]
+
+[Test]
+title 54. lm_message_new
+create tstlm LmObj
+LmObj lm_message_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 55. lm_message_new_with_sub_type
+create tstlm LmObj
+LmObj lm_message_new_with_sub_type SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 56. lm_message_get_type
+create tstlm LmObj
+LmObj lm_message_get_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 57. lm_message_get_sub_type
+create tstlm LmObj
+LmObj lm_message_get_sub_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 58. lm_message_get_node
+create tstlm LmObj
+LmObj lm_message_get_node
+delete LmObj
+[Endtest]
+
+[Test]
+title 59. lm_message_ref
+create tstlm LmObj
+LmObj lm_message_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 60. lm_message_unref
+create tstlm LmObj
+LmObj lm_message_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 61. lm_connection_get_state
+create tstlm LmObj
+LmObj lm_connection_get_state SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 62. lm_connection_ref
+create tstlm LmObj
+LmObj lm_connection_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 63. lm_connection_unref
+create tstlm LmObj
+LmObj lm_connection_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 64. lm_connection_send_raw
+create tstlm LmObj
+LmObj lm_connection_send_raw SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 65. lm_register_message_handler
+create tstlm LmObj
+LmObj register_message_handler SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 66. lm_set_ssl_WithNULL
+create tstlm LmObj
+LmObj lm_connection_set_ssl_WithNULL
+delete LmObj
+[Endtest]
+
+[Test]
+title 67. lm_connection_authenticate_withUnexistJID
+create tstlm LmObj
+LmObj lm_authenticate_unexistjid SERVER UnexistGizmoJID PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 68. lm_login_test_with_SpecialChar_JID
+create tstlm LmObj
+LmObj lm_login_test SERVER SpecialUSERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 69. lm_login_test_with_Long_JID
+create tstlm LmObj
+LmObj lm_login_test SERVER LONGUSERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 70. lm_login_test_with_Long_PASSWORD
+create tstlm LmObj
+LmObj lm_login_test SERVER USERNAME LONGPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 71. lm_send_long_message
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT LONGMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 72. lm_send_400chars
+create tstlm LmObj
+LmObj lm_connection_send400char SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 73. lm_send_repeated
+create tstlm LmObj
+LmObj lm_connection_send_repeated SERVER USERNAME PASSWORD RECIPIENT REPEATEDMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 74. lm_send_smiley
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm1.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,304 @@
+[Define]
+SERVER chat.gizmoproject.com
+USERNAME prima@chat.gizmoproject.com
+PASSWORD donna
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+
+UnexistGizmoJID testlmnokia1111@chat.gizmoproject.com
+OnlyDomainofJID @chat.gizmoproject.com
+UnexistGTalkJID abcd123_mk@gmail.com
+BadGizmoDomain prima@chat.gizmoooproject.com
+badpassword 12345
+badserver chat.gizmoprojeeeect.com
+UsernameWithBadServer testlmnokia@chat.gizmoprojeeeeect.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGPASSWORD loudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouth
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+
+EMPTYCONTACT Emptycontact@chat.gizmoproject.com
+EMPTYPASSWORD test
+
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+
+PROXY_SERVER 172.16.9.181
+PROXY_PORT 8080
+[Enddefine]
+
+[Test]
+title 75. lm_add_contact
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD GIZMOCONTACT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 76. lm_remove_contact
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD GIZMOCONTACT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 77. lm_subscribe_contact
+create tstlm LmObj
+LmObj lm_subscribe_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 78. lm_send_receive
+create tstlm LmObj
+LmObj lm_connection_send_receive SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 80. lm_send_to_LongGmailUserid
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD LONGGMAILUSERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 81. lm_connection_cancel_open
+create tstlm LmObj
+LmObj lm_connection_cancel_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 82. lm_send_image_bytestream_msg
+create tstlm LmObj
+LmObj lm_connection_send_image_bytestream_msg SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 83. lm_send_image_bytestream_iq
+create tstlm LmObj
+LmObj lm_connection_send_image_bytestream_iq SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 84. lm_get_privacy_lists
+create tstlm LmObj
+LmObj lm_connection_get_privacy_lists SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 85. lm_set_privacy_lists
+create tstlm LmObj
+LmObj lm_connection_set_privacy_lists SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 86. lm_get_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 87. lm_set_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 88. lm_create_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_create_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 89. lm_get_one_unexist_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_unexist_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 90. lm_set_one_unexist_privacy_list
+create tstlm LmObj
+LmObj lm_connection_set_one_unexist_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 91. lm_get_many_privacy_list_from_listname
+create tstlm LmObj
+LmObj lm_connection_get_many_privacy_list_from_listname SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 92. lm_set_active_list
+create tstlm LmObj
+LmObj lm_connection_set_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 93. lm_set_unexist_active_list
+create tstlm LmObj
+LmObj lm_connection_set_unexist_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 94. lm_set_decline_active_list
+create tstlm LmObj
+LmObj lm_connection_set_decline_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 95. lm_block_contact
+create tstlm LmObj
+LmObj lm_connection_block_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 96. lm_unblock_contact
+create tstlm LmObj
+LmObj lm_connection_unblock_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 97. lm_send_multiple_conn
+create tstlm LmObj
+LmObj lm_connection_send_multiple_conn SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 98. lm_service_discovery
+create tstlm LmObj
+LmObj lm_service_discovery SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 99. lm_simple_communications_blocking
+create tstlm LmObj
+LmObj lm_simple_communications_blocking SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 100. lm_service_discovery_connected_resource
+create tstlm LmObj
+LmObj lm_service_discovery_connected_resource SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 101. lm_send_im_with_reply_unexistjid_gizmo
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD UnexistGizmoJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 102. lm_add_contact_unexistjid_gizmo
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD UnexistGizmoJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 103. lm_remove_contact_unexisting_gizmo
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD UnexistGizmoJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 104. lm_add_contact_unexistjid_gtalk
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD UnexistGTalkJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 105. lm_remove_contact_unexisting_gtalk
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD UnexistGTalkJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 106. lm_add_contact_long_gtalkid
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD LONGGMAILUSERID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 107. lm_remove_contact_long_gtalkid
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD LONGGMAILUSERID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 108. lm_send_im_with_reply
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 109. lm_fetching_empty_contactlist
+create tstlm LmObj
+LmObj lm_fetching_contactlist SERVER EMPTYCONTACT EMPTYPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 110. lm_change_own_presence
+create tstlm LmObj
+LmObj lm_change_own_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE
+ PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 111. lm_send_im_with_reply_invalid_gizmo
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD UnexistGizmoJID MESSAGE RES
+OURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 112. lm_send_im_with_reply_invalid_gizmodomain_only
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD OnlyDomainofJID MESSAGE RES
+OURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm_NFT.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,82 @@
+[Define]
+SERVER talk.google.com
+USERNAME nokiaprima@gmail.com
+PASSWORD nokianokia
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+USERNAME1 rakesh.harsh@gmail.com
+PASSWORD1 majisay82
+UnexistGizmoJID testlmnokia1111@chat.gizmoproject.com
+UnexistGTalkJID abcd123_mk@gmail.com
+OnlyDomainofJID @gmail.com
+BadGizmoDomain prima@chat.gizmoooproject.com
+BadGtalkDomain nokiaprima@gmaiiil.com
+badpassword 12345
+badserver talk.goo456gly.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@gmail.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@gmail.com
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+LONGPASSWORD thisisawrongpasswordandthetestcaseshouldnotfail
+SPECIALMESSAGE hello&*&*^#^*)%)@$)*@)(*%%(*!^%@^#%
+EMPTYCONTACT Emptycontact@gmail.com
+EMPTYPASSWORD testtesttest
+EMPTYDOMAIN nokiaprima
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+UsernameWithBadServer prima@talk.goo456gly.com
+
+
+PROXY_SERVER 172.16.42.135
+PROXY_PORT 8080
+
+[Enddefine]
+
+[Test]
+title 1. lm_nft_updating_presence
+create tstlm LmObj
+LmObj lm_nft_updating_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 2. lm_nft_presence_notification
+create tstlm LmObj
+LmObj lm_nft_presence_notification SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 3. lm_nft_send_text_message
+create tstlm LmObj
+LmObj lm_nft_send_text_message SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 4. lm_nft_open_conversation_with_multiple
+create tstlm LmObj
+LmObj lm_nft_open_conversation_with_multiple SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 5. lm_nft_fetch300_contact
+create tstlm LmObj
+LmObj lm_nft_fetch300_contact SERVER USERNAME1 PASSWORD1 RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 6. lm_nft_loginlogoutmultipletime
+create tstlm LmObj
+LmObj lm_nft_loginlogoutmultipletime SERVER USERNAME1 PASSWORD1 RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm_gizmo.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,592 @@
+[Define]
+SERVER chat.gizmoproject.com
+USERNAME prima@chat.gizmoproject.com
+PASSWORD donna
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+
+UnexistGizmoJID testlmnokia1111@chat.gizmoproject.com
+OnlyDomainofJID @chat.gizmoproject.com
+UnexistGTalkJID abcd123_mk@gmail.com
+BadGizmoDomain prima@chat.gizmooo123project.com
+BadGtalkDomain nokiaprima@gmaiiil.com
+badpassword 12345
+badserver chat.gizmoprojeeeect.com
+UsernameWithBadServer testlmnokia@chat.gizmoproj123eeeeect.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGPASSWORD thisisawrongpasswordandthetestcaseshouldnotfail
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+SPECIALMESSAGE hello&*&*^#^*)%)@$)*@)(*%%(*!^%@^#%
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+
+EMPTYCONTACT Emptycontact@chat.gizmoproject.com
+EMPTYPASSWORD test
+EMPTYDOMAIN prima
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+
+
+PROXY_SERVER 172.16.9.181
+PROXY_PORT 8080
+
+[Enddefine]
+
+[Test]
+title 1. lm_connection_new
+create tstlm LmObj
+LmObj lm_connection_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 2. lm_connection_send
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 3. lm_fetching_contactlist
+create tstlm LmObj
+LmObj lm_fetching_contactlist SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 4. lm_fetching_presence
+create tstlm LmObj
+LmObj lm_fetching_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 5. lm_connection_new_with_context
+create tstlm LmObj
+LmObj lm_new_with_context
+delete LmObj
+[Endtest]
+
+[Test]
+title 6. lm_connection_open
+create tstlm LmObj
+LmObj lm_connection_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 7. lm_connection_closeWhenNotOpen
+create tstlm LmObj
+LmObj lm_connection_closeWhenNotOpen SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 8. lm_connection_authenticate
+create tstlm LmObj
+LmObj lm_authenticate SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 9. lm_connection_is_open
+create tstlm LmObj
+LmObj lm_connection_is_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 10. lm_connection_authenticate_withbadpassword
+create tstlm LmObj
+LmObj lm_authenticate_badpassword SERVER USERNAME badpassword RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 11. lm_connection_authenticate when connection is closed
+create tstlm LmObj
+LmObj lm_authenticate_connectionisnotcreated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 12. lm_connection_is_open_WhenConnectionIsClosed
+create tstlm LmObj
+LmObj lm_connection_is_open_WhenConnectionIsClosed SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 13. lm_connection_close
+create tstlm LmObj
+LmObj lm_connection_close SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 14. lm_connection_is_authenticated
+create tstlm LmObj
+LmObj lm_is_authenticated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 15. lm_connection_is_authenticated_WhenNot_Authenticated
+create tstlm LmObj
+LmObj lm_connection_is_authenticated_WhenNot_Authenticated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 16. lm_connection_set_get_server
+create tstlm LmObj
+LmObj lm_connection_set_get_server SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 17. lm_connection_set_get_port
+create tstlm LmObj
+LmObj lm_connection_set_get_port
+delete LmObj
+[Endtest]
+
+[Test]
+title 18. lm_connection_set_get_ssl
+create tstlm LmObj
+LmObj lm_connection_set_get_ssl
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 19. lm_connection_set_get_proxy
+create tstlm LmObj
+LmObj lm_connection_set_get_proxy
+delete LmObj
+[Endtest]
+
+[Test]
+title 20. lm_connection_set_get_jid
+create tstlm LmObj
+LmObj lm_connection_set_get_jid SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 21. lm_connection_set_jid_WithNull
+create tstlm LmObj
+LmObj lm_connection_set_jid_WithNull SERVER \0 PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 22. lm_connection_set_port_WithNULL
+create tstlm LmObj
+LmObj lm_connection_set_port_WithNULL
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 23. lm_connection_set_server_withNULL
+create tstlm LmObj
+LmObj lm_connection_set_server_withNULL \0 USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 24. lm_connection_set_disconnect_function
+create tstlm LmObj
+LmObj set_disconnect_function SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 25. lm_connection_send_with_reply
+create tstlm LmObj
+LmObj lm_send_with_reply SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 26. lm_proxy_set_get_port
+create tstlm LmObj
+LmObj lm_proxy_set_get_port
+delete LmObj
+[Endtest]
+
+[Test]
+title 27. lm_proxy_set_get_type
+create tstlm LmObj
+LmObj lm_proxy_set_get_type
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 28. lm_proxy_set_get_server
+create tstlm LmObj
+LmObj lm_proxy_set_get_server
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 29. lm_proxy_set_get_username
+create tstlm LmObj
+LmObj lm_proxy_set_get_username
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 30. lm_proxy_set_get_password
+create tstlm LmObj
+LmObj lm_proxy_set_get_password
+delete LmObj
+[Endtest]
+
+[Test]
+title 31. lm_proxy_new
+create tstlm LmObj
+LmObj lm_proxy_new
+delete LmObj
+[Endtest]
+
+[Test]
+title 32. lm_proxy_new_with_server
+create tstlm LmObj
+LmObj lm_proxy_new_with_server
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 33. lm_proxy_ref
+create tstlm LmObj
+LmObj lm_proxy_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 34. lm_proxy_unref
+create tstlm LmObj
+LmObj lm_proxy_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 35. lm_ssl_new
+create tstlm LmObj
+LmObj lm_ssl_new
+delete LmObj
+[Endtest]
+
+[Test]
+title 36. lm_ssl_is_supported
+create tstlm LmObj
+LmObj lm_ssl_is_supported
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 37. lm_ssl_get_fingerprint
+create tstlm LmObj
+LmObj lm_ssl_get_fingerprint
+delete LmObj
+[Endtest]
+
+[Test]
+title 38. lm_ssl_ref
+create tstlm LmObj
+LmObj lm_ssl_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 39. lm_ssl_unref
+create tstlm LmObj
+LmObj lm_ssl_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 40. lm_message_node_ref
+create tstlm LmObj
+LmObj lm_message_node_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 41. lm_message_node_unref
+create tstlm LmObj
+LmObj lm_message_node_unref
+delete LmObj
+[Endtest]
+
+[Test]
+title 42. lm_message_node_to_string
+create tstlm LmObj
+LmObj lm_message_node_to_string
+delete LmObj
+[Endtest]
+
+
+\\failed when run together. passed independantly
+[Test]
+title 43. lm_message_node_set_get_attributes
+create tstlm LmObj
+LmObj lm_message_node_set_get_attributes
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 44. lm_message_node_set_get_raw_mode
+create tstlm LmObj
+LmObj lm_message_node_set_get_raw_mode
+delete LmObj
+[Endtest]
+
+\\failed when run together. passed independantly
+[Test]
+title 45. lm_message_node_add_child
+create tstlm LmObj
+LmObj lm_message_node_add_child
+delete LmObj
+[Endtest]
+
+[Test]
+title 46. lm_message_node_get_child
+create tstlm LmObj
+LmObj lm_message_node_get_child
+delete LmObj
+[Endtest]
+
+[Test]
+title 47. lm_message_node_find_child
+create tstlm LmObj
+LmObj lm_message_node_find_child
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 48. lm_message_node_set_get_value
+create tstlm LmObj
+LmObj lm_message_node_set_get_value
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 49. lm_message_handler_new
+create tstlm LmObj
+LmObj lm_message_handler_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 50. lm_message_handler_invalidate
+create tstlm LmObj
+LmObj lm_message_handler_invalidate
+delete LmObj
+[Endtest]
+
+[Test]
+title 51. lm_message_handler_is_valid
+create tstlm LmObj
+LmObj lm_message_handler_is_valid
+delete LmObj
+[Endtest]
+
+[Test]
+title 52. lm_message_handler_ref
+create tstlm LmObj
+LmObj lm_message_handler_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 53. lm_message_handler_unref
+create tstlm LmObj
+LmObj lm_message_handler_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 54. lm_message_new
+create tstlm LmObj
+LmObj lm_message_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 55. lm_message_new_with_sub_type
+create tstlm LmObj
+LmObj lm_message_new_with_sub_type SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 56. lm_message_get_type
+create tstlm LmObj
+LmObj lm_message_get_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 57. lm_message_get_sub_type
+create tstlm LmObj
+LmObj lm_message_get_sub_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 58. lm_message_get_node
+create tstlm LmObj
+LmObj lm_message_get_node
+delete LmObj
+[Endtest]
+
+[Test]
+title 59. lm_message_ref
+create tstlm LmObj
+LmObj lm_message_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 60. lm_message_unref
+create tstlm LmObj
+LmObj lm_message_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 61. lm_connection_get_state
+create tstlm LmObj
+LmObj lm_connection_get_state SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 62. lm_connection_ref
+create tstlm LmObj
+LmObj lm_connection_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 63. lm_connection_unref
+create tstlm LmObj
+LmObj lm_connection_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 64. lm_connection_send_raw
+create tstlm LmObj
+LmObj lm_connection_send_raw SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 65. lm_register_message_handler
+create tstlm LmObj
+LmObj register_message_handler SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 66. lm_set_ssl_WithNULL
+create tstlm LmObj
+LmObj lm_connection_set_ssl_WithNULL
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 67. lm_connection_authenticate_withUnexistJID
+create tstlm LmObj
+LmObj lm_authenticate_unexistjid SERVER UnexistGizmoJID PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 68. lm_login_test_with_SpecialChar_JID
+create tstlm LmObj
+LmObj lm_login_test SERVER SpecialUSERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 69. lm_login_test_with_Long_JID
+create tstlm LmObj
+LmObj lm_login_test SERVER LONGUSERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 70. lm_login_test_with_Long_PASSWORD
+create tstlm LmObj
+LmObj lm_login_test SERVER USERNAME LONGPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 71. lm_send_long_message
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT LONGMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 72. lm_send_400chars
+create tstlm LmObj
+LmObj lm_connection_send400char SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 73. lm_send_repeated
+create tstlm LmObj
+LmObj lm_connection_send_repeated SERVER USERNAME PASSWORD RECIPIENT REPEATEDMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 74. lm_send_smiley
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm_gizmo1.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,356 @@
+[Define]
+SERVER chat.gizmoproject.com
+USERNAME prima@chat.gizmoproject.com
+PASSWORD donna
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+
+UnexistGizmoJID testlmnokia1111@chat.gizmoproject.com
+OnlyDomainofJID @chat.gizmoproject.com
+UnexistGTalkJID abcd123_mk@gmail.com
+BadGizmoDomain prima@chat.gizmo123ooproject.com
+badpassword 12345
+badserver chat.gizmop123rojeeeect.com
+UsernameWithBadServer testlmnokia@chat.gizmoprojeeeeect.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@chat.gizmoproject.com
+LONGPASSWORD loudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouthloudmouth
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+SPECIALMESSAGE hello&*&*^#^*)%)@$)*@)(*%%(*!^%@^#%
+EMPTYCONTACT Emptycontact@chat.gizmoproject.com
+EMPTYPASSWORD test
+
+EMPTYDOMAIN prima
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+
+PROXY_SERVER 172.16.9.181
+PROXY_PORT 8080
+[Enddefine]
+
+[Test]
+title 75. lm_add_contact
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD GIZMOCONTACT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 76. lm_remove_contact
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD GIZMOCONTACT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 77. lm_subscribe_contact
+create tstlm LmObj
+LmObj lm_subscribe_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 78. lm_send_receive
+create tstlm LmObj
+LmObj lm_connection_send_receive SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 80. lm_send_to_LongGmailUserid
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD LONGGMAILUSERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 81. lm_connection_cancel_open
+create tstlm LmObj
+LmObj lm_connection_cancel_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 82. lm_send_image_bytestream_msg
+create tstlm LmObj
+LmObj lm_connection_send_image_bytestream_msg SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 83. lm_send_image_bytestream_iq
+create tstlm LmObj
+LmObj lm_connection_send_image_bytestream_iq SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 84. lm_get_privacy_lists
+create tstlm LmObj
+LmObj lm_connection_get_privacy_lists SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 85. lm_set_privacy_lists
+create tstlm LmObj
+LmObj lm_connection_set_privacy_lists SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 86. lm_get_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 87. lm_set_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 88. lm_create_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_create_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 89. lm_get_one_unexist_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_unexist_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 90. lm_set_one_unexist_privacy_list
+create tstlm LmObj
+LmObj lm_connection_set_one_unexist_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 91. lm_get_many_privacy_list_from_listname
+create tstlm LmObj
+LmObj lm_connection_get_many_privacy_list_from_listname SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 92. lm_set_active_list
+create tstlm LmObj
+LmObj lm_connection_set_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 93. lm_set_unexist_active_list
+create tstlm LmObj
+LmObj lm_connection_set_unexist_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 94. lm_set_decline_active_list
+create tstlm LmObj
+LmObj lm_connection_set_decline_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 95. lm_block_contact
+create tstlm LmObj
+LmObj lm_connection_block_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 96. lm_unblock_contact
+create tstlm LmObj
+LmObj lm_connection_unblock_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 97. lm_send_multiple_conn
+create tstlm LmObj
+LmObj lm_connection_send_multiple_conn SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 98. lm_service_discovery
+create tstlm LmObj
+LmObj lm_service_discovery SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 99. lm_simple_communications_blocking
+create tstlm LmObj
+LmObj lm_simple_communications_blocking SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 100. lm_service_discovery_connected_resource
+create tstlm LmObj
+LmObj lm_service_discovery_connected_resource SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 101. lm_send_im_with_reply_unexistjid_gizmo
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD UnexistGizmoJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 102. lm_add_contact_unexistjid_gizmo
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD UnexistGizmoJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 103. lm_remove_contact_unexisting_gizmo
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD UnexistGizmoJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 104. lm_add_contact_unexistjid_gtalk
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD UnexistGTalkJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 105. lm_remove_contact_unexisting_gtalk
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD UnexistGTalkJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 106. lm_add_contact_long_gtalkid
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD LONGGMAILUSERID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 107. lm_remove_contact_long_gtalkid
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD LONGGMAILUSERID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 108. lm_send_im_with_reply
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 109. lm_fetching_empty_contactlist
+create tstlm LmObj
+LmObj lm_fetching_contactlist SERVER EMPTYCONTACT EMPTYPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 110. lm_change_own_presence
+create tstlm LmObj
+LmObj lm_change_own_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 111. lm_send_im_with_reply_invalid_gizmo
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD UnexistGizmoJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 112. lm_send_im_with_reply_invalid_gizmodomain_only
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD OnlyDomainofJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 113. lm_send_message_with_special_char
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT SPECIALMESSAGE RESOU
+RCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 114. lm_login_test_with_blank_username
+create tstlm LmObj
+LmObj lm_login_test SERVER \0 PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER P
+ROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 115. lm_login_test_with_blank_password
+create tstlm LmObj
+LmObj lm_login_test SERVER USERNAME \0 RECIPIENT MESSAGE RESOURCE PROXY_SERVER P
+ROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 116. lm_login_test_empty_domain
+create tstlm LmObj
+LmObj lm_login_test SERVER EMPTYDOMAIN PASSWORD RECIPIENT MESSAGE RESOURCE PROXY
+_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 117. lm_login_test_invalid_port
+create tstlm LmObj
+LmObj lm_login_test_invalid_port SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 118. lm_login_test_invalid_server
+create tstlm LmObj
+LmObj lm_login_test_invalid_server badserver USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 79. lm_login_test_invalid_domain
+create tstlm LmObj
+LmObj lm_login_test_invalid_server SERVER BadGtalkDomain PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm_gtalk.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,591 @@
+[Define]
+SERVER talk.google.com
+USERNAME nokiaprima@gmail.com
+PASSWORD nokianokia
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+
+UnexistGizmoJID testlmnokia1111@chat.gizmoproject.com
+UnexistGTalkJID abcd123_mk@gmail.com
+OnlyDomainofJID @gmail.com
+BadGizmoDomain prima@chat.gizmoooproject.com
+BadGtalkDomain nokiaprima@gmaiiil.com
+badpassword 12345
+badserver talk.goo456gly.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@gmail.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@gmail.com
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+LONGPASSWORD thisisawrongpasswordandthetestcaseshouldnotfail
+SPECIALMESSAGE hello&*&*^#^*)%)@$)*@)(*%%(*!^%@^#%
+EMPTYCONTACT Emptycontact@gmail.com
+EMPTYPASSWORD testtesttest
+EMPTYDOMAIN nokiaprima
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+UsernameWithBadServer prima@talk.goo456gly.com
+
+
+PROXY_SERVER 172.16.42.135
+PROXY_PORT 8080
+
+[Enddefine]
+
+[Test]
+title 1. lm_connection_new
+create tstlm LmObj
+LmObj lm_connection_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 2. lm_connection_send
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 3. lm_fetching_contactlist
+create tstlm LmObj
+LmObj lm_fetching_contactlist SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 4. lm_fetching_presence
+create tstlm LmObj
+LmObj lm_fetching_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 5. lm_connection_new_with_context
+create tstlm LmObj
+LmObj lm_new_with_context
+delete LmObj
+[Endtest]
+
+[Test]
+title 6. lm_connection_open
+create tstlm LmObj
+LmObj lm_connection_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 7. lm_connection_closeWhenNotOpen
+create tstlm LmObj
+LmObj lm_connection_closeWhenNotOpen SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 8. lm_connection_authenticate
+create tstlm LmObj
+LmObj lm_authenticate SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 9. lm_connection_is_open
+create tstlm LmObj
+LmObj lm_connection_is_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 10. lm_connection_authenticate_withbadpassword
+create tstlm LmObj
+LmObj lm_authenticate_badpassword SERVER USERNAME badpassword RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 11. lm_connection_authenticate when connection is closed
+create tstlm LmObj
+LmObj lm_authenticate_connectionisnotcreated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 12. lm_connection_is_open_WhenConnectionIsClosed
+create tstlm LmObj
+LmObj lm_connection_is_open_WhenConnectionIsClosed SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 13. lm_connection_close
+create tstlm LmObj
+LmObj lm_connection_close SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 14. lm_connection_is_authenticated
+create tstlm LmObj
+LmObj lm_is_authenticated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 15. lm_connection_is_authenticated_WhenNot_Authenticated
+create tstlm LmObj
+LmObj lm_connection_is_authenticated_WhenNot_Authenticated SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 16. lm_connection_set_get_server
+create tstlm LmObj
+LmObj lm_connection_set_get_server SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 17. lm_connection_set_get_port
+create tstlm LmObj
+LmObj lm_connection_set_get_port
+delete LmObj
+[Endtest]
+
+[Test]
+title 18. lm_connection_set_get_ssl
+create tstlm LmObj
+LmObj lm_connection_set_get_ssl
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 19. lm_connection_set_get_proxy
+create tstlm LmObj
+LmObj lm_connection_set_get_proxy
+delete LmObj
+[Endtest]
+
+[Test]
+title 20. lm_connection_set_get_jid
+create tstlm LmObj
+LmObj lm_connection_set_get_jid SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 21. lm_connection_set_jid_WithNull
+create tstlm LmObj
+LmObj lm_connection_set_jid_WithNull SERVER \0 PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 22. lm_connection_set_port_WithNULL
+create tstlm LmObj
+LmObj lm_connection_set_port_WithNULL
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 23. lm_connection_set_server_withNULL
+create tstlm LmObj
+LmObj lm_connection_set_server_withNULL \0 USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 24. lm_connection_set_disconnect_function
+create tstlm LmObj
+LmObj set_disconnect_function SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 25. lm_connection_send_with_reply
+create tstlm LmObj
+LmObj lm_send_with_reply SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 26. lm_proxy_set_get_port
+create tstlm LmObj
+LmObj lm_proxy_set_get_port
+delete LmObj
+[Endtest]
+
+[Test]
+title 27. lm_proxy_set_get_type
+create tstlm LmObj
+LmObj lm_proxy_set_get_type
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 28. lm_proxy_set_get_server
+create tstlm LmObj
+LmObj lm_proxy_set_get_server
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 29. lm_proxy_set_get_username
+create tstlm LmObj
+LmObj lm_proxy_set_get_username
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 30. lm_proxy_set_get_password
+create tstlm LmObj
+LmObj lm_proxy_set_get_password
+delete LmObj
+[Endtest]
+
+[Test]
+title 31. lm_proxy_new
+create tstlm LmObj
+LmObj lm_proxy_new
+delete LmObj
+[Endtest]
+
+[Test]
+title 32. lm_proxy_new_with_server
+create tstlm LmObj
+LmObj lm_proxy_new_with_server
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 33. lm_proxy_ref
+create tstlm LmObj
+LmObj lm_proxy_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 34. lm_proxy_unref
+create tstlm LmObj
+LmObj lm_proxy_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 35. lm_ssl_new
+create tstlm LmObj
+LmObj lm_ssl_new
+delete LmObj
+[Endtest]
+
+[Test]
+title 36. lm_ssl_is_supported
+create tstlm LmObj
+LmObj lm_ssl_is_supported
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 37. lm_ssl_get_fingerprint
+create tstlm LmObj
+LmObj lm_ssl_get_fingerprint
+delete LmObj
+[Endtest]
+
+[Test]
+title 38. lm_ssl_ref
+create tstlm LmObj
+LmObj lm_ssl_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 39. lm_ssl_unref
+create tstlm LmObj
+LmObj lm_ssl_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 40. lm_message_node_ref
+create tstlm LmObj
+LmObj lm_message_node_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 41. lm_message_node_unref
+create tstlm LmObj
+LmObj lm_message_node_unref
+delete LmObj
+[Endtest]
+
+[Test]
+title 42. lm_message_node_to_string
+create tstlm LmObj
+LmObj lm_message_node_to_string
+delete LmObj
+[Endtest]
+
+
+\\failed when run together. passed independantly
+[Test]
+title 43. lm_message_node_set_get_attributes
+create tstlm LmObj
+LmObj lm_message_node_set_get_attributes
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 44. lm_message_node_set_get_raw_mode
+create tstlm LmObj
+LmObj lm_message_node_set_get_raw_mode
+delete LmObj
+[Endtest]
+
+\\failed when run together. passed independantly
+[Test]
+title 45. lm_message_node_add_child
+create tstlm LmObj
+LmObj lm_message_node_add_child
+delete LmObj
+[Endtest]
+
+[Test]
+title 46. lm_message_node_get_child
+create tstlm LmObj
+LmObj lm_message_node_get_child
+delete LmObj
+[Endtest]
+
+[Test]
+title 47. lm_message_node_find_child
+create tstlm LmObj
+LmObj lm_message_node_find_child
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 48. lm_message_node_set_get_value
+create tstlm LmObj
+LmObj lm_message_node_set_get_value
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 49. lm_message_handler_new
+create tstlm LmObj
+LmObj lm_message_handler_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 50. lm_message_handler_invalidate
+create tstlm LmObj
+LmObj lm_message_handler_invalidate
+delete LmObj
+[Endtest]
+
+[Test]
+title 51. lm_message_handler_is_valid
+create tstlm LmObj
+LmObj lm_message_handler_is_valid
+delete LmObj
+[Endtest]
+
+[Test]
+title 52. lm_message_handler_ref
+create tstlm LmObj
+LmObj lm_message_handler_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 53. lm_message_handler_unref
+create tstlm LmObj
+LmObj lm_message_handler_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 54. lm_message_new
+create tstlm LmObj
+LmObj lm_message_new SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 55. lm_message_new_with_sub_type
+create tstlm LmObj
+LmObj lm_message_new_with_sub_type SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 56. lm_message_get_type
+create tstlm LmObj
+LmObj lm_message_get_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 57. lm_message_get_sub_type
+create tstlm LmObj
+LmObj lm_message_get_sub_type
+delete LmObj
+[Endtest]
+
+[Test]
+title 58. lm_message_get_node
+create tstlm LmObj
+LmObj lm_message_get_node
+delete LmObj
+[Endtest]
+
+[Test]
+title 59. lm_message_ref
+create tstlm LmObj
+LmObj lm_message_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 60. lm_message_unref
+create tstlm LmObj
+LmObj lm_message_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 61. lm_connection_get_state
+create tstlm LmObj
+LmObj lm_connection_get_state SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 62. lm_connection_ref
+create tstlm LmObj
+LmObj lm_connection_ref
+delete LmObj
+[Endtest]
+
+[Test]
+title 63. lm_connection_unref
+create tstlm LmObj
+LmObj lm_connection_unref
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 64. lm_connection_send_raw
+create tstlm LmObj
+LmObj lm_connection_send_raw SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 65. lm_register_message_handler
+create tstlm LmObj
+LmObj register_message_handler SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+[Test]
+title 66. lm_set_ssl_WithNULL
+create tstlm LmObj
+LmObj lm_connection_set_ssl_WithNULL
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 67. lm_connection_authenticate_withUnexistJID
+create tstlm LmObj
+LmObj lm_authenticate_unexistjid SERVER UnexistGtalkJID PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 68. lm_login_test_with_SpecialChar_JID
+create tstlm LmObj
+LmObj lm_login_test SERVER SpecialUSERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 69. lm_login_test_with_Long_JID
+create tstlm LmObj
+LmObj lm_login_test SERVER LONGGMAILUSERID GMAILPWD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 70. lm_login_test_with_Long_PASSWORD
+create tstlm LmObj
+LmObj lm_login_test SERVER USERNAME LONGPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 71. lm_send_long_message
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT LONGMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 72. lm_send_400chars
+create tstlm LmObj
+LmObj lm_connection_send400char SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 73. lm_send_repeated
+create tstlm LmObj
+LmObj lm_connection_send_repeated SERVER USERNAME PASSWORD RECIPIENT REPEATEDMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 74. lm_send_smiley
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME PASSWORD RECIPIENT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/conf/tstlm_gtalk1.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,313 @@
+[Define]
+SERVER talk.google.com
+USERNAME nokiaprima@gmail.com
+PASSWORD nokianokia
+RECIPIENT donna.prima@gmail.com
+MESSAGE Hello
+RESOURCE mytesds5rt123
+
+UnexistGTalkJID abcd123_mk@gmail.com
+OnlyDomainofJID @gmail.com
+UnexistGizmoJID primaunexist@chat.gizmoproject.com
+BadGizmoDomain prima@chat.gizmoooproject.com
+BadGtalkDomain nokiaprima@gmaiiil.com
+badpassword 12345
+badserver talk.goo456gly.com
+SpecialUSERNAME im:here%27s_a_wild_%26_%2Fcr%zy%2F_address@gmail.com
+LONGUSERNAME im:here%27s_a_wild_%26_%2Fr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address_here%27s_a_wild_%26_%2Fcr%zy%2F_address@gmail.com
+LONGMESSAGE HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworlsfsdfdgdfgdfgdfgdfgdf
+REPEATEDMESSAGE RepeatingHello
+SMILEYMESSAGE :):-);-):-D:D:-(:(
+GIZMOCONTACT harsh_rakesh@chat.gizmoproject.com
+LONGPASSWORD thisisawrongpasswordandthetestcaseshouldnotfail
+SPECIALMESSAGE hello&*&*^#^*)%)@$)*@)(*%%(*!^%@^#%
+EMPTYCONTACT Emptycontact@gmail.com
+EMPTYPASSWORD testtesttest
+EMPTYDOMAIN nokiaprima
+LONGGMAILUSERID abcd123456abcd123456abcd123456@gmail.com
+GMAILPWD nokia123
+UsernameWithBadServer prima@talk.goo456gly.com
+
+PROXY_SERVER 172.16.42.135
+PROXY_PORT 8080
+[Enddefine]
+
+[Test]
+title 75. lm_add_contact
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD GIZMOCONTACT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 76. lm_remove_contact
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD GIZMOCONTACT SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 77. lm_subscribe_contact
+create tstlm LmObj
+LmObj lm_subscribe_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 78. lm_send_receive
+create tstlm LmObj
+LmObj lm_connection_send_receive SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 79. lm_login_test_invalid_domain
+create tstlm LmObj
+LmObj lm_login_test_invalid_server SERVER BadGtalkDomain PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 80. lm_send_to_LongGmailUserid
+create tstlm LmObj
+LmObj lm_connection_send SERVER USERNAME GMAILPWD LONGGMAILUSERID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 81. lm_connection_cancel_open
+create tstlm LmObj
+LmObj lm_connection_cancel_open SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 82. lm_send_image_bytestream_msg
+create tstlm LmObj
+LmObj lm_connection_send_image_bytestream_msg SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 83. lm_send_image_bytestream_iq
+create tstlm LmObj
+LmObj lm_connection_send_image_bytestream_iq SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 84. lm_get_privacy_lists
+create tstlm LmObj
+LmObj lm_connection_get_privacy_lists SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 85. lm_set_privacy_lists
+create tstlm LmObj
+LmObj lm_connection_set_privacy_lists SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 86. lm_get_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 87. lm_set_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 88. lm_create_one_privacy_list
+create tstlm LmObj
+LmObj lm_connection_create_one_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 89. lm_get_one_unexist_privacy_list
+create tstlm LmObj
+LmObj lm_connection_get_one_unexist_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 90. lm_set_one_unexist_privacy_list
+create tstlm LmObj
+LmObj lm_connection_set_one_unexist_privacy_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 91. lm_get_many_privacy_list_from_listname
+create tstlm LmObj
+LmObj lm_connection_get_many_privacy_list_from_listname SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 92. lm_set_active_list
+create tstlm LmObj
+LmObj lm_connection_set_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 93. lm_set_unexist_active_list
+create tstlm LmObj
+LmObj lm_connection_set_unexist_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 94. lm_set_decline_active_list
+create tstlm LmObj
+LmObj lm_connection_set_decline_active_list SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 95. lm_block_contact
+create tstlm LmObj
+LmObj lm_connection_block_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 96. lm_unblock_contact
+create tstlm LmObj
+LmObj lm_connection_unblock_contact SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 97. lm_send_multiple_conn
+create tstlm LmObj
+LmObj lm_connection_send_multiple_conn SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 98. lm_service_discovery
+create tstlm LmObj
+LmObj lm_service_discovery SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 99. lm_simple_communications_blocking
+create tstlm LmObj
+LmObj lm_simple_communications_blocking SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 100. lm_service_discovery_connected_resource
+create tstlm LmObj
+LmObj lm_service_discovery_connected_resource SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 101. lm_send_im_with_reply_unexistjid_gizmo
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD UnexistGizmoJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 102. lm_add_contact_unexistjid_gizmo
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD UnexistGizmoJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 103. lm_remove_contact_unexisting_gizmo
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD UnexistGizmoJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 104. lm_add_contact_unexistjid_gtalk
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD UnexistGTalkJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 105. lm_remove_contact_unexisting_gtalk
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD UnexistGTalkJID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 106. lm_add_contact_long_gtalkid
+create tstlm LmObj
+LmObj lm_add_contact SERVER USERNAME PASSWORD LONGGMAILUSERID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 107. lm_remove_contact_long_gtalkid
+create tstlm LmObj
+LmObj lm_remove_contact SERVER USERNAME PASSWORD LONGGMAILUSERID SMILEYMESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+[Test]
+title 108. lm_send_im_with_reply
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 109. lm_fetching_empty_contactlist
+create tstlm LmObj
+LmObj lm_fetching_contactlist SERVER EMPTYCONTACT EMPTYPASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 110. lm_change_own_presence
+create tstlm LmObj
+LmObj lm_change_own_presence SERVER USERNAME PASSWORD RECIPIENT MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 111. lm_send_im_with_reply_invalid_gtalk
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD UnexistGTalkJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+[Test]
+title 112. lm_send_im_with_reply_invalid_gtalkdomain_only
+create tstlm LmObj
+LmObj lm_send_im_with_reply SERVER USERNAME PASSWORD OnlyDomainofJID MESSAGE RESOURCE PROXY_SERVER PROXY_PORT
+delete LmObj
+[Endtest]
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/eabi/tstlmu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ?Description
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+../init/TestFramework.ini /epoc32/winscw/c/TestFramework/TestFramework.ini
+../conf/tstlm_gtalk.cfg /epoc32/winscw/c/TestFramework/tstlm_gtalk.cfg
+../conf/tstlm_gtalk1.cfg /epoc32/winscw/c/TestFramework/tstlm_gtalk1.cfg
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example:
+
+
+
+PRJ_TESTMMPFILES
+// NOTE: If using ARS requirements .mmp file operation should be done under this.
+// 'abld test build'
+tstlm.mmp
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+//tstlm.mmp
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/group/tstlm.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ?Description
+*
+*/
+
+
+#include<platform_paths.hrh>
+TARGET tstlm.dll
+TARGETTYPE dll
+UID 0x1000008D 0x101FB3E3
+
+CAPABILITY ALL -TCB
+
+
+//TARGETPATH ?target_path
+DEFFILE tstlm.def
+
+MACRO SYMBIAN
+
+
+SOURCEPATH ../src
+SOURCE tstlm.cpp
+SOURCE tstlmBlocks.cpp
+
+//RESOURCE resource_file
+//RESOURCE resource_file2
+
+USERINCLUDE ../inc
+
+SYSTEMINCLUDE /epoc32/include
+SYSTEMINCLUDE /epoc32/include/internal
+
+//SYSTEMINCLUDE /epoc32/include/domain/osextensions
+USERINCLUDE ../../inc
+//#ifdef __S60_32__
+SYSTEMINCLUDE /epoc32/include/stdapis
+//SYSTEMINCLUDE /epoc32/include/stdapis/glib-2.0
+//SYSTEMINCLUDE /epoc32/include/stdapis/glib-2.0/glib
+//SYSTEMINCLUDE /epoc32/include/stdapis/openssl
+//#endif
+
+//#ifndef __S60_50__
+//SYSTEMINCLUDE /epoc32/include/osextensions/stdapis
+//SYSTEMINCLUDE /epoc32/include/osextensions/stdapis/glib-2.0
+//SYSTEMINCLUDE /epoc32/include/osextensions/stdapis/glib-2.0/glib
+//SYSTEMINCLUDE /epoc32/include/osextensions/stdapis/openssl
+//#endif
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_BOOST_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+OS_LAYER_LIBUTILITY_SYSTEMINCLUDE
+
+
+
+
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+LIBRARY libc.lib
+LIBRARY libpthread.lib
+LIBRARY libglib.lib
+LIBRARY loudmouth.lib
+
+LANG SC
+
+//EPOCALLOWDLLDATA
+
+/*
+START WINS
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+
+// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH ?emulated_path_on_target_machine
+HEADER
+SOURCE ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/group/tstlm.pkg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,66 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the License "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\tstlm.dll" - "!:\Sys\Bin\tstlm.dll"
+;CFG FILES
+"..\conf\tstlm_gtalk.cfg"-"C:\TestFramework\tstlm_gtalk.cfg"
+"..\conf\tstlm_gtalk1.cfg"-"C:\TestFramework\tstlm_gtalk1.cfg"
+"..\init\TestFramework.ini"-"C:\TestFramework\TestFramework.ini"
+
+;ini file
+"..\init\TestFramework.ini"-"C:\TestFramework\TestFramework.ini"
+
+
+; Embedded SIS
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/inc/tstlm.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,314 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: tstlm.h
+*
+*/
+
+
+
+
+#ifndef TSTLM_H
+#define TSTLM_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+// Logging path
+_LIT( KtstlmLogPath, "\\logs\\testframework\\tstlm\\" );
+// Log file
+_LIT( KtstlmLogFile, "tstlm.txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class Ctstlm;
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+* Ctstlm test class for STIF Test Framework TestScripter.
+* ?other_description_lines
+*
+* @lib ?library
+* @since ?Series60_version
+*/
+NONSHARABLE_CLASS(Ctstlm) : public CScriptBase
+ {
+ public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static Ctstlm* NewL( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * Destructor.
+ */
+ virtual ~Ctstlm();
+
+ public: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ public: // Functions from base classes
+
+ /**
+ * From CScriptBase Runs a script line.
+ * @since ?Series60_version
+ * @param aItem Script line containing method name and parameters
+ * @return Symbian OS error code
+ */
+ virtual TInt RunMethodL( CStifItemParser& aItem );
+
+ protected: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ protected: // Functions from base classes
+
+ /**
+ * From ?base_class ?member_description
+ */
+ //?type ?member_function();
+
+ private:
+
+ /**
+ * C++ default constructor.
+ */
+ Ctstlm( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ // Prohibit copy constructor if not deriving from CBase.
+ // ?classname( const ?classname& );
+ // Prohibit assigment operator if not deriving from CBase.
+ // ?classname& operator=( const ?classname& );
+
+ /**
+ * Frees all resources allocated from test methods.
+ * @since ?Series60_version
+ */
+ void Delete();
+
+ /**
+ * Test methods are listed below.
+ */
+
+ /**
+ * Example test method.
+ * @since ?Series60_version
+ * @param aItem Script line containing parameters.
+ * @return Symbian OS error code.
+ */
+
+ // LmConnection
+ virtual TInt lm_connection_newL( CStifItemParser& aItem );
+ virtual TInt lm_new_with_contextL( CStifItemParser& aItem );
+ virtual TInt lm_connection_openL( CStifItemParser& aItem );
+ virtual TInt lm_connection_closeL ( CStifItemParser& aItem );
+ virtual TInt lm_authenticateL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_is_openL ( CStifItemParser& aItem );
+ virtual TInt lm_is_authenticatedL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_get_serverL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_get_jidL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_get_portL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_get_sslL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_get_proxyL ( CStifItemParser& aItem );
+
+ virtual TInt lm_connection_sendL(CStifItemParser& aItem );
+ virtual TInt lm_connection_send400charL(CStifItemParser& aItem );
+ virtual TInt lm_connection_send_repeatedL(CStifItemParser& aItem );
+
+
+ virtual TInt lm_send_with_replyL ( CStifItemParser& aItem );
+ virtual TInt register_message_handlerL ( CStifItemParser& aItem );
+ virtual TInt set_disconnect_functionL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_send_rawL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_get_stateL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_refL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_unrefL ( CStifItemParser& aItem );
+
+ virtual TInt lm_connection_is_open_WhenConnectionIsClosedL ( CStifItemParser& aItem );
+ virtual TInt lm_is_authenticated_WhenNotAuthenticatedL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_server_WithNULL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_jid_WithNULL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_port_WithNULL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_set_ssl_WithNULL ( CStifItemParser& aItem );
+ virtual TInt lm_connection_closeWhenNotOpenedL ( CStifItemParser& aItem );
+ // LmMessage
+ virtual TInt lm_message_newL ( CStifItemParser& aItem );
+ virtual TInt lm_message_new_with_sub_typeL ( CStifItemParser& aItem );
+ virtual TInt lm_message_get_typeL ( CStifItemParser& aItem );
+ virtual TInt lm_message_get_sub_typeL ( CStifItemParser& aItem );
+ virtual TInt lm_message_get_nodeL ( CStifItemParser& aItem );
+ virtual TInt lm_message_refL ( CStifItemParser& aItem );
+ virtual TInt lm_message_unrefL ( CStifItemParser& aItem );
+
+ // LmMessageHanlder
+ virtual TInt lm_message_handler_newL ( CStifItemParser& aItem );
+ virtual TInt lm_message_handler_invalidateL ( CStifItemParser& aItem );
+ virtual TInt lm_message_handler_is_validL ( CStifItemParser& aItem );
+ virtual TInt lm_message_handler_refL ( CStifItemParser& aItem );
+ virtual TInt lm_message_handler_unrefL ( CStifItemParser& aItem );
+
+ // LmMessageNode
+
+ virtual TInt lm_message_node_set_get_valueL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_add_childL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_get_childL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_find_childL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_set_get_attributesL ( CStifItemParser& aItem );
+
+
+ virtual TInt lm_message_node_set_get_raw_modeL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_refL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_unrefL ( CStifItemParser& aItem );
+ virtual TInt lm_message_node_to_stringL ( CStifItemParser& aItem );
+
+ // LmSSL
+ virtual TInt lm_ssl_newL( CStifItemParser& aItem );
+ virtual TInt lm_ssl_is_supportedL( CStifItemParser& aItem );
+ virtual TInt lm_ssl_get_fingerprintL( CStifItemParser& aItem );
+ virtual TInt lm_ssl_refL( CStifItemParser& aItem );
+ virtual TInt lm_ssl_unrefL( CStifItemParser& aItem );
+
+ // LmProxy
+ virtual TInt lm_proxy_newL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_new_with_serverL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_set_get_typeL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_set_get_serverL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_set_get_portL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_set_get_usernameL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_set_get_passwordL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_refL( CStifItemParser& aItem );
+ virtual TInt lm_proxy_unrefL( CStifItemParser& aItem );
+
+ // lm-send-sync example
+ virtual TInt lm_send_syncL ( CStifItemParser& aItem );
+
+ //fetching contact list
+
+ virtual TInt lm_fetching_contactlist_L( CStifItemParser& aItem );
+
+ virtual TInt lm_fetching_presenceL( CStifItemParser& aItem );
+
+ // subscribe presence for contact
+
+ virtual TInt lm_subscribe_contact_L( CStifItemParser& aItem );
+
+
+ virtual TInt lm_authenticate_WithUnexistingJID( CStifItemParser& aItem );
+ virtual TInt lm_authenticate_WithBadPasswordL( CStifItemParser& aItem );
+ virtual TInt lm_authenticate_WhenConnectionIsNotOpenedL( CStifItemParser& aItem );
+ virtual TInt lm_connection_open_with_badserverL(CStifItemParser& aItem);
+
+ virtual TInt lm_connection_send_receiveL(CStifItemParser& aItem);
+ virtual TInt lm_login_testL(CStifItemParser& aItem);
+
+ virtual TInt lm_add_contactL(CStifItemParser& aItem);
+ virtual TInt lm_remove_contactL(CStifItemParser& aItem);
+ virtual TInt lm_connection_cancel_openL(CStifItemParser& aItem);
+ virtual TInt lm_connection_get_privacy_listsL(CStifItemParser& aItem);
+ virtual TInt lm_connection_set_privacy_listsL(CStifItemParser& aItem);
+ virtual TInt lm_connection_send_image_bytestream_msgL(CStifItemParser& aItem);
+ virtual TInt lm_connection_send_image_bytestream_iqL(CStifItemParser& aItem);
+ virtual TInt lm_connection_send_multiple_connL(CStifItemParser& aItem);
+ virtual TInt lm_connection_block_contactL(CStifItemParser& aItem);
+ virtual TInt lm_connection_unblock_contactL(CStifItemParser& aItem);
+ virtual TInt lm_connection_set_active_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_set_unexist_active_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_set_decline_active_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_get_one_privacy_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_set_one_privacy_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_get_many_privacy_list_from_listnameL(CStifItemParser& aItem);
+ virtual TInt lm_connection_set_one_unexist_privacy_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_get_one_unexist_privacy_listL(CStifItemParser& aItem);
+ virtual TInt lm_connection_create_one_privacy_listL(CStifItemParser& aItem);
+ virtual TInt lm_service_discoveryL(CStifItemParser& aItem);
+ virtual TInt lm_service_discovery_connected_resourceL(CStifItemParser& aItem);
+ virtual TInt lm_simple_communications_blockingL(CStifItemParser& aItem);
+ virtual TInt lm_send_im_with_replyL(CStifItemParser& aItem);
+ virtual TInt lm_receive_any_messageL(CStifItemParser& aItem);
+ virtual TInt lm_login_multiple_sessionsL(CStifItemParser& aItem);
+ virtual TInt lm_change_own_presenceL(CStifItemParser& aItem);
+ virtual TInt lm_login_test_invalid_serverL(CStifItemParser& aItem);
+ virtual TInt lm_login_test_invalid_portL(CStifItemParser& aItem);
+
+ virtual TInt lm_memory_leak_testL(CStifItemParser& aItem);
+ virtual TInt lm_nft_updating_presenceL(CStifItemParser& aItem);
+ virtual TInt lm_nft_presence_notificationL(CStifItemParser& aItem);
+ virtual TInt lm_nft_send_text_messageL(CStifItemParser& aItem);
+ virtual TInt lm_nft_open_conversation_with_multipleL(CStifItemParser& aItem);
+ virtual TInt lm_nft_fetch300_contactL(CStifItemParser& aItem);
+ virtual TInt lm_nft_loginlogoutmultipletime(CStifItemParser& aItem);
+ virtual TInt lm_nft_receiving100_message_L(CStifItemParser& aItem);
+ public: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ protected: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ private: // Data
+
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ // Reserved pointer for future extension
+ //TAny* iReserved;
+
+ public: // Friend classes
+ //?friend_class_declaration;
+ protected: // Friend classes
+ //?friend_class_declaration;
+ private: // Friend classes
+ //?friend_class_declaration;
+
+ };
+
+#endif // TSTLM_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/init/TestFramework.ini Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Engine_Defaults]
+
+TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment',
+ 'TestCases' or 'FullReport'
+
+CreateTestReport= YES # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT # Possible values: TXT or HTML
+TestReportOutput= FILE # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\tstlm_gtalk.cfg
+[End_Module]
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\tstlm_gtalk1.cfg
+[End_Module]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Logger_Defaults]
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/src/tstlm.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: tstlm.cpp
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <StifTestInterface.h>
+#include <stdlib.h>
+#include "tstlm.h"
+#include <e32cons.h>
+//#include <mrtlib.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+// ?value_n: ?description_line1
+// ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+ ?arg_type arg, // ?description
+ ?arg_type arg) // ?description
+ {
+
+ ?code // ?comment
+
+ // ?comment
+ ?code
+ }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ctstlm::Ctstlm
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Ctstlm::Ctstlm(
+ CTestModuleIf& aTestModuleIf ):
+ CScriptBase( aTestModuleIf )
+ {
+ //MrtInit();
+ setenv("G_SLICE","always-malloc",1);
+ setenv("LM_DEBUG","ALL",1);
+ }
+
+// -----------------------------------------------------------------------------
+// Ctstlm::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ctstlm::ConstructL()
+ {
+ iLog = CStifLogger::NewL( KtstlmLogPath,
+ KtstlmLogFile,
+ CStifLogger::ETxt,
+ CStifLogger::EFile,
+ EFalse );
+
+ TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksMem );
+ TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksRequests );
+ TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles );
+ }
+
+// -----------------------------------------------------------------------------
+// Ctstlm::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ctstlm* Ctstlm::NewL(
+ CTestModuleIf& aTestModuleIf )
+ {
+ Ctstlm* self = new (ELeave) Ctstlm( aTestModuleIf );
+
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+
+ return self;
+
+ }
+
+// Destructor
+Ctstlm::~Ctstlm()
+ {
+
+ // Delete resources allocated from test methods
+ Delete();
+
+ // Delete logger
+ delete iLog;
+
+ }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL(
+ CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+ {
+
+ return ( CScriptBase* ) Ctstlm::NewL( aTestModuleIf );
+
+ }
+
+// -----------------------------------------------------------------------------
+// E32Dll is a DLL entry point function.
+// Returns: KErrNone
+// -----------------------------------------------------------------------------
+//
+#ifndef EKA2 // Hide Dll entry point to EKA2
+GLDEF_C TInt E32Dll(
+ TDllReason /*aReason*/) // Reason code
+ {
+ return(KErrNone);
+
+ }
+#endif // EKA2
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/tsrc/src/tstlmBlocks.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,14822 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: tstlmblocks.cpp
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <StifParser.h>
+#include <StifTestInterface.h>
+#include "tstlm.h"
+
+#include "loudmouth/loudmouth.h"
+#include <glib.h>
+#include <glib/gprintf.h> // for g_stpcpy
+#include <string.h>
+#include <stdlib.h>
+
+#include <glowmem.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+#define UNEXIST_PORT 0
+#define MYPORT 4321
+#define HAVE_OPENSSL
+#define FAKEPORT NULL
+//You need to use 5223 for ssl+sasl and 5222 for non-ssl+sasl connection
+
+#define GTALK_SSL_PORT 443
+#define SSL_INVALID_PORT 999
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+
+typedef enum
+{
+ RC_OK,
+ RC_ERROR
+} RC_Code_t;
+
+typedef struct
+{
+ gchar *recipient;
+ gchar *message;
+} MessageData;
+
+typedef struct
+{
+ gchar *proxy_server;
+ guint proxy_port;
+}ProxyData;
+
+typedef struct
+{
+ gchar *server;
+ gchar *username;
+ gchar *password;
+ gchar *resource;
+ MessageData *msg_data;
+#ifdef __WINSCW__
+ ProxyData *proxy_data;
+#endif
+} ConnectData;
+
+typedef struct
+{
+ ConnectData *connect_data;
+ GMainLoop *main_loop;
+ RC_Code_t rCode;
+} AuthData;
+
+typedef struct
+{
+ GMainLoop *main_loop;
+ RC_Code_t Test_Success;
+ int count;
+} HandleData;
+
+typedef struct
+{
+ ConnectData *connect_data;
+ LmMessage* message;
+ LmMessageHandler* handler;
+ GMainLoop *main_loop;
+ RC_Code_t rCode;
+} SendStreamData;
+// ======== MODULE DATA STRUCTURES =========
+typedef enum
+ {
+ XMPP_PRESENCE_TYPE_ONLINE,
+ XMPP_PRESENCE_TYPE_CHAT,
+ XMPP_PRESENCE_TYPE_AWAY,
+ XMPP_PRESENCE_TYPE_XA,
+ XMPP_PRESENCE_TYPE_DND,
+ XMPP_PRESENCE_TYPE_INVISIBLE,
+ XMPP_PRESENCE_TYPE_UNAVAILABLE
+ } JabberPresenceType;
+
+// LOCAL FUNCTION PROTOTYPES
+
+// Function to read data from the cfg file
+static RC_Code_t read_data ( ConnectData*& connect_data,
+ CStifItemParser& aItem );
+// Function to free the allocated resources
+static void free_data ( ConnectData*& connect_data );
+
+// Callback function used in lm_connection_open
+static void connection_open_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer data );
+
+static void wrong_input_in_open_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer data );
+
+//Callback function set in lm_connection_authenticate() call
+//from lm-connection_send
+static void connection_auth_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer data );
+
+//Callback from lm_login_test method after auth
+static void lm_login_cb ( LmConnection * connection,
+ gboolean success,
+ gpointer data );
+// Callback function called by lm_connection_open in Lm_AuthenticateL
+// Will call authenticate method from inside this callback.
+// It uses the correct input data
+static void auth_in_connection_cb( LmConnection *connection,
+ gboolean success,
+ gpointer *data );
+
+// Callback function set in auth_from_open_cb for handling
+//wrong input data during authenticate. Written to handle negative test cases.
+static void wrong_input_auth_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer data );
+// Callback function set by lm_connection_open call.
+//written to handle the negative test cases for authenticate
+static void auth_from_open_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer *data );
+// Callback function to handle messages
+static LmHandlerResult handle_messages ( LmMessageHandler *handler,
+ LmConnection *conneciton,
+ LmMessage *message,
+ gpointer user_data );
+static LmHandlerResult handle_100_messages ( LmMessageHandler *handler,
+ LmConnection *conneciton,
+ LmMessage *message,
+ gpointer user_data );
+// Callback function called when connection is closed
+static void connection_close_cb ( LmConnection *connection,
+ LmDisconnectReason reason,
+ gpointer user_data );
+
+// Callback function called when presence is changed
+static void jabber_presence_handler_cb ( LmConnection *connection,
+ LmDisconnectReason reason,
+ gpointer user_data );
+static void message_response_cb ( LmConnection *connection,
+ LmDisconnectReason reason,
+ gpointer user_data );
+
+// Get the MessageType in Type
+static void GetMessageType ( LmMessageType MessageType, gchar *Type );
+// Get MessageSubType in SubType
+static void GetMessageSubType ( LmMessageSubType MessageSubType,
+ gchar *SubType );
+
+// Callback function called if something goes wrong during the connection phase
+static LmSSLResponse ssl_cb ( LmSSL *ssl,
+ LmSSLStatus status,
+ gpointer user_data );
+
+#ifdef __WINSCW__
+// Set connection to connect through a proxy
+static void SetProxy ( LmConnection *connection, ProxyData *connect_data );
+#endif
+
+// Set SSL for connection
+static void SSLInit ( LmConnection *connection );
+
+// Returns the username from the JID ( username@domainname/resource )
+static gchar *get_user_name ( const gchar *jid );
+
+
+static JabberPresenceType
+jabber_presence_type_from_string ( const gchar *string );
+
+
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ==============================
+
+//-----------------------------------------------------------------------------
+// function_name : read_data
+// description : Reads data from the CFG file
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static RC_Code_t
+read_data ( ConnectData*& connect_data, CStifItemParser& aItem )
+ {
+ TPtrC string;
+ TBuf8<KMaxFileName> temp;
+ MessageData *msg_data = NULL;
+
+#ifdef __WINSCW__
+ ProxyData *proxy_data = NULL;
+ TInt proxy_port;
+#endif
+
+
+ connect_data = g_new0 ( ConnectData, 1 );
+ if ( !connect_data )
+ {
+ return RC_ERROR;
+ }
+
+ msg_data = g_new0 ( MessageData, 1 );
+ if ( !msg_data )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+
+ connect_data->msg_data = msg_data;
+
+#ifdef __WINSCW__
+ proxy_data = g_new0 ( ProxyData, 1 );
+ if ( !proxy_data )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ connect_data->proxy_data = proxy_data;
+#endif
+
+ // Read server name
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->server = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->server )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->server, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Username
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->username = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->username )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->username, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Password corresponding to Username
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->password = g_new0 ( gchar, temp.Length () );
+ if ( !connect_data->password )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->password, ( gchar *) temp.Ptr() );
+ }
+
+ // Read recipient
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ msg_data->recipient = g_new0 ( gchar, temp.Length() );
+ if ( !msg_data->recipient )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( msg_data->recipient, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read Message
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ msg_data->message = g_new0 ( gchar, temp.Length() );
+ if ( !msg_data->message )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( msg_data->message, ( gchar * ) temp.Ptr() );
+ }
+
+ // Read resource identifier
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ connect_data->resource = g_new0 ( gchar, temp.Length() );
+ if ( !connect_data->resource )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( connect_data->resource, ( gchar * ) temp.Ptr() );
+ }
+
+#ifdef __WINSCW__
+ // Read proxy server and proxy port
+ if ( aItem.GetNextString ( string ) == KErrNone )
+ {
+ temp.Copy ( string );
+ temp.Append ( '\0' );
+ proxy_data->proxy_server = g_new0 ( gchar, temp.Length() );
+ if ( !proxy_data->proxy_server )
+ {
+ free_data ( connect_data );
+ return RC_ERROR;
+ }
+ g_stpcpy ( proxy_data->proxy_server, ( gchar * ) temp.Ptr() );
+ }
+
+ if ( aItem.GetNextInt ( proxy_port ) == KErrNone )
+ {
+ proxy_data->proxy_port = proxy_port;
+ }
+#endif
+
+ return RC_OK;
+ }
+
+
+//-----------------------------------------------------------------------------
+// function_name : free_data
+// description : Deallocates all the data
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+free_data ( ConnectData*& connect_data )
+ {
+ if ( connect_data )
+ {
+ if ( connect_data->server )
+ {
+ g_free ( connect_data->server );
+ connect_data->server = NULL;
+ }
+
+ if ( connect_data->username )
+ {
+ g_free ( connect_data->username );
+ connect_data->username = NULL;
+ }
+
+ if ( connect_data->password )
+ {
+ g_free ( connect_data->password );
+ connect_data->password = NULL;
+ }
+
+ if ( connect_data->msg_data )
+ {
+ if ( connect_data->msg_data->recipient )
+ {
+ g_free ( connect_data->msg_data->recipient );
+ connect_data->msg_data->recipient = NULL;
+ }
+ if ( connect_data->msg_data->message )
+ {
+ g_free ( connect_data->msg_data->message );
+ connect_data->msg_data->message = NULL;
+ }
+ g_free ( connect_data->msg_data );
+ connect_data->msg_data = NULL;
+ }
+
+ if ( connect_data->resource )
+ {
+ g_free ( connect_data->resource );
+ connect_data->resource = NULL;
+ }
+
+ #ifdef __WINSCW__
+ if ( connect_data->proxy_data )
+ {
+ if ( connect_data->proxy_data->proxy_server )
+ {
+ g_free ( connect_data->proxy_data->proxy_server );
+ connect_data->proxy_data->proxy_server = NULL;
+ }
+ g_free ( connect_data->proxy_data );
+ connect_data->proxy_data = NULL;
+ }
+ #endif
+ g_free ( connect_data );
+ connect_data = NULL;
+ }
+ }
+
+
+//-----------------------------------------------------------------------------
+// funnction_name : connection_open_cb
+// description : callback function called by lm_connection_open
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+connection_open_cb ( LmConnection *connection,
+ gboolean success /*success*/,
+ gpointer data )
+ {
+
+ gboolean result = success ;
+ GMainLoop *main_loop = ( GMainLoop * ) data;
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+ /* send whitespace to the server every 30 seconds */
+ lm_connection_set_keep_alive_rate (connection, 30);
+ }
+
+
+//-----------------------------------------------------------------------------
+// funnction_name : wrong_input_in_open_cb
+// description : callback function called by lm_connection_open when the wrong
+//input like wrong server , user id etc is given
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+wrong_input_in_open_cb ( LmConnection */*connection*/,
+ gboolean success /*success*/,
+ gpointer data )
+ {
+
+ gboolean result = success;
+ AuthData *auth_data = ( AuthData * ) data;
+
+ //Result is false when the wrong input parameters were successfully handled.
+ if (result == FALSE)
+ {
+ auth_data->rCode = RC_OK;
+ }
+ else
+ {
+ //Result is true, when the wrong input was not handled successfully.
+ auth_data->rCode = RC_ERROR;
+ }
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+//-----------------------------------------------------------------------------
+// funnction_name : wrong_input_auth_cb
+// description : callback function called by lm_connection_open
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+wrong_input_auth_cb ( LmConnection */*connection*/,
+ gboolean success,
+ gpointer data )
+ {
+ gboolean result = success;
+ AuthData *auth_data = ( AuthData * ) data;
+ //Result is false when the wrong input parameters were successfully handled.
+ if (result == FALSE)
+ {
+ auth_data->rCode = RC_OK;
+ }
+ else
+ {
+ //Result is true, when the wrong input was not handled successfully.
+ auth_data->rCode = RC_ERROR;
+ }
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+
+//-----------------------------------------------------------------------------
+// funnction_name : connection_auth_cb
+// description : callback function set by lm_connection_authenticate
+// in lm_connection_sendL()
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void connection_auth_cb ( LmConnection */*connection*/,
+ gboolean /*success*/,
+ gpointer data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * ) data;
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : auth_in_connection_cb
+// description : callback function called for lm_connection_open
+// Returns : RC_OK if successfull, RC_ERROR otherwise
+//-----------------------------------------------------------------------------
+static void
+auth_in_connection_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer *data )
+ {
+ AuthData *auth_data = ( AuthData * ) data;
+
+ if ( !success )
+ {
+ // Connection failed
+ auth_data->rCode = RC_ERROR;
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+
+ // Extract the username from the JID
+ gchar *username = get_user_name ( auth_data->connect_data->username );
+
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ auth_data->connect_data->password,
+ auth_data->connect_data->resource,
+ NULL,
+ auth_data->connect_data->msg_data,
+ NULL,
+ NULL ) )
+ {
+ auth_data->rCode = RC_ERROR;
+ g_free ( username );
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+ g_free ( username );
+
+ auth_data->rCode = RC_OK;
+ g_main_loop_quit ( auth_data->main_loop );
+
+ }
+
+//-----------------------------------------------------------------------------
+// function_name : auth_from_open_cb
+// description : callback function called for lm_connection_authenticate
+// Returns : RC_OK if successfull, RC_ERROR otherwise
+//-----------------------------------------------------------------------------
+static void
+auth_from_open_cb ( LmConnection *connection,
+ gboolean success,
+ gpointer *data )
+ {
+ AuthData *auth_data = ( AuthData * ) data;
+
+ if ( !success )
+ {
+ // Connection failed
+ auth_data->rCode = RC_ERROR;
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+
+ // Extract the username from the JID
+ gchar *username = get_user_name ( auth_data->connect_data->username );
+
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ auth_data->connect_data->password,
+ auth_data->connect_data->resource,
+ ( LmResultFunction ) wrong_input_auth_cb,
+ auth_data ,
+ NULL,
+ NULL ) )
+ {
+ auth_data->rCode = RC_ERROR;
+ g_free ( username );
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+ g_free ( username );
+
+ }
+
+
+//--------------------------------------------------------------------------------
+// function_name : handle_messages
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_messages ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* /*message*/,
+ gpointer user_data )
+ {
+ HandleData *handle_data = ( HandleData * )user_data;
+
+ if ( handle_data )
+ {
+ handle_data->Test_Success = RC_OK;
+
+ g_main_loop_quit ( handle_data->main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//--------------------------------------------------------------------------------
+// function_name : handle_messages
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_100_messages ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* /*message*/,
+ gpointer user_data )
+ {
+ HandleData *handle_data = ( HandleData * )user_data;
+ //static int count=0;
+ handle_data->count++;
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ //count++;
+ if(handle_data->count==5)
+ {
+ g_main_loop_quit ( handle_data->main_loop );
+ // g_main_loop_quit ( main_loop );
+ }
+ //}
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//--------------------------------------------------------------------------------
+// function_name : handle_messages
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_100_presence_notification ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* /*message*/,
+ gpointer user_data )
+ {
+ HandleData *handle_data = ( HandleData * )user_data;
+ handle_data->count++;
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ if(handle_data->count==100)
+ {
+ g_main_loop_quit ( handle_data->main_loop );
+
+ }
+
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//--------------------------------------------------------------------------------
+// function_name : connection_close_cb
+// description : callback function called when connection is closed
+// Returns : RC_OK if called
+//--------------------------------------------------------------------------------
+static void
+connection_close_cb ( LmConnection */*connection*/,
+ LmDisconnectReason reason,
+ gpointer user_data )
+ {
+ HandleData *handle_data = ( HandleData * ) user_data;
+
+ switch ( reason )
+ {
+ case LM_DISCONNECT_REASON_OK:
+ handle_data->Test_Success = RC_OK;
+ break;
+ case LM_DISCONNECT_REASON_PING_TIME_OUT:
+ /* No break, fall through */
+ case LM_DISCONNECT_REASON_HUP:
+ case LM_DISCONNECT_REASON_ERROR:
+ case LM_DISCONNECT_REASON_UNKNOWN:
+ handle_data->Test_Success = RC_ERROR;
+ break;
+ default:
+ handle_data->Test_Success = RC_ERROR;
+ break;
+ }
+
+ }
+
+
+//------------------------------------------------------------------------------
+// function_name : GetMessageType
+// description : Gets LmMessageType in Type
+// Returns : None
+//------------------------------------------------------------------------------
+static void
+GetMessageType ( LmMessageType MessageType, gchar *Type )
+{
+ switch ( MessageType )
+ {
+ case LM_MESSAGE_TYPE_MESSAGE:
+ g_stpcpy ( Type, "LM_MESSAGE_TYPE_MESSAGE" );
+ break;
+ case LM_MESSAGE_TYPE_PRESENCE:
+ g_stpcpy ( Type, "LM_MESSAGE_TYPE_MESSAGE" );
+ break;
+ case LM_MESSAGE_TYPE_IQ:
+ g_stpcpy ( Type, "LM_MESSAGE_TYPE_IQ" );
+ break;
+ case LM_MESSAGE_TYPE_STREAM:
+ g_stpcpy ( Type, "LM_MESSAGE_TYPE_STREAM" );
+ break;
+ case LM_MESSAGE_TYPE_STREAM_ERROR:
+ g_stpcpy ( Type, "LM_MESSAGE_TYPE_STREAM_ERROR" );
+ break;
+ case LM_MESSAGE_TYPE_UNKNOWN:
+ g_stpcpy ( Type, "LM_MESSAGE_TYPE_UNKNOWN" );
+ break;
+ }
+}
+
+
+//------------------------------------------------------------------------------
+// function_name : GetMessageSubType
+// description : Gets LmMessageSubType in SubType
+// Returns : None
+//------------------------------------------------------------------------------
+static void
+GetMessageSubType ( LmMessageSubType MessageSubType, gchar *SubType )
+{
+ switch ( MessageSubType )
+ {
+ case LM_MESSAGE_SUB_TYPE_NOT_SET:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_NOT_SET" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_AVAILABLE:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_AVAILABLE" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_NORMAL:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_NORMAL" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_CHAT:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_CHAT" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_GROUPCHAT:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_GROUPCHAT" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_HEADLINE:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_HEADLINE" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_UNAVAILABLE:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_UNAVAILABLE" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_PROBE:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_PROBE" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_SUBSCRIBE:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_SUBSCRIBE" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_SUBSCRIBED:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_SUBSCRIBED" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_GET:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_GET" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_SET:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_SET" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_RESULT" );
+ break;
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ g_stpcpy ( SubType, "LM_MESSAGE_SUB_TYPE_ERROR" );
+ break;
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+// jabber_presence_type_from_string: Returns the presence type
+// ---------------------------------------------------------------------------
+//
+static JabberPresenceType
+jabber_presence_type_from_string ( const gchar *string )
+ {
+
+ if ( string == NULL )
+ return XMPP_PRESENCE_TYPE_ONLINE;
+
+ if ( !strcmp ( string, "online" ) )
+ return XMPP_PRESENCE_TYPE_ONLINE;
+ else if ( !strcmp ( string, "chat" ) )
+ return XMPP_PRESENCE_TYPE_CHAT;
+ else if ( !strcmp ( string, "away" ) )
+ return XMPP_PRESENCE_TYPE_AWAY;
+ else if ( !strcmp ( string, "xa" ) )
+ return XMPP_PRESENCE_TYPE_XA;
+ else if ( !strcmp ( string, "dnd" ) )
+ return XMPP_PRESENCE_TYPE_DND;
+ else if ( !strcmp ( string, "invisible" ) )
+ return XMPP_PRESENCE_TYPE_INVISIBLE;
+ else if ( !strcmp ( string, "unavailable" ) )
+ return XMPP_PRESENCE_TYPE_UNAVAILABLE;
+ else
+ return XMPP_PRESENCE_TYPE_ONLINE;
+ }
+
+
+// ---------------------------------------------------------------------------
+// function_name : ssl_cb
+// description : This function is called if something goes wrong
+// during the connecting phase.
+// Arguements :
+// ssl : An LmSSL
+// status : The status informing what went wrong
+// user_data : User data provided in the callback
+//
+// Returns : User should return LM_SSL_RESPONSE_CONTINUE if
+// connection should proceed. otherwise
+// LM_SSL_RESPONSE_STOP.
+// ---------------------------------------------------------------------------
+//
+static LmSSLResponse
+ssl_cb ( LmSSL */*ssl*/, LmSSLStatus status, gpointer /*user_data*/ )
+ {
+
+ g_print ( "SSL status :%d\n", status );
+
+ switch ( status )
+ {
+ case LM_SSL_STATUS_NO_CERT_FOUND:
+ g_printerr ("No certificate found!\n");
+ break;
+ case LM_SSL_STATUS_UNTRUSTED_CERT:
+ g_printerr ("Certificate is not trusted!\n");
+ break;
+ case LM_SSL_STATUS_CERT_EXPIRED:
+ g_printerr ("Certificate has expired!\n");
+ break;
+ case LM_SSL_STATUS_CERT_NOT_ACTIVATED:
+ g_printerr ("Certificate has not been activated!\n");
+ break;
+ case LM_SSL_STATUS_CERT_HOSTNAME_MISMATCH:
+ g_printerr ("Certificate hostname does not match expected hostname!\n");
+ break;
+ case LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH:
+ g_printerr ( "fingerprint error!\n" );
+ break;
+ case LM_SSL_STATUS_GENERIC_ERROR:
+ g_printerr ("Generic SSL error!\n");
+ break;
+ }
+
+ return LM_SSL_RESPONSE_CONTINUE;
+ }
+
+
+// ---------------------------------------------------------------------------
+// function_name : SetProxy
+// description : Sets the connection to use proxy
+// Arguements :
+// connection : LmConnection
+// connect_data : ConnectData
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+#ifdef __WINSCW__
+static void
+SetProxy ( LmConnection *connection, ProxyData *proxy_data )
+ {
+ LmProxy *proxy = NULL;
+
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ lm_proxy_set_server ( proxy, proxy_data->proxy_server );
+ lm_proxy_set_port ( proxy, proxy_data->proxy_port );
+ lm_connection_set_proxy ( connection, proxy );
+ lm_proxy_unref ( proxy );
+ }
+#endif
+
+// ---------------------------------------------------------------------------
+// function_name : SSLInit
+// description : Sets the connection to use SSL
+// Arguements :
+// connection : LmConnection
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+static void
+SSLInit ( LmConnection *connection )
+ {
+ LmSSL *ssl = NULL;
+
+ ssl = lm_ssl_new ( NULL, ( LmSSLFunction ) ssl_cb, NULL, NULL );
+ lm_connection_set_ssl ( connection, ssl );
+ lm_ssl_unref ( ssl );
+ lm_connection_set_keep_alive_rate (connection, 30);
+ }
+
+
+// ---------------------------------------------------------------------------
+// function_name : get_user_name
+// description : Returns the username from the jid
+// Arguements :
+// jid : jid
+// Returns : username
+// ---------------------------------------------------------------------------
+//
+static gchar *
+get_user_name ( const gchar *jid )
+ {
+ const gchar *ch;
+
+ g_return_val_if_fail ( jid != NULL, NULL );
+
+ ch = strchr ( jid, '@' );
+ if ( !ch )
+ return ( gchar *) jid;
+
+ return g_strndup ( jid, ch - jid );
+ }
+
+// ---------------------------------------------------------------------------
+// jabber_presence_handler_cb: Callback function to handle the presence info
+// ---------------------------------------------------------------------------
+//
+static LmHandlerResult
+jabber_presence_handler_cb ( LmMessageHandler * /*handler*/,
+ LmConnection * /*connection*/,
+ LmMessage *message,
+ gpointer user_data )
+ {
+ const gchar *jid;
+ const gchar *show;
+ const gchar *status;
+
+ LmMessageNode *node;
+ JabberPresenceType type;
+
+ if(message != NULL)
+ {
+ // Get the JID attribute
+ jid = lm_message_node_get_attribute ( message->node, "from" );
+
+ // Get the show attribute
+
+ node = lm_message_node_get_child ( message->node, "show" );
+ show = node ? ( node->value ) : "online";
+
+ // Get the status attribute
+ node = lm_message_node_get_child ( message->node, "status" );
+ status = node ? ( node->value ) : NULL;
+
+ type = jabber_presence_type_from_string ( show );
+ }
+
+
+ GMainLoop *main_loop = ( GMainLoop * ) user_data;
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ctstlm::Delete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+//
+void Ctstlm::Delete()
+ {
+
+ }
+
+// -----------------------------------------------------------------------------
+// Ctstlm::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt Ctstlm::RunMethodL(
+ CStifItemParser& aItem )
+ {
+ iLog->Log ( _L ( "In RunMethodL method" ) );
+
+
+ //TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksRequests );
+ //TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles );
+
+ static TStifFunctionInfo const KFunctions[] =
+ {
+ // Copy this line for every implemented function.
+ // First string is the function name used in TestScripter script file.
+ // Second is the actual implementation member function.
+
+ // LmConnection
+ ENTRY( "lm_connection_new", Ctstlm::lm_connection_newL ),
+ ENTRY( "lm_new_with_context", Ctstlm::lm_new_with_contextL ),
+ ENTRY( "lm_connection_open", Ctstlm::lm_connection_openL ),
+ ENTRY( "lm_connection_is_open_WhenConnectionIsClosed", Ctstlm::lm_connection_is_open_WhenConnectionIsClosedL),
+ ENTRY( "lm_connection_is_authenticated_WhenNot_Authenticated", Ctstlm::lm_is_authenticated_WhenNotAuthenticatedL),
+ ENTRY( "lm_connection_set_server_withNULL", Ctstlm::lm_connection_set_server_WithNULL),
+ ENTRY( "lm_connection_set_jid_WithNull", Ctstlm::lm_connection_set_jid_WithNULL),
+ ENTRY( "lm_connection_set_port_WithNULL", Ctstlm::lm_connection_set_port_WithNULL),
+ ENTRY( "lm_connection_set_ssl_WithNULL", Ctstlm::lm_connection_set_ssl_WithNULL),
+ ENTRY( "lm_connection_close", Ctstlm::lm_connection_closeL ),
+ ENTRY( "lm_connection_closeWhenNotOpen", Ctstlm::lm_connection_closeWhenNotOpenedL ),
+ ENTRY( "lm_authenticate", Ctstlm::lm_authenticateL ),
+ ENTRY( "lm_connection_is_open", Ctstlm::lm_connection_is_openL ),
+ ENTRY( "lm_is_authenticated", Ctstlm::lm_is_authenticatedL ),
+ ENTRY( "lm_connection_set_get_server", Ctstlm::lm_connection_set_get_serverL ),
+ ENTRY( "lm_connection_set_get_jid", Ctstlm::lm_connection_set_get_jidL ),
+ ENTRY( "lm_connection_set_get_port", Ctstlm::lm_connection_set_get_portL ),
+ ENTRY( "lm_connection_set_get_ssl", Ctstlm::lm_connection_set_get_sslL ),
+ ENTRY( "lm_connection_set_get_proxy", Ctstlm::lm_connection_set_get_proxyL ),
+
+ ENTRY( "lm_connection_send", Ctstlm::lm_connection_sendL ),
+ ENTRY( "lm_connection_send400char", Ctstlm::lm_connection_send400charL ),
+ ENTRY( "lm_connection_send_repeated", Ctstlm::lm_connection_send_repeatedL ),
+
+ ENTRY( "lm_send_with_reply", Ctstlm::lm_send_with_replyL ),
+ ENTRY( "register_message_handler", Ctstlm::register_message_handlerL ),
+ ENTRY( "set_disconnect_function", Ctstlm::set_disconnect_functionL ),
+ ENTRY( "lm_connection_send_raw", Ctstlm::lm_connection_send_rawL ),
+ ENTRY( "lm_connection_get_state", Ctstlm::lm_connection_get_stateL ),
+ ENTRY( "lm_connection_ref", Ctstlm::lm_connection_refL ),
+ ENTRY( "lm_connection_unref", Ctstlm::lm_connection_unrefL ),
+
+ // LmMessage
+ ENTRY( "lm_message_new", Ctstlm::lm_message_newL ),
+ ENTRY( "lm_message_new_with_sub_type", Ctstlm::lm_message_new_with_sub_typeL ),
+ ENTRY( "lm_message_get_type", Ctstlm::lm_message_get_typeL ),
+ ENTRY( "lm_message_get_sub_type", Ctstlm::lm_message_get_sub_typeL ),
+ ENTRY( "lm_message_get_node", Ctstlm::lm_message_get_nodeL ),
+ ENTRY( "lm_message_ref", Ctstlm::lm_message_refL ),
+ ENTRY( "lm_message_unref", Ctstlm::lm_message_unrefL ),
+
+ // LmMessageHandler
+ ENTRY( "lm_message_handler_new", Ctstlm::lm_message_handler_newL ),
+ ENTRY( "lm_message_handler_invalidate", Ctstlm::lm_message_handler_invalidateL ),
+ ENTRY( "lm_message_handler_is_valid", Ctstlm::lm_message_handler_is_validL ),
+ ENTRY( "lm_message_handler_ref", Ctstlm::lm_message_handler_refL ),
+ ENTRY( "lm_message_handler_unref", Ctstlm::lm_message_handler_unrefL ),
+
+ // LmMessageNode
+ ENTRY( "lm_message_node_set_get_value", Ctstlm::lm_message_node_set_get_valueL ),
+ ENTRY( "lm_message_node_add_child", Ctstlm::lm_message_node_add_childL ),
+ ENTRY( "lm_message_node_get_child", Ctstlm::lm_message_node_get_childL ),
+ ENTRY( "lm_message_node_find_child", Ctstlm::lm_message_node_find_childL ),
+
+ ENTRY( "lm_message_node_set_get_attributes", Ctstlm::lm_message_node_set_get_attributesL ),
+
+ ENTRY( "lm_message_node_set_get_raw_mode", Ctstlm::lm_message_node_set_get_raw_modeL ),
+
+ ENTRY( "lm_message_node_ref", Ctstlm::lm_message_node_refL ),
+ ENTRY( "lm_message_node_unref", Ctstlm::lm_message_node_unrefL ),
+
+ ENTRY( "lm_message_node_to_string", Ctstlm::lm_message_node_to_stringL ),
+
+ // LmSSL
+ ENTRY( "lm_ssl_new", Ctstlm::lm_ssl_newL ),
+ ENTRY( "lm_ssl_is_supported", Ctstlm::lm_ssl_is_supportedL ),
+ ENTRY( "lm_ssl_get_fingerprint", Ctstlm::lm_ssl_get_fingerprintL ),
+ ENTRY( "lm_ssl_ref", Ctstlm::lm_ssl_refL ),
+ ENTRY( "lm_ssl_unref", Ctstlm::lm_ssl_unrefL ),
+
+ // LmProxy
+ ENTRY( "lm_proxy_new", Ctstlm::lm_proxy_newL ),
+ ENTRY( "lm_proxy_new_with_server", Ctstlm::lm_proxy_new_with_serverL ),
+ ENTRY( "lm_proxy_set_get_type", Ctstlm::lm_proxy_set_get_typeL ),
+ ENTRY( "lm_proxy_set_get_server", Ctstlm::lm_proxy_set_get_serverL ),
+ ENTRY( "lm_proxy_set_get_port", Ctstlm::lm_proxy_set_get_portL ),
+ ENTRY( "lm_proxy_set_get_username", Ctstlm::lm_proxy_set_get_usernameL ),
+ ENTRY( "lm_proxy_set_get_password", Ctstlm::lm_proxy_set_get_passwordL ),
+ ENTRY( "lm_proxy_ref", Ctstlm::lm_proxy_refL ),
+ ENTRY( "lm_proxy_unref", Ctstlm::lm_proxy_unrefL ),
+
+ // lm-send-sync example
+ ENTRY( "lm_send_sync", Ctstlm::lm_send_syncL ),
+
+ // lm contact list fetching code
+
+ ENTRY( "lm_fetching_contactlist", Ctstlm::lm_fetching_contactlist_L ),
+ ENTRY( "lm_fetching_presence", Ctstlm::lm_fetching_presenceL ),
+ ENTRY( "lm_subscribe_contact", Ctstlm::lm_subscribe_contact_L ),
+ ENTRY( "lm_authenticate_unexistjid", Ctstlm::lm_authenticate_WithUnexistingJID ),
+ ENTRY( "lm_authenticate_badpassword", Ctstlm::lm_authenticate_WithBadPasswordL ),
+ ENTRY( "lm_authenticate_connectionisnotcreated", Ctstlm::lm_authenticate_WhenConnectionIsNotOpenedL ),
+ ENTRY( "lm_connection_open_with_bad_server", Ctstlm::lm_connection_open_with_badserverL ),
+ ENTRY( "lm_connection_send_receive", Ctstlm::lm_connection_send_receiveL ),
+ ENTRY( "lm_login_test", Ctstlm::lm_login_testL ),
+ ENTRY( "lm_add_contact", Ctstlm::lm_add_contactL ),
+ ENTRY( "lm_remove_contact", Ctstlm::lm_remove_contactL ),
+ ENTRY( "lm_connection_cancel_open", Ctstlm::lm_connection_cancel_openL ),
+ ENTRY( "lm_connection_get_privacy_lists", Ctstlm::lm_connection_get_privacy_listsL ),
+ ENTRY( "lm_connection_set_privacy_lists", Ctstlm::lm_connection_set_privacy_listsL ),
+ ENTRY( "lm_connection_send_image_bytestream_msg", Ctstlm::lm_connection_send_image_bytestream_msgL ),
+ ENTRY( "lm_connection_send_image_bytestream_iq", Ctstlm::lm_connection_send_image_bytestream_iqL ),
+ ENTRY( "lm_connection_send_multiple_conn", Ctstlm::lm_connection_send_multiple_connL ),
+ ENTRY( "lm_connection_block_contact", Ctstlm::lm_connection_block_contactL ),
+ ENTRY( "lm_connection_unblock_contact", Ctstlm::lm_connection_unblock_contactL ),
+ ENTRY( "lm_connection_set_active_list", Ctstlm::lm_connection_set_active_listL ),
+ ENTRY( "lm_connection_set_unexist_active_list", Ctstlm::lm_connection_set_unexist_active_listL ),
+ ENTRY( "lm_connection_set_decline_active_list", Ctstlm::lm_connection_set_decline_active_listL ),
+ ENTRY( "lm_connection_get_one_privacy_list", Ctstlm::lm_connection_get_one_privacy_listL ),
+ ENTRY( "lm_connection_set_one_privacy_list", Ctstlm::lm_connection_set_one_privacy_listL ),
+ ENTRY( "lm_connection_get_many_privacy_list_from_listname", Ctstlm::lm_connection_get_many_privacy_list_from_listnameL ),
+ ENTRY( "lm_connection_set_one_unexist_privacy_list", Ctstlm::lm_connection_set_one_unexist_privacy_listL ),
+ ENTRY( "lm_connection_get_one_unexist_privacy_list", Ctstlm::lm_connection_get_one_unexist_privacy_listL ),
+ ENTRY( "lm_connection_create_one_privacy_list", Ctstlm::lm_connection_create_one_privacy_listL ),
+ ENTRY( "lm_service_discovery", Ctstlm::lm_service_discoveryL ),
+ ENTRY( "lm_service_discovery_connected_resource", Ctstlm::lm_service_discovery_connected_resourceL ),
+ ENTRY( "lm_simple_communications_blocking", Ctstlm::lm_simple_communications_blockingL ),
+ ENTRY( "lm_send_im_with_reply", Ctstlm::lm_send_im_with_replyL ),
+ ENTRY( "lm_receive_any_message", Ctstlm::lm_receive_any_messageL ),
+ ENTRY( "lm_login_multiple_sessions", Ctstlm::lm_login_multiple_sessionsL ),
+ ENTRY( "lm_change_own_presence", Ctstlm::lm_change_own_presenceL ),
+ ENTRY( "lm_login_test_invalid_server", Ctstlm::lm_login_test_invalid_serverL ),
+ ENTRY( "lm_login_test_invalid_port", Ctstlm::lm_login_test_invalid_portL ),
+ ENTRY( "lm_memory_leak_test", Ctstlm::lm_memory_leak_testL ),
+ ENTRY( "lm_nft_updating_presence", Ctstlm::lm_nft_updating_presenceL ),
+ ENTRY( "lm_nft_presence_notification", Ctstlm::lm_nft_presence_notificationL ),
+ ENTRY( "lm_nft_send_text_message", Ctstlm::lm_nft_send_text_messageL ),
+ ENTRY( "lm_nft_open_conversation_with_multiple",Ctstlm::lm_nft_open_conversation_with_multipleL ),
+ ENTRY( "lm_nft_fetch300_contact", Ctstlm::lm_nft_fetch300_contactL ),
+ ENTRY( "lm_nft_loginlogoutmultipletime", Ctstlm::lm_nft_loginlogoutmultipletime ),
+ ENTRY( "lm_nft_receiving100_message_L", Ctstlm::lm_nft_receiving100_message_L ),
+
+ };
+
+ const TInt count = sizeof( KFunctions ) /
+ sizeof( TStifFunctionInfo );
+
+ return RunInternalL( KFunctions, count, aItem );
+
+ }
+
+
+//----------------------------------------------------------------------------
+// Ctstlm::lm_connection_newL
+// Description : Creates a new closed connection. Server can be NULL but must
+// be set before calling lm_connection_open()
+// Arguements :
+// server : The hostname of the server for the connection
+// Retrurns : A newly created LmConnection, should be unreffed with
+// lm_connection_unref()
+//----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_newL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+ SET_LOW_MEMORY_TRAP ( NULL );
+
+ iLog->Log ( _L("In lm_connection_newL" ) );
+
+
+
+__UHEAP_MARK;
+__UHEAP_RESET;
+
+ // Read data from the cfg file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+__UHEAP_FAILNEXT(1);
+
+ //-----------------------
+ connection = lm_connection_new ( connect_data->server );
+ //-----------------------
+
+ // Free the allocated resources
+ free_data ( connect_data );
+
+ if ( connection == NULL )
+ {
+ iLog->Log ( _L( "lm_connection_new failed to allocate memory" ) );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+__UHEAP_MARKEND;
+
+ REMOVE_LOW_MEMORY_TRAP ();
+
+ iLog->Log ( _L( "lm_connection_new test case passed" ) );
+
+ return KErrNone;
+ }
+
+
+//----------------------------------------------------------------------------
+// Ctstlm::lm_connection_new_with_context
+// Description : Creates a new closed connection running in a certain context
+// Arguements :
+// server : The hostname of the server for the connection
+// context : The context this connection should be running on
+// Retrurns : A newly created Lmconnection, should be unreffed with
+// lm_connection_unref()
+//----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_new_with_contextL ( CStifItemParser& /* aItem */ )
+ {
+ GMainContext *context;
+ LmConnection *connection = NULL;
+
+ iLog->Log ( _L( "In lm_connection_new_with_contextL" ) );
+
+ context = g_main_context_new ();
+ connection = lm_connection_new_with_context ( NULL, context );
+ if ( connection == NULL )
+ {
+ iLog->Log ( _L ( "lm_connection_new_with_context failed" ) );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_new_with_context test case passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_open
+// Description : An async call to open connection. When the connection is open
+// function 'connection_open_cb' is called
+// Arguements :
+// connection : LmConnection to open
+// function : Callback function that will be called when the connection
+// is open
+// user_data : User data that will be passed to function
+// notify : Function for freeing that user_data, can be NULL
+// error : location to store error
+// Returns : TRUE if everything went fine, FALSE otherwise
+//
+// Requieres : This test case requires GUI for selecting Access point
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_openL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+ GMainLoop *main_loop = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_open" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ //context = g_main_context_new ();
+ //connection = lm_connection_new_with_context ( connect_data->server, context );
+
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Set proxy for emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set connection to use SSL
+ SSLInit ( connection );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_open succeded" ) );
+ return KErrNone;
+
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_close
+// Description : A synchronous call to close the connection
+// Arguements :
+// connection : LmConnection to close
+// error : location to store error, or NULL
+// Retrurns :TRUE if no errors were detected, otherwise FALSE
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_closeL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_close" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+ // Set proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ if ( lm_connection_close ( connection, NULL ) == FALSE )
+ {
+ iLog->Log ( _L ( "lm_connection_close failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "lm_connection_close passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_closeWhenNotOpenedL
+// Description : A synchronous call to close the connection
+// Arguements :
+// connection : LmConnection to close
+// error : location to store error, or NULL
+// Retrurns :TRUE if no errors were detected, otherwise FALSE
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_closeWhenNotOpenedL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_close" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ if ( lm_connection_close ( connection, NULL ) == TRUE )
+ {
+ iLog->Log ( _L ( "lm_connection_close failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "lm_connection_closeWhenNotOpenedL passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_authenticateL
+// Description : Tries to authenticate a user against the server
+// Arguements :
+// connnection : LmConnection to authenticate
+// username : Username used to authenticate
+// password : Password corresponding to username
+// resource : Resource used for this connection
+// function : Callback function called when authentication is finished
+// user_data : Userdata passed to callback function when called
+// notify : Function for freeing user_data, can be NULL
+// error : location to store error, or NULL
+// Returns : TRUE if no errors were detected, FALSE otherwise
+// Requieres : This test case requires GUI for selecting Access point
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_authenticateL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ AuthData *auth_data = NULL;
+
+ iLog->Log ( _L ( "In lm_authenticateL" ) );
+
+ auth_data = g_new0 ( AuthData, 1 );
+ if ( !auth_data )
+ {
+ iLog->Log ( _L ( "memory allocation failed for auth_data" ) );
+ return KErrGeneral;
+ }
+
+ if ( read_data ( auth_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( auth_data->connect_data );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ auth_data->rCode = RC_ERROR;
+ connection = lm_connection_new ( auth_data->connect_data->server );
+ if ( connection == NULL )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, auth_data->connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, auth_data->connect_data->proxy_data );
+#endif
+ SSLInit ( connection );
+
+ if ( !lm_connection_open ( connection,
+ ( LmResultFunction ) auth_in_connection_cb,
+ auth_data,
+ NULL,
+ NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( auth_data->main_loop );
+ g_main_loop_unref ( auth_data->main_loop );
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+
+ if ( auth_data->rCode != RC_OK )
+ {
+ iLog->Log ( _L ( "lm_authenticateL failed" ) );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_free ( auth_data );
+
+ iLog->Log ( _L ( "lm_authenticateL passed" ) );
+
+ return KErrNone;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_is_open
+// Description : Check if connection is currently open or not
+// Arguements :
+// connection : an LmConnection to check if it is open
+// Returns : TRUE if connection is open and FALSE if it is closed
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_is_openL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ gboolean NotOpen = FALSE;
+
+ iLog->Log ( _L ( "In lm_connection_is_open" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+ SSLInit ( connection );
+
+ // Check for connection in case of connection not yet opened
+ if ( !lm_connection_is_open ( connection ) )
+ {
+ iLog->Log ( _L ( "Connection is not open" ) );
+ NotOpen = TRUE;
+ }
+
+ // Check for open connection in case of connection opened
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ if ( !lm_connection_is_open ( connection ) && FALSE == NotOpen )
+ {
+ iLog->Log ( _L ( "lm_connection_is_open failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_is_open passed" ) );
+
+ return KErrNone;
+ }
+/////////////////////////////////////////////////////////
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_is_open_WhenConnectionIsClosedL
+// Description : Check if connection is currently open or not
+// Arguements :
+// connection : an LmConnection to check if it is open
+// Returns : TRUE if connection is open and FALSE if it is closed
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_is_open_WhenConnectionIsClosedL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ gboolean NotOpen = FALSE;
+
+ iLog->Log ( _L ( "lm_connection_is_open_WhenConnectionIsClosedL" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( " lm_connection_is_open" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ if ( lm_connection_is_open ( connection ) )
+ {
+ iLog->Log ( _L ( "lm_connection_is_open_WhenConnectionIsClosedL failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_is_open_WhenConnectionIsClosedL passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_is_authenticated
+// Description : Check if connection is authenticated or not
+// Arguements :
+// connection : an LmConnection to check
+// Returns : TRUE if connection is authenticated, FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_is_authenticatedL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ gboolean NotAuthenticated = FALSE;
+
+ iLog->Log ( _L ( "In lm_connection_is_authenticated" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the connection to use gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID to be used for connection
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // Open a connection
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ // Check for authentication before the connection is authenticated
+ if ( !lm_connection_is_authenticated ( connection ) )
+ {
+ iLog->Log ( _L ( "Connection not yet authenticated" ) );
+ NotAuthenticated = TRUE;
+ }
+
+ // Authenticate the connection
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Check for authentication after the connection is authenticated
+ if ( !lm_connection_is_authenticated ( connection ) &&
+ FALSE == NotAuthenticated )
+ {
+ iLog->Log ( _L ( "lm_connection_is_authenticated failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_is_authenticated passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_get_server
+// Description : Sets the server address for connection to server. Notice that
+// connection can't be open while doing this.
+// Arguements :
+// connection : an LmConnection
+// server : Address of the server ( name of the server )
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_get_serverL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ gchar *ServerName = "ganapati.nokia.com";
+ ConnectData *connect_data = NULL;
+ gchar *NewServerName;
+
+ iLog->Log ( _L ( "In lm_connection_set_server" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( " lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+
+ // Set the servers name before the connection
+ lm_connection_set_server ( connection, ServerName );
+
+ // Verify the server name
+ NewServerName = (gchar *)lm_connection_get_server ( connection );
+
+ if ( strcmp ( NewServerName, ServerName ) != 0 )
+ {
+ iLog->Log ( _L ( "lm_connection_set_server failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Server name modified successfully
+ iLog->Log ( _L ( "lm_connection_set_server passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm:lm_connection_set_server_WithNULL
+// Description : Sets the server address for connection to server. Notice that
+// connection can't be open while doing this.
+// Arguements :
+// connection : an LmConnection
+// server : Address of the server ( name of the server )
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_server_WithNULL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ gchar *ServerName = "\0";
+ ConnectData *connect_data = NULL;
+ gchar *NewServerName;
+
+ iLog->Log ( _L ( "In lm_connection_set_server" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( " lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+
+ // Set the servers name before the connection
+ lm_connection_set_server ( connection, ServerName );
+
+ // Verify the server name
+ NewServerName = (gchar *)lm_connection_get_server ( connection );
+
+ if ( strcmp ( NewServerName, ServerName ) != 0 )
+ {
+ iLog->Log ( _L ( "lm_connection_set_server failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Server name modified successfully
+ iLog->Log ( _L ( "lm_connection_set_server passed" ) );
+
+ return KErrNone;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_get_jid
+// Description : Sets the JID to be used for connection
+// Arguements :
+// connection : an LmConnection
+// jid : JID to be used for connection
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_get_jidL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ gchar *Jid = "connect.nokia.com";
+ const gchar *GetJid = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_jid" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new close connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set new jid
+ Jid = g_strdup_printf ( "%s@%s", connect_data->username, connect_data->server );
+ lm_connection_set_jid ( connection, Jid );
+
+
+ // Verify the Jid
+ GetJid = lm_connection_get_jid ( connection );
+ if ( strcmp ( Jid, GetJid ) != 0 )
+ {
+ iLog->Log ( _L ( "lm_connection_set_jid failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ // Remove a referece on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "lm_connection_set_jid passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_jid_WithNULL
+// Description : Sets the JID to be used for connection
+// Arguements :
+// connection : an LmConnection
+// jid : JID to be used for connection
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_jid_WithNULL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ gchar *Jid = "\0";
+ const gchar *GetJid = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_jid" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new close connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set new jid
+ Jid = g_strdup_printf ( "%s@%s", connect_data->username, connect_data->server );
+ lm_connection_set_jid ( connection, Jid );
+
+
+ // Verify the Jid
+ GetJid = lm_connection_get_jid ( connection );
+ if ( strcmp ( Jid, GetJid ) != 0 )
+ {
+ iLog->Log ( _L ( "lm_connection_set_jid failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ // Remove a referece on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "lm_connection_set_jid passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_get_port
+// Description : Sets the port that connection will be using
+// Arguements :
+// connection : an LmConnection
+// port : server port
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_get_portL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection = NULL;
+ guint LmPort;
+
+ // Open a new closed connection
+ connection = lm_connection_new ( NULL );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Sets the port
+ lm_connection_set_port ( connection, MYPORT );
+
+ // Get the port
+ LmPort = lm_connection_get_port ( connection );
+
+ // Verify the port used by the connection
+ if ( LmPort != MYPORT )
+ {
+ iLog->Log ( _L ( "lm_connection_set_port failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_set_port passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_port_WithNULL
+// Description : Sets the port that connection will be using
+// Arguements :
+// connection : an LmConnection
+// port : server port
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_port_WithNULL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection = NULL;
+ guint LmPort;
+
+ // Open a new closed connection
+ connection = lm_connection_new ( NULL );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Sets the port
+ lm_connection_set_port ( connection, FAKEPORT );
+
+ // Get the port
+ LmPort = lm_connection_get_port ( connection );
+
+ // Verify the port used by the connection
+ if ( LmPort != FAKEPORT )
+ {
+ iLog->Log ( _L ( "lm_connection_set_port failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_set_port passed" ) );
+
+ return KErrNone;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_get_ssl
+// Description : Sets SSL struct or unset if ssl is NULL.
+// If set connection will use SSL for the connection
+// Arguements :
+// connection : an LmConnection
+// ssl : an LmSSL
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_get_sslL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection = NULL;
+ LmSSL *ssl = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_ssl" ) );
+
+ if ( lm_ssl_is_supported() )
+ {
+ connection = lm_connection_new ( NULL );
+
+ ssl = lm_ssl_new ( NULL, NULL, NULL, NULL );
+
+ lm_connection_set_ssl ( connection, ssl );
+ lm_ssl_unref ( ssl );
+
+ if ( !lm_connection_get_ssl ( connection ) )
+ {
+ iLog->Log ( _L ( "lm_connection_set_ssl failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_set_ssl passed" ) );
+
+ return KErrNone;
+ }
+
+ iLog->Log ( _L ( "ssl not supported" ) );
+
+ return KErrNone;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_ssl_WithNULL
+// Description : Sets SSL struct or unset if ssl is NULL.
+// If set connection will use SSL for the connection
+// Arguements :
+// connection : an LmConnection
+// ssl : an LmSSL
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_ssl_WithNULL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection = NULL;
+ LmSSL *ssl = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_ssl" ) );
+
+ if ( lm_ssl_is_supported() )
+ {
+ connection = lm_connection_new ( NULL );
+
+ ssl = lm_ssl_new ( NULL, NULL, NULL, NULL );
+
+ lm_connection_set_ssl ( connection, ssl );
+ lm_ssl_unref ( ssl );
+
+ if ( !lm_connection_get_ssl ( connection ) )
+ {
+ iLog->Log ( _L ( "lm_connection_set_ssl failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_set_ssl passed" ) );
+
+ return KErrNone;
+ }
+
+ iLog->Log ( _L ( "ssl not supported" ) );
+
+ return KErrNone;
+ }
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_get_proxy
+// Description : Sets the proxy to use for this connection. To unset pass NULL
+// Arguements :
+// connection : an LmConnection
+// proxy : an LmProxy
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_get_proxyL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection;
+ LmProxy *Proxy;
+
+ iLog->Log ( _L ( "In lm_connection_set_proxy" ) );
+
+ connection = lm_connection_new ( NULL );
+
+ Proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+
+ // Set proxy
+ lm_connection_set_proxy ( connection, Proxy );
+ lm_proxy_unref ( Proxy );
+
+ // Verify proxy setttings
+ if ( !lm_connection_get_proxy ( connection ) )
+ {
+ iLog->Log ( _L ( "lm_connection_set_proxy failed" ) );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_set_proxy passed") );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_sendL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_sendL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+
+ iLog->Log ( _L ( "In lm_connection_send" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+ return KErrNone;
+}
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_send_with_replyL
+// Description : Send a LmMessage which will result in a reply
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// handler : LmMessageHandler that will be used when reply to a message
+// arrives
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_send_with_replyL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode *q_node;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_send_with_reply" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the port to gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // Open a connection with the server
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction )connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attributes ( q_node, "xmlns", "jabber:iq:auth", NULL );
+ lm_message_node_add_child ( q_node, "username", connect_data->username );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_messages, main_loop, NULL );
+ //we are sending a dummy username request to server and the server should reply with error or not supported message
+ //we handle this in the handler and quit the mainloop.
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref ( handler );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref ( handler );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_send_with_reply passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::register_message_handlerL
+// Description : Registers a LmMessageHandler to handle incoming messages of
+// certain type.
+// Arguements :
+// connection : Connection to register a handle for
+// handler : Message handler to register
+// type : Message type that handler will handle
+// priority : The priority in which to call handler
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::register_message_handlerL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection;
+ ConnectData *connect_data;
+ LmMessage *msg;
+ LmMessageHandler *handler;
+ HandleData *handle_data;
+ GMainLoop *main_loop = NULL;
+
+ iLog->Log ( _L ( "In register_message_handlerL" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Create a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ SSLInit ( connection );
+
+ // Open a connection with the server
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection,
+ ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction )connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ handle_data = g_new0 ( HandleData, 1 );
+ if ( !handle_data )
+ {
+ iLog->Log ( _L ( "Memory allocation failed for handle_data" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ handle_data->main_loop = main_loop;
+ handle_data->Test_Success = RC_ERROR;
+
+ // Register a message handler
+ handler = lm_message_handler_new ( handle_messages, handle_data, NULL );
+ if ( !handler )
+ {
+ iLog->Log ( _L ( "lm_message_handler_new failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL );
+ lm_message_handler_unref ( handler );
+
+
+ // Construct a message
+ msg = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_IQ );
+ lm_message_node_add_child ( msg->node, "query", NULL );
+
+
+ //Send message to the server
+ //Since we are sending dummy query to the recipient, we are expecting
+ //an error message. This indicates the response was successfully received.
+ if ( !lm_connection_send ( connection, msg, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_message_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( msg );
+ return KErrGeneral;
+ }
+
+ // Wait for the reply from the server
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ // Free the allocated resources
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( msg );
+
+ // Verify wheather the callback function called or not
+ if ( RC_OK != handle_data->Test_Success )
+ {
+ iLog->Log ( _L ( "register_message_handlerL failed" ) );
+ g_free ( handle_data );
+ return KErrGeneral;
+ }
+
+ g_free ( handle_data );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "register_message_handlerL passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::set_disconnect_functionL
+// Description : Set the callback that will be called when a connection is
+// closed
+// Arguements :
+// connection : Connection to register disconnect callback for
+// function : Function to be called when connection is closed
+// user_data : User data passed to a function
+// notify : Function to free user_data
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::set_disconnect_functionL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ HandleData *handle_data = NULL;
+
+ iLog->Log ( _L ( "In set_disconnect_functionL" ) );
+
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Create a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ SSLInit ( connection );
+
+
+ // Open a connection with the server
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ handle_data = g_new0 ( HandleData, 1 );
+ if ( !handle_data )
+ {
+ iLog->Log ( _L ( "Memory allocation failed for handle_data" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ return KErrGeneral;
+ }
+ handle_data->Test_Success = RC_ERROR;
+
+ // Set a Callback function that will be called when connection is closed
+ lm_connection_set_disconnect_function ( connection,
+ connection_close_cb,
+ handle_data,
+ NULL );
+
+ // Close the opened connection
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+
+ // Check wheather callback function is called or not
+ if ( RC_OK != handle_data->Test_Success )
+ {
+ iLog->Log ( _L ( "set_disconnect_functionL failed" ) );
+ g_free ( handle_data );
+ return KErrGeneral;
+ }
+
+ g_free ( handle_data );
+
+ iLog->Log ( _L ( "set_disconnect_functionL passed" ) );
+ free_data ( connect_data );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send_raw
+// Description : Asynchronus call to send a raw string.
+// Arguements :
+// connection : Connection used to send
+// str : The string to send, the entire string will be sent
+// error : Set if error was detected during sending
+// Returns : TRUE if no errors were detected during sending, FALSE
+// otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send_rawL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ GError *error = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_send_raw" ) );
+
+ // Read data from the cfg file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Create a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ SSLInit ( connection );
+
+ // Open a connection with the server
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ // Send a raw message
+ if ( !lm_connection_send_raw ( connection,
+ connect_data->msg_data->message,
+ &error ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_raw failed: %s"), error->message );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_send_raw passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_get_state
+// Description : Returns the state of the connection
+// Arguements :
+// connection : Connection to get state
+// Returns : The state of the connection
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_get_stateL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmConnectionState state;
+
+ iLog->Log ( _L ( "In lm_connection_get_state" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Create a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ SSLInit ( connection );
+
+ // Verify the state when the connection is closed
+ state = lm_connection_get_state ( connection );
+
+ if ( LM_CONNECTION_STATE_CLOSED != state )
+ {
+ iLog->Log ( _L ( "lm_connection_get_state failed:closed" ) );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Verify the state after opening the connection
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ state = lm_connection_get_state ( connection );
+
+ if ( LM_CONNECTION_STATE_OPEN != state )
+ {
+ iLog->Log ( _L ( "lm_connection_get_state failed: open" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction )connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+
+ state = lm_connection_get_state ( connection );
+
+ if ( LM_CONNECTION_STATE_AUTHENTICATED != state )
+ {
+ iLog->Log ( _L ( "lm_connection_get_state failed: authenticated" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_connection_get_state passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_ref
+// Description : Add a reference on connection
+// Arguements :
+// connection : Connection to a add a reference to
+// Returns : Returns the same connection
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_refL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection = NULL;
+
+ iLog->Log ( _L ("In lm_connection_unref" ) );
+
+ // Create a new closed connection
+ connection = lm_connection_new ( NULL );
+
+ // Add a reference on connection
+ connection = lm_connection_ref ( connection );
+
+ // Loudmouth don't have any API to check the ref count on connection
+ // Therefore lm_connection_ref is considered as passed.
+
+ // Decrement the reference count and free the memory
+ lm_connection_unref ( connection );
+ lm_connection_unref ( connection );
+
+ iLog->Log ( _L ( "lm_connection_ref passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_unref
+// Description : Removes the reference on connection. If there are no
+// references to connection, it will be freed and shouldn't
+// used again
+// Check the total available heap space
+// Create a new closed connection,
+// Check that available heap space is reduced
+// Decrement the reference on connection
+// Check the available heap is equal to what it was before
+// Arguements :
+// connection : Connection to remove reference from
+// Returns : None
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_unrefL ( CStifItemParser& /*aItem*/ )
+ {
+ LmConnection *connection = NULL;
+ RHeap& heap_handle = User::Heap();
+ TInt largest_free_block;
+ TInt heap_available_before;
+ TInt heap_available_after;
+
+ iLog->Log ( _L ( "In lm_connection_unref" ) );
+__UHEAP_MARK;
+ // Get the heap space before creating closed connection
+ heap_available_before = heap_handle.Available ( largest_free_block );
+
+ // Create a new closed connection
+ connection = lm_connection_new ( NULL );
+
+ // Decrement the reference on connection
+ lm_connection_unref ( connection );
+
+ // Get the heap space after freeing memory
+ heap_available_after = heap_handle.Available ( largest_free_block );
+
+ if ( heap_available_after != heap_available_before )
+ {
+ iLog->Log ( _L ( "{heap_available_before = %d, heap_available_before = %d}" ),
+ heap_available_before, heap_available_after );
+ iLog->Log ( _L ( "Available memeory is not as expected after free!" ) );
+ return KErrGeneral;
+ }
+__UHEAP_MARKEND;
+ iLog->Log ( _L ( "{ Expected:heap_available_before is equal to heap_available_after }" ) );
+ iLog->Log ( _L ( "heap_available_before = %d, heap_available_after = %d" ),
+ heap_available_before, heap_available_after );
+ iLog->Log ( _L ( "lm_connection_unref passed" ) );
+
+ return KErrNone;
+
+ }
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_new
+// Description:Creates a new LmMessage which can be sent with
+// lm_connection_send() or lm_connection_send_with_reply().
+// Arguements :
+// to : recipient jid
+// type : message type
+// Returns : a newly created LmMessage
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_newL ( CStifItemParser& aItem )
+ {
+ LmMessage *message;
+ ConnectData *connect_data = NULL;
+ LmMessageType MessageType;
+ gchar Type[256];
+
+ iLog->Log ( _L ( "\tIn lm_message_new" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "\tread_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Construct a message with a type=LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "\tConstruct a message" ) );
+
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "\tlm_message_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ // Verify the message type
+ iLog->Log ( _L ( "\tVerify the message type" ) );
+
+ MessageType = lm_message_get_type ( message );
+ if ( LM_MESSAGE_TYPE_MESSAGE != MessageType )
+ {
+ iLog->Log ( _L( "\tExpected message type: LM_MESSAGE_TYPE_MESSAGE" ) );
+ memset ( Type, '\0', sizeof ( Type ) );
+ GetMessageType ( MessageType, Type );
+ iLog->Log ( _L8 ( "\tActual message type : %s" ), Type );
+
+ iLog->Log ( _L ( "\tlm_message_get_type failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_message_new passed" ) );
+
+ return KErrNone;
+
+ }
+
+
+ // ---------------------------------------------------------------------------
+// Ctstlm::lm_message_new_with_sub_type
+// Description:Creates a new LmMessage with subtype set.
+// Arguements :
+// to : recipient jid
+// type : message type
+// sub_type : message sub type
+// Returns : a newly created LmMessage
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_new_with_sub_typeL ( CStifItemParser& aItem )
+ {
+ LmMessage *message;
+ ConnectData *connect_data = NULL;
+ LmMessageType MessageType;
+ LmMessageSubType MessageSubType;
+ gchar Type[256];
+ gchar SubType[256];
+
+ iLog->Log ( _L ( "In lm_message_new_with_sub_type" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "\tread_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Construct a message with type and sub type
+ message = lm_message_new_with_sub_type ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "\tlm_message_new_with_sub_type failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ // Verify the message type
+ MessageType = lm_message_get_type ( message );
+ if ( LM_MESSAGE_TYPE_IQ != MessageType )
+ {
+ iLog->Log ( _L ( "\tExpected message type: LM_MESSAGE_TYPE_IQ" ) );
+ memset ( Type, '\0', sizeof ( Type ) );
+ GetMessageType ( MessageType, Type );
+ iLog->Log ( _L8 ( "\tActual message type : %s"), Type );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Verify the message sub type
+ MessageSubType = lm_message_get_sub_type ( message );
+ if ( LM_MESSAGE_SUB_TYPE_SET != MessageSubType )
+ {
+ iLog->Log ( _L ( "\tExpected message subtype: LM_MESSAGE_SUB_TYPE_SET" ) );
+ memset ( SubType, '\0', sizeof ( SubType ) );
+ GetMessageSubType ( MessageSubType, SubType );
+ iLog->Log ( _L8 ( "\tActual message subtype : %s" ), SubType );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+ iLog->Log ( _L ( "lm_message_new_with_sub_type passed" ) );
+
+ return KErrNone;
+ }
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_get_type
+// Description:Fetches the type of the message
+// Arguements :
+// message : an LmMessage
+// Returns : the message type
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_get_typeL ( CStifItemParser& /*aItem*/ )
+ {
+ LmMessage *message = NULL;
+ LmMessageType MessageType;
+ gchar Type[256];
+
+ iLog->Log ( _L ( "In lm_message_get_type" ) );
+ memset ( Type, '\0', sizeof ( Type ) );
+
+ // Construct a message with a type
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_PRESENCE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "\tlm_message_new failed while constructing PRESENCE msg" ) );
+ return KErrGeneral;
+ }
+
+ // Verify the message type=LM_MESSAGE_TYPE_PRESENCE
+ iLog->Log ( _L ( "\tMessage type verification" ) );
+
+ MessageType = lm_message_get_type ( message );
+ if ( LM_MESSAGE_TYPE_PRESENCE != MessageType )
+ {
+ iLog->Log ( _L ( "\tExpected message type: LM_MESSAGE_TYPE_PRESENCE" ) ) ;
+ memset ( Type, '\0', sizeof ( Type ) );
+ GetMessageType ( MessageType, Type );
+ iLog->Log ( _L8 ( "\tActual message type :%s" ), Type );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Construct another message with type=LM_MESSAGE_TYPE_IQ
+ iLog->Log ( _L ( "\tConstruct a message with another type" ) );
+
+ lm_message_unref ( message );
+ message = NULL;
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_IQ );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "\tlm_message_new failed while constructing IQ message " ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Verify the message type
+ iLog->Log ( _L ( "\tVerify the message type" ) );
+
+ MessageType = lm_message_get_type ( message );
+ if ( LM_MESSAGE_TYPE_IQ != MessageType )
+ {
+ iLog->Log ( _L ( "\tExpected message type: LM_MESSAGE_TYPE_IQ" ) );
+ memset ( Type, '\0', sizeof ( Type ) );
+ GetMessageType ( MessageType, Type );
+ iLog->Log ( _L8 ( "\tActual message type : %s" ), Type );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+
+ iLog->Log ( _L ( "\tlm_message_get_type passed" ) );
+
+ return KErrNone;
+ }
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_get_sub_type
+// Description:Fetches the sub type of the message
+// Arguements :
+// message : an LmMessage
+// Returns : the message sub type
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_get_sub_typeL ( CStifItemParser& /*aItem*/ )
+ {
+ LmMessage *message = NULL;
+ LmMessageSubType MessageSubType;
+ gchar SubType[256];
+
+ iLog->Log ( _L ( "In lm_message_get_sub_type" ) );
+
+ // Construct a message with type and subtype=LM_MESSAGE_SUB_TYPE_SUBSCRIBE
+ iLog->Log ( _L ( "\tConstruct a message with type & subtype" ) );
+
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new_with_sub_type failed for SUBSCRIBE" ) );
+ return KErrGeneral;
+ }
+
+ // Verify message subtype
+ MessageSubType = lm_message_get_sub_type ( message );
+ if ( LM_MESSAGE_SUB_TYPE_SUBSCRIBE != MessageSubType )
+ {
+ iLog->Log ( _L ( "\tExpected MessageSubType: LM_MESSAGE_SUB_TYPE_SUBSCRIBE" ) );
+ memset ( SubType, '\0', sizeof ( SubType ) );
+ GetMessageSubType ( MessageSubType, SubType );
+ iLog->Log ( _L8 ( "\tActual MessageSubType : %s" ), SubType );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Construct another message with subtype=LM_MESSAGE_SUB_TYPE_CHAT
+ lm_message_unref ( message );
+ message = NULL;
+
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_MESSAGE_SUB_TYPE_CHAT );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "\tlm_message_new_with_sub_type failed for CHAT" ) );
+ return KErrGeneral;
+ }
+
+ // Verify message subtype
+ MessageSubType = lm_message_get_sub_type ( message );
+ if ( LM_MESSAGE_SUB_TYPE_CHAT != MessageSubType )
+ {
+ iLog->Log ( _L ( "\tExpected MessageSubType: LM_MESSAGE_SUB_TYPE_CHAT" ) );
+
+ memset ( SubType, '\0', sizeof ( SubType ) );
+ GetMessageSubType ( MessageSubType, SubType );
+ iLog->Log ( _L8 ( "\tActual MessageSubType : %s" ), SubType );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+
+ iLog->Log ( _L ( "\tlm_message_get_sub_type passed" ) );
+
+ return KErrNone;
+ }
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_get_node
+// Description:Retrives the root node from LmMessage
+// Arguements :
+// message : an LmMessage
+// Returns : an LmMessageNode
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_get_nodeL ( CStifItemParser& /*aItem*/ )
+ {
+ LmMessage *message;
+ LmMessageNode *Node = NULL;
+
+ iLog->Log ( _L ( "In lm_message_get_node" ) );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive root node from the message
+ iLog->Log ( _L ( "Retrive root node from message" ) );
+
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_get_node passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_ref
+// Description:Adds a reference to message
+// Arguements :
+// message : an LmMessage
+// Returns : an message
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_refL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+
+ iLog->Log ( _L ( "In lm_message_ref" ) );
+
+ // Construct a message
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Add a reference to message
+ message = lm_message_ref ( message );
+
+ // Loudmouth don't have any API to check the ref count on message
+ // Therefore lm_message_ref is considered as passed.
+
+ // Decrement the reference(2 times) to message and free the memory
+ lm_message_unref ( message );
+ lm_message_unref ( message );
+
+ iLog->Log ( _L ( "lm_message_ref passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_unref
+// Description:Removes a reference from message. When no more references are
+// present, the message is freed.
+// Check the total available heap space
+// Construct a new message by using lm_message_new
+// Check that available heap space is reduced
+// Decrement the reference from message
+// Check the available heap is equal to what it was before
+// Arguements :
+// message : an LmMessage
+// Returns : None
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_unrefL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message;
+ RHeap& heap_handle = User::Heap();
+ TInt largest_free_block;
+ TInt heap_available_before;
+ TInt heap_available_after;
+
+ iLog->Log ( _L ( "In lm_message_unref" ) );
+
+ // Get the total heap space before constructing a message
+ iLog->Log ( _L ( "Getting the heap size before message construction" ) );
+ heap_available_before = heap_handle.Available ( largest_free_block );
+
+ // Construct a message
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Decrement the reference from message
+ iLog->Log ( _L ( "Remove the reference from the message" ) );
+ lm_message_unref ( message );
+
+ // Get the heap space after freeing memory
+ iLog->Log ( _L ( "Getting the heap size after freeing the memory" ) );
+ heap_available_after = heap_handle.Available ( largest_free_block );
+
+ // Compare the heap size
+ iLog->Log ( _L ( "Comparing heap size before and after freeing memory" ) );
+
+ if ( heap_available_after != heap_available_before )
+ {
+ iLog->Log ( _L ( "heap_available_before = %d, heap_available_after = %d" ),
+ heap_available_before, heap_available_after );
+ iLog->Log ( _L ( "Available memory is not as expected after freeing" ) );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Expected: heap_available_before is equal to heap_available_after" ) );
+ iLog->Log ( _L ( "heap_available_before = %d, heap_available_after = %d" ),
+ heap_available_before, heap_available_after );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_handler_new
+// Description:Creates a new message handler.This can be set to handle incoming
+// messages and when a message of type the handler is registered to
+// handle is received function will be called and user_data will be
+// passed to it. notify is called when the message handler is freed,
+// that way any memory allocated by user_data can be freed.
+// Arguements :
+// function : a callback
+// user_data : user data passed to function
+// notify : function called when the message handler is freed
+// Returns : a newly created message handler
+//
+// Note : This test case requires UI mode to select Access point
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_handler_newL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_message_handler_new" ) );
+
+ // Create a new message handler
+ handler = lm_message_handler_new ( handle_messages, NULL, NULL );
+ if ( !handler )
+ {
+ iLog->Log ( _L ( "lm_message_handler_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Validate the handler
+ if ( !lm_message_handler_is_valid ( handler ) )
+ {
+ iLog->Log ( _L ( "message handler is not valid" ) );
+ lm_message_handler_unref ( handler );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "lm_message_handler_new passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_handler_invalidate
+// Description:Invalidates the handler. Useful if you need to cancel a reply
+// Arguements :
+// handler : an LmMessageHandler
+// Returns : None
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_handler_invalidateL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessageHandler *handler = NULL;
+ gboolean IsValid;
+
+ iLog->Log ( _L ( "In lm_message_handler_invalidate" ) );
+
+ // Create a new message handler
+ iLog->Log ( _L ( "Creat a new message handler" ) );
+
+ handler = lm_message_handler_new ( handle_messages, NULL, NULL );
+ if ( !handler )
+ {
+ iLog->Log ( _L ( "lm_message_handler_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Invalidate the message handler ( handler->valid = FALSE )
+ iLog->Log ( _L ( "Invalidate the handler" ) );
+ lm_message_handler_invalidate ( handler );
+
+ // Check for validity of message handler
+ iLog->Log ( _L ( "Checking validity of message handler" ) );
+
+ IsValid = lm_message_handler_is_valid ( handler );
+ if ( IsValid )
+ {
+ iLog->Log ( _L ( "lm_message_handler_invalidate failed" ) );
+ lm_message_handler_unref ( handler );
+ return KErrGeneral;
+ }
+
+ lm_message_handler_unref ( handler );
+
+ iLog->Log ( _L ( "lm_message_handler_invalidate passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_handler_is_valid
+// Description:Fetches whether the handler is valid or not.
+// Arguements :
+// handler : an LmMessageHandler
+// Returns : TRUE if handler is valid, otherwise FALSE
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_handler_is_validL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_message_handler_is_valid" ) );
+
+ // Create a new message handler
+ iLog->Log ( _L ( "Constructing new message handler" ) );
+ handler = lm_message_handler_new ( handle_messages, NULL, NULL );
+ if ( !handler )
+ {
+ iLog->Log ( _L ( "lm_message_handler_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Check the validity of the message handler
+ iLog->Log ( _L ( "Check for validity of message handler" ) );
+ if ( !lm_message_handler_is_valid ( handler ) )
+ {
+ iLog->Log ( _L ( "lm_message_handler_is_valid failed" ) );
+ lm_message_handler_unref ( handler );
+ return KErrGeneral;
+ }
+
+ // Invalidate the handler ( set handler->valid = FALSE )
+ iLog->Log ( _L ( "Invalidate the message handler" ) );
+ lm_message_handler_invalidate ( handler );
+
+ // check for validity of message handler after invalidating
+ iLog->Log ( _L ( "Check for validity after invalidating" ) );
+
+ if ( lm_message_handler_is_valid ( handler ) )
+ {
+ iLog->Log ( _L ( "lm_message_handler_is_valid failed" ) );
+ lm_message_handler_unref ( handler );
+ return KErrGeneral;
+ }
+
+ lm_message_handler_unref ( handler );
+
+ iLog->Log ( _L ( "lm_message_handler_is_valid passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_handler_ref
+// Description:Adds a reference to handler
+// Arguements :
+// handler : an LmMessageHandler
+// Returns : the message handler
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_handler_refL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_message_handler_ref" ) );
+
+ // Create a new message handler
+ iLog->Log ( _L ( "Construct a new message handler" ) );
+
+ handler = lm_message_handler_new ( handle_messages, NULL, NULL );
+ if ( !handler )
+ {
+ iLog->Log ( _L ( "lm_message_handler_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Loudmouth don't have any API to check reference to handler
+ // Therefore this test is considered as passed without checking
+
+ iLog->Log ( _L ( "Remove a reference from the message handler" ) );
+ lm_message_handler_unref ( handler );
+
+ iLog->Log ( _L ( "lm_message_handler_ref passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_handler_unref
+// Description:Removes a reference from handler. When no more references are
+// present, the handler is freed
+// Check the total available heap space
+// Construct a new message handler
+// Check that available heap space is reduced
+// Remove reference from the message handler
+// Check the available heap is equal to what it was before
+// Arguements :
+// handler : an LmMessageHandler
+// Returns : None
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_handler_unrefL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessageHandler *handler = NULL;
+ RHeap& heap_handle = User::Heap();
+ TInt largest_free_block;
+ TInt heap_avail_before;
+ TInt heap_avail_after;
+
+ iLog->Log ( _L ( "Inlm_message_handler_unref" ) );
+
+ // Get the total heap size before creating new message handler
+ iLog->Log ( _L ( "Get the heap size before allocating memory" ) );
+ heap_avail_before = heap_handle.Available ( largest_free_block );
+
+ // Create a new message handler
+ iLog->Log ( _L ( "Construct a new message handler" ) );
+
+ handler = lm_message_handler_new ( handle_messages, NULL, NULL );
+ if ( !handler )
+ {
+ iLog->Log ( _L ( "lm_message_handler_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Remove a reference from the message handler
+ iLog->Log ( _L ( "Freeing allocated memory" ) );
+ lm_message_handler_unref ( handler );
+
+ // Get the heap size after removing reference from message handler
+ iLog->Log ( _L ( "Get the heap size after freeing memory" ) );
+ heap_avail_after = heap_handle.Available ( largest_free_block );
+
+ // Compare the heap size
+ iLog->Log ( _L ( "Compare the heap size after freeing memory" ) );
+
+ if ( heap_avail_before != heap_avail_after )
+ {
+ iLog->Log ( _L ( "heap_avail_before = %d, heap_avail_after = %d" ),
+ heap_avail_before, heap_avail_after );
+ iLog->Log ( _L ( "Available memory is not as expected after freeing" ) );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Expected: heap_avail_before is equal to heap_avail_after" ) );
+ iLog->Log ( _L ( "heap_avail_before = %d, heap_avail_after = %d" ),
+ heap_avail_before, heap_avail_after );
+
+ return KErrNone;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_set_value
+// Description:Sets the value of node. If a prev value is set it will be freed
+// Arguements :
+// Node : an LmMessageNode
+// value : the new value
+// Returns : None
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_set_get_valueL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+ const gchar *SetUsername = "Nokia";
+
+ iLog->Log ( _L ( "In lm_message_node_get_value" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retriving root node from the message" ) );
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Set the value of the node
+ iLog->Log ( _L ( "Set the value of the node" ) );
+ lm_message_node_set_value ( Node, SetUsername );
+
+ // Retrive the value of node
+ iLog->Log ( _L ( "Retrive the value of the node" ) );
+ const gchar *GetUsername = lm_message_node_get_value ( Node );
+
+ // Verify the result
+ iLog->Log ( _L ( "Verify value of node" ) );
+ if ( strcmp ( SetUsername, GetUsername ) )
+ {
+ iLog->Log ( _L ( "lm_message_set_value failed" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_set_value passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_add_child
+// Description:Add a child node with a name and value
+// Arguements :
+// node : an LmMessageNode
+// name : name of the new child
+// value : value of the new child
+// Returns : the newly created child
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_add_childL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+ const gchar *Username = "Nokia";
+
+ iLog->Log ( _L ( "In lm_message_node_add_child" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from message" ) );
+
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Add a child
+ iLog->Log ( _L ( "Add a child 'username' to node" ) );
+ lm_message_node_add_child ( Node, "username", Username );
+
+ // Verify the child
+ iLog->Log ( _L ( "Verify the child" ) );
+ if ( !lm_message_node_get_child ( Node, "username" ) )
+ {
+ iLog->Log ( _L ( "lm_message_add_child failed" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Freeing allocated resources" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_node_add_child passed" ) );
+
+ return KErrNone;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_find_child
+// Description:Locates a child among all children of node. The entire tree will
+// be searched until a child with a name child_name is located.
+// Arguements :
+// node : an LmMessageNode
+// name : name of the child to find
+// Returns : located child or NULL if not found
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_find_childL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+ const gchar *Username = "Nokia";
+ const gchar *Password = "Nokia";
+
+ iLog->Log ( _L ( "In lm_message_node_find_child" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from the message" ) );
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Add childrens
+ iLog->Log ( _L ( "Adding childrens 'username' and 'password'" ) );
+ lm_message_node_add_child ( Node, "username", Username );
+ lm_message_node_add_child ( Node, "password", Password );
+
+ // Locate the child 'username'
+ iLog->Log ( _L ( "Locate the child 'username'" ) );
+ if ( !lm_message_node_find_child ( Node, "username" ) )
+ {
+ iLog->Log ( _L ( "lm_message_node_find_child: child 'username' not found" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ // Locate the child 'password'
+ if ( !lm_message_node_get_child ( Node, "password" ) )
+ {
+ iLog->Log ( _L ( "lm_message_node_find_child: child 'password' not found" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_node_find_child passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_set_get_attributes
+// Description:Sets a list of attributes. The arguements should be names and
+// correspoinding values and needs to be ended with NULL.
+// Arguements :
+// node : an LmMessageNode
+// name : first attribute, should be fallowed by string with value
+// .. : rest of the name/value pairs
+// Returns : None
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_set_get_attributesL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+ const gchar *Value = "Nokia";
+
+ iLog->Log ( _L ( "In lm_message_node_set_attributes" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from the message" ) );
+
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Set attributes
+ iLog->Log ( _L ("Setting attributes 'username', 'password' and 'xmlns'" ) );
+ lm_message_node_set_attributes ( Node,
+ "username", Value,
+ "password", Value,
+ "xmlns", "jabber:iq:register",
+ NULL );
+
+ // Verify the attributes set
+ iLog->Log ( _L (" Verify the attributes" ) );
+
+ if ( !lm_message_node_get_attribute ( Node, "username" ) )
+ {
+ iLog->Log ( _L ( "lm_message_set_attributes failed for username" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ if ( !lm_message_node_get_attribute ( Node, "password" ) )
+ {
+ iLog->Log ( _L ( "lm_message_set_attributes failed for password" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ if ( !lm_message_node_get_attribute ( Node, "xmlns" ) )
+ {
+ iLog->Log ( _L ( "lm_message_set_attributes failed for xmlns" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_node_set_attributes passed" ) );
+
+ return KErrNone;
+}
+
+
+
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_set_get_raw_mode
+// Description:Checks if the nodes values should be sent as raw mode
+// Arguements :
+// node : an LmMessageNode
+// Returns : TRUE if nodes value should be sent as is
+// FALSE if the value will be escaped before sending
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_set_get_raw_modeL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+
+ iLog->Log ( _L ( "In lm_message_node_set_raw_mode" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from message" ) );
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Set the raw mode to TRUE
+ iLog->Log ( _L ( "Set the node to raw mode" ) );
+ lm_message_node_set_raw_mode ( Node, TRUE );
+
+ // Check if the Node is in raw mode or not after setting
+ iLog->Log ( _L ( "Check for raw mode after setting" ) );
+ if ( !lm_message_node_get_raw_mode ( Node ) )
+ {
+ iLog->Log ( _L ( "get_raw_mode returned FALSE after setting raw mode" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ // Set the raw mode to FALSE
+ iLog->Log ( _L ( "Unset the raw mode" ) );
+ lm_message_node_set_raw_mode ( Node, FALSE );
+
+ // Check for raw mode
+ iLog->Log ( _L ( "Check for raw mode after unsetting" ) );
+ if ( lm_message_node_get_raw_mode ( Node ) )
+ {
+ iLog->Log ( _L ( "get_raw_mode returned TRUE after unsetting" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_node_set_raw_mode passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_ref
+// Description:Adds a reference to node
+// Arguements :
+// node : an LmMessageNode
+// Returns : the node
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_refL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+
+ iLog->Log ( _L ( "In lm_message_node_ref" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from message" ) );
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Add a reference to node
+ lm_message_node_ref ( Node );
+
+ // Loudmouth dont have any API to check reference on message node
+ // Therefore lm_message_node_ref is considered as passed without checking
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_node_ref passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_unref
+// Description: Removes a reference from the the node. When no more
+// reference are present, the node is freed. When freed
+// lm_message_node_unref() will be called on all children.
+// Check the size of the heap just to verify whether node
+// is freed or not when no more references to the node
+// Arguements :
+// node : an LmMessageNode
+// Returns : Node
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_unrefL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+
+ RHeap& heap_handle = User::Heap();
+ TInt largest_free_block;
+ TInt heap_avail_before;
+ TInt heap_avail_after;
+
+ iLog->Log ( _L ( "In lm_message_node_unref" ) );
+
+ // Get the heap size before constructing a message
+ heap_avail_before = heap_handle.Available ( largest_free_block );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from message" ) );
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Remove reference from the message
+ iLog->Log ( _L ( "Remove reference from the message" ) );
+ lm_message_unref ( message );
+
+ // Remove reference from the node
+ iLog->Log ( _L ( "Remove a reference from the node" ) );
+ lm_message_node_unref ( Node );
+
+ // Get the heap size after removing references
+ heap_avail_after = heap_handle.Available ( largest_free_block );
+
+ // Verify the heap size
+ if ( heap_avail_after != heap_avail_before )
+ {
+ iLog->Log ( _L ( "heap_avail_before = %d, heap_avail_after = %d" ),
+ heap_avail_before, heap_avail_after );
+ iLog->Log ( _L ( "Available memory is not as expected after freeing" ) );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Expected: heap_available_before is equal to heap_available_after" ) );
+ iLog->Log ( _L ( "heap_avail_before = %d, heap_avail_after = %d" ),
+ heap_avail_before, heap_avail_after );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_to_string
+// Description:Returns an XML string representing the node. This is what
+// is sent over the connection. This is used internally by
+// loudmouth and is external for debugging purposes
+// Arguements :
+// node : an LmMessageNode
+// Returns : an XML string representation of node
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_to_stringL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ gchar *XmlString = NULL;
+
+
+ iLog->Log ( _L ( "In lm_message_node_to_string" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_PRESENCE
+ iLog->Log ( _L ( "Construct a message with type=presence" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_PRESENCE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed for type = PRESENCE" ) );
+ return KErrGeneral;
+ }
+
+ // Convert node to XML string
+ XmlString = lm_message_node_to_string ( message->node );
+
+ // Check in XML string for <presence> stanza
+ if ( !g_strrstr ( XmlString, "presence" ) )
+ {
+ iLog->Log ( _L ( "XML string doesnt contain <presence> stanza" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ lm_message_unref ( message );
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_IQ );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed for type = IQ" ) );
+ return KErrGeneral;
+ }
+
+ // Convert the message node to XML string
+ XmlString = lm_message_node_to_string ( message->node );
+
+ // Check in XML string for <iq> stanza
+ if ( !g_strrstr ( XmlString, "iq" ) )
+ {
+ iLog->Log ( _L ( "XML string doesnt contain <iq> stanza" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "lm_message_node_to_string passed" ) );
+ lm_message_unref ( message );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_ssl_new
+// Description: Creates a new ssl struct
+// Arguements :
+// expected_fingerprint : The expected fingerprint. ssl_function will be
+// called if there is a mismatch. NULL if you
+// are not interested in this check.
+// ssl_cb : Callback called to inform the user of a problem
+// during setting up the SSL connection and how
+// to proceed.
+// user_data : Data sent with the callback
+// notify : Function to free user_data when the connection
+// is finished.
+// Returns : A new LmSSL struct
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_ssl_newL ( CStifItemParser& /*aItem*/ )
+{
+ LmSSL *ssl = NULL;
+
+ iLog->Log ( _L ( "In lm_ssl_new" ) );
+
+ ssl = lm_ssl_new ( NULL, ( LmSSLFunction ) ssl_cb, NULL, NULL );
+ if ( !ssl )
+ {
+ iLog->Log ( _L ( "lm_ssl_new failed" ) );
+ return KErrGeneral;
+ }
+
+ lm_ssl_unref ( ssl );
+
+ iLog->Log ( _L ( "lm_ssl_new passed" ) );
+
+ return KErrNone;
+}
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_ssl_is_supportedL
+// Description: Checks wheather the Loudmouth supports SSL or not.
+// Arguements : None
+// Returns : TRUE if loudmouth supports SSL, FALSE otherwise
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_ssl_is_supportedL ( CStifItemParser& /*aItem*/ )
+{
+ iLog->Log ( _L ( "In lm_ssl_is_supported" ) );
+
+ if ( !lm_ssl_is_supported() )
+ {
+ iLog->Log ( _L ( "Loudmouth installation doesn't support SSL" ) );
+ }
+ else
+ {
+ iLog->Log ( _L ( "Loudmouth supports SSL" ) );
+ }
+
+ iLog->Log ( _L ( "lm_ssl_is_supported passed" ) );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_ssl_get_fingerprintL
+// Description: Returns the MD5 fingerprint of the remote server's certificate.
+// Arguements :
+// ssl : An LmSSL
+// Returns : A 16-byte array indicating fingerprint or NULL if unknow
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_ssl_get_fingerprintL ( CStifItemParser& /*aItem*/ )
+{
+ LmSSL *ssl;
+
+ iLog->Log ( _L ( "In lm_ssl_get_fingerprint" ) );
+
+ ssl = lm_ssl_new ( "--ssl", ( LmSSLFunction )ssl_cb, NULL, NULL );
+
+ const gchar *fingerprint = lm_ssl_get_fingerprint ( ssl );
+ if ( !fingerprint )
+ {
+ iLog->Log ( _L ( "Not able to get the remote server's certificate" ) );
+ }
+
+ iLog->Log ( _L ( "lm_ssl_get_fingerprint passed" ) );
+ lm_ssl_unref ( ssl );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_ssl_ref
+// Description: Adds a reference to ssl
+// Arguements :
+// ssl : An LmSSL
+// Returns : LmSSL
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_ssl_refL ( CStifItemParser& /*aItem*/ )
+{
+ LmSSL *ssl;
+
+ iLog->Log ( _L ( "In lm_ssl_ref" ) );
+
+ ssl = lm_ssl_new ( NULL, NULL, NULL, NULL );
+ if ( !ssl )
+ {
+ iLog->Log ( _L ( "lm_ssl_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Add a reference to ssl
+ lm_ssl_ref ( ssl );
+
+ // Loudmouth don't have any API to get the reference to ssl.
+ // Therefore this test case is considered as passed without verifying it
+ lm_ssl_unref ( ssl );
+
+ iLog->Log ( _L ( "lm_ssl_ref passed" ) );
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_ssl_unref
+// Description: Removes a reference from ssl.
+// When no more references are present, ssl is freed.
+// Check the heap size to ensure that lm_ssl_unref frees the ssl
+// when no more references are present.
+// Arguements :
+// ssl : An LmSSL
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_ssl_unrefL ( CStifItemParser& /*aItem*/ )
+{
+ RHeap& heap_handle = User::Heap();
+ TInt largest_free_block;
+ TInt heap_avail_before;
+ TInt heap_avail_after;
+
+ LmSSL *ssl = NULL;
+
+ iLog->Log ( _L ( "In lm_ssl_unref" ) );
+
+ // Get the heap size before creating a new ssl
+ heap_avail_before = heap_handle.Available ( largest_free_block );
+
+ // Create a new ssl
+ ssl = lm_ssl_new ( NULL, NULL, NULL, NULL );
+ if ( !ssl )
+ {
+ iLog->Log ( _L ( "lm_ssl_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Remove a reference from the ssl
+ lm_ssl_unref ( ssl );
+
+ // Get the heap size after freeing memory
+ heap_avail_after = heap_handle.Available ( largest_free_block );
+
+ // Compare the heap size
+ if ( heap_avail_after != heap_avail_before )
+ {
+ iLog->Log ( _L ( "heap_avail_before = %d, heap_avail_after = %d" ),
+ heap_avail_before, heap_avail_after );
+ iLog->Log ( _L ( "Available memory is not as expected after unref" ) );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Expected: heap_avail_before is equal to heap_avail_after" ) );
+ iLog->Log ( _L ( "heap_avail_before = %d, heap_avail_after = %d" ),
+ heap_avail_before, heap_avail_after );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_new
+// Description:Creates a new proxy
+// Arguements :
+// type : proxy type (LM_PROXY_TYPE_NONE/LM_PROXY_TYPE_HTTP)
+// Returns : a newly created proxy
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_newL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+ LmProxyType Type;
+
+ iLog->Log ( _L ( "In lm_proxy_new" ) );
+
+ iLog->Log ( _L ( "Create a new proxy" ) );
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ // Verify the proxy type
+ iLog->Log ( _L ( "Proxy type verification" ) );
+
+ Type = lm_proxy_get_type ( proxy );
+ if ( LM_PROXY_TYPE_HTTP != Type )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ lm_proxy_unref ( proxy );
+
+ iLog->Log ( _L ( "lm_proxy_new passed" ) );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_new_with_server
+// Description:Creates a new proxy
+// Arguements :
+// type : proxy type (LM_PROXY_TYPE_NONE/LM_PROXY_TYPE_HTTP)
+// server : proxy server
+// port : proxy server port
+// Returns : a newly created proxy
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_new_with_serverL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+ guint port = 8000;
+ const gchar *server = "nokia.com";
+
+
+ iLog->Log ( _L ( "In lm_proxy_new_with_server" ) );
+ // Create a new proxy with the server
+ proxy = lm_proxy_new_with_server ( LM_PROXY_TYPE_HTTP, server, port );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new_with_server failed" ) );
+ return KErrGeneral;
+ }
+
+ // Verify proxy type, server and port
+ iLog->Log ( _L ( "Verify server, type and port in proxy" ) );
+
+ if ( LM_PROXY_TYPE_HTTP != lm_proxy_get_type ( proxy ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_new_with_server failed for proxy type setting" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ if ( strcmp ( server, lm_proxy_get_server ( proxy ) ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_new_with_server failed for server setting" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ if ( port != lm_proxy_get_port ( proxy ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_new_with_server failed for port setting" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ lm_proxy_unref ( proxy );
+
+ iLog->Log ( _L ( "lm_proxy_new_with_server passed" ) );
+
+ return KErrNone;
+}
+
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_set_get_type
+// Description:Sets the proxy type for proxy to type
+// Arguements :
+// proxy : an LmProxy
+// type : proxy type
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_set_get_typeL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+
+ iLog->Log ( _L ( "In lm_proxy_set_get_type" ) );
+
+ // Create a new proxy with type=LM_PROXY_TYPE_NONE
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_NONE );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Set the proxy type=LM_PROXY_TYPE_HTTP
+ lm_proxy_set_type ( proxy, LM_PROXY_TYPE_HTTP );
+
+ // Verify the proxy type for LM_PROXY_TYPE_HTTP
+ if ( LM_PROXY_TYPE_HTTP != lm_proxy_get_type ( proxy ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_type failed" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ lm_proxy_unref ( proxy );
+
+ iLog->Log ( _L ( "lm_proxy_set_get_type passed" ) );
+
+ return KErrNone;
+}
+
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_set_get_server
+// Description:Sets the server address for proxy
+// Arguements :
+// proxy : an LmProxy
+// server : address of the proxy server
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_set_get_serverL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+ const gchar *server = "nokia.com";
+
+ iLog->Log ( _L ( "In lm_proxy_get_server" ) );
+
+ // Create a new proxy with type = LM_PROXY_TYPE_HTTP
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Set the proxy server to "nokia.com"
+ lm_proxy_set_server ( proxy, server );
+
+ // Verify the server address in proxy
+ if ( strcmp ( server, lm_proxy_get_server ( proxy ) ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_server failed" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ lm_proxy_unref ( proxy );
+
+ iLog->Log ( _L ( "lm_proxy_set_server passed" ) );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_set_port
+// Description:Sets the server port that proxy will be using
+// Arguements :
+// proxy : an LmProxy
+// port : proxy server port
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_set_get_portL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+ guint port1 = 80;
+ guint port2 = 21;
+
+ iLog->Log ( _L ( "In lm_proxy_set_get_port" ) );
+
+ // Create new proxy
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Set the port = port1
+ lm_proxy_set_port ( proxy, port1 );
+
+ // Verify the port
+ if ( port1 != lm_proxy_get_port ( proxy ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_port failed for port = %d" ), port1 );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ // Set the port = port2
+ lm_proxy_set_port ( proxy, port2 );
+
+ // Verify the port
+ if ( port2 != lm_proxy_get_port ( proxy ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_port failed for port = %d" ), port2 );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ lm_proxy_unref ( proxy );
+
+ iLog->Log ( _L ( "lm_proxy_set_get_port passed" ) );
+
+ return KErrNone;
+}
+
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_set_username
+// Description:Sets the username for proxy or NULL to unset
+// Arguements :
+// proxy : an LmProxy
+// username : username
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_set_get_usernameL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+ const gchar *user1 = "nokia";
+ const gchar *user2 = "linux";
+
+ iLog->Log ( _L ( "In lm_proxy_set_get_username" ) );
+
+ // Create a new proxy
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Set the proxy username to "nokia"
+ lm_proxy_set_username ( proxy, user1 );
+
+ // Verify the proxy username
+ if ( strcmp ( user1, lm_proxy_get_username ( proxy ) ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_username failed for user1" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ // Set the proxy username to "linux"
+ lm_proxy_set_username ( proxy, user2);
+
+ // Verify the proxy username
+ if ( strcmp ( user2, lm_proxy_get_username ( proxy ) ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_username failed for user2" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ lm_proxy_unref ( proxy );
+
+ iLog->Log ( _L ( "lm_proxy_set_get_username passed" ) );
+
+ return KErrNone;
+}
+
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_set_password
+// Description:Sets the password for proxy
+// Arguements :
+// proxy : an LmProxy
+// Returns : the proxy password
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_set_get_passwordL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+ const gchar *password = "nokia";
+
+ iLog->Log ( _L ( "In lm_proxy_set_get_passrod" ) );
+
+ // Create a new proxy
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Set the password proxy to "nokia"
+ lm_proxy_set_password ( proxy, password );
+
+ // Verify the password
+ if ( strcmp ( password, lm_proxy_get_password ( proxy ) ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_password failed" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ // Unset the password
+ lm_proxy_set_password ( proxy, NULL );
+
+ // Verify the password
+ if ( lm_proxy_get_password ( proxy ) )
+ {
+ iLog->Log ( _L ( "lm_proxy_set_password failed" ) );
+ lm_proxy_unref ( proxy );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "lm_proxy_set_password passed" ) );
+ lm_proxy_unref ( proxy );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_ref
+// Description:Adds a reference to proxy
+// Arguements :
+// proxy : an LmProxy
+// Returns : the proxy
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_refL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+
+ iLog->Log ( _L ( "In lm_proxy_ref" ) );
+
+ // Creat a new proxy
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Add a reference to proxy
+ proxy = lm_proxy_ref ( proxy );
+
+ // Loudmouth don't provide API for getting reference to the proxy
+ // Therefore this test case is considered as passed without checking
+ iLog->Log ( _L ( "lm_proxy_ref passed" ) );
+ lm_proxy_unref ( proxy );
+ lm_proxy_unref ( proxy );
+
+ return KErrNone;
+}
+
+
+// ---------------------------------------------------------------------------
+// Ctstlm::lm_proxy_unref
+// Description:Removes a reference from the proxy
+// When no more rererences are present proxy is freed
+// Check the heap size to ensure that lm_proxy_unref free
+// the proxy when no more references are present.
+// Arguements :
+// proxy : an LmProxy
+// Returns : None
+// ---------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_proxy_unrefL ( CStifItemParser& /*aItem*/ )
+{
+ LmProxy *proxy = NULL;
+
+ RHeap& heap_handle = User::Heap();
+ TInt largest_free_block;
+ TInt heap_avail_before;
+ TInt heap_avail_after;
+
+ iLog->Log ( _L ( "In lm_proxy_unref" ) );
+
+ // Get the heap size before creating a new proxy
+ heap_avail_before = heap_handle.Available ( largest_free_block );
+
+ // Create a new proxy
+ proxy = lm_proxy_new ( LM_PROXY_TYPE_HTTP );
+ if ( !proxy )
+ {
+ iLog->Log ( _L ( "lm_proxy_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Remove a reference from the proxy
+ lm_proxy_unref ( proxy );
+
+ // Get the heap size
+ heap_avail_after = heap_handle.Available ( largest_free_block );
+
+ // Compare the heap size
+ if ( heap_avail_after != heap_avail_before )
+ {
+ iLog->Log ( _L ( "heap_available_before = %d, heap_available_after = %d" ),
+ heap_avail_before, heap_avail_after );
+ iLog->Log ( _L ( "Available memory is not as expected after freeing" ) );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Expected: heap_available_before is equal to heap_available_after" ) );
+ iLog->Log ( _L ( "heap_available_before = %d, heap_available_after = %d" ),
+ heap_avail_before, heap_avail_after );
+ iLog->Log ( _L ( "lm_message_unref passed" ) );
+
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_send_sync
+// Description : Opens a connection with the gtalk server and sends a jabber
+// message to the another person
+// Requires : This test case requires GUI mode for selecting Access point
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_send_syncL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ LmMessage *message = NULL;
+
+ ConnectData *connect_data = NULL;
+
+ GError *error = NULL;
+
+ iLog->Log ( _L ( "In lm_send_sync" ) );
+
+ // Read data from the CFG file
+ iLog->Log ( _L ( "Reading data from the CFG file" ) );
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "Read data from the CFG file" ) );
+ iLog->Log ( _L8 ( "Server name: %s" ), connect_data->server );
+
+ // Open a new closed connection
+ iLog->Log ( _L ( "Open a new closed connection" ) );
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "New closed connection opened" ) );
+
+ iLog->Log ( _L ( "Setting jid" ) );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ iLog->Log ( _L ( "Setting gtalks SSL port" ) );
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Proxy settings for emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set connection to use SSL
+ iLog->Log ( _L ( "Setting SSL for the connection" ) );
+ SSLInit ( connection );
+
+ iLog->Log ( _L ( "Open a connection with the server" ) );
+ //Calling connection open
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ iLog->Log ( _L ( "connection with the server successfull" ) );
+
+ iLog->Log ( _L ( "Getting the username from the server" ) );
+ iLog->Log ( _L8 ( "jid: %s" ), connect_data->username );
+ // Get the user from the full JID
+ gchar *username = get_user_name ( connect_data->username );
+ iLog->Log ( _L ( "after extracting from the jid: %s" ), username );
+
+
+ iLog->Log ( _L ( "Authenticating with the server" ) );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction )connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ iLog->Log ( _L ( "Authentication done" ) );
+
+ // Send a message to the server
+ iLog->Log ( _L8 ( "Create a new message: %s" ),
+ connect_data->msg_data->recipient );
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "Add a node" ) );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message );
+
+
+ iLog->Log ( _L ( "Send message to the server" ) );
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "Message has been sent" ) );
+
+ iLog->Log ( _L ( "Free the allocated resources" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "Freed" ) );
+
+ iLog->Log ( _L ( "lm_send_sync passed" ) );
+
+ return KErrNone;
+ }
+
+ //-----------------------------------------------------------------------------
+// Ctstlm::lm_is_authenticated_WhenNotAuthenticatedL
+// Description : Check if connection is authenticated or not
+// Arguements :
+// connection : an LmConnection to check
+// Returns : TRUE if connection is authenticated, FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_is_authenticated_WhenNotAuthenticatedL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ gboolean NotAuthenticated = FALSE;
+
+ iLog->Log ( _L ( "In lm_connection_is_authenticated" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the connection to use gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID to be used for connection
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // Open a connection
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ // Check for authentication after the connection is authenticated
+ if ( lm_connection_is_authenticated ( connection ) )
+ {
+ iLog->Log ( _L ( "lm_is_authenticated_WhenNotAuthenticatedL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_is_authenticated_WhenNotAuthenticatedL passed" ) );
+
+ return KErrNone;
+ }
+
+
+
+//--------------------------------------------------------------------------------
+// function_name : handle_fetch_contactlist_messages
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_fetch_contactlist_messages ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ break;
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ //return NULL;
+ break;
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+ q_node = lm_message_node_get_child (reply->node, "query");
+
+ if (!q_node)
+ {
+ //return NULL;
+ }
+
+ item_node = lm_message_node_get_child (q_node, "item");
+
+ while (item_node)
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(item_node,"jid");
+ char* friendname;
+ const char* atstring = "@";
+ friendname = strtok((char*)reply_string,atstring );
+ item_node = item_node->next;
+ }
+
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_fetching_contactlistL
+// Description : fetching contact list
+// Arguements :
+// connection :
+// message :
+// error :
+// Returns :
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_fetching_contactlist_L ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode *q_node;
+ //LmMessageSubType type;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_fetching_contactlist_L" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ //Open call
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction )connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,
+ "xmlns", "jabber:iq:roster",
+ NULL);
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_fetching_contactlist_L passed" ) );
+
+ return KErrNone;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_fetching_presenceL
+// Description : fetching contact list
+// Arguements :
+// connection :
+// message :
+// error :
+// Returns :
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_fetching_presenceL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ //LmMessageNode *q_node;
+ // LmMessageSubType type;
+ LmMessageHandler *handler = NULL;
+ GMainLoop *main_loop = NULL;
+
+ iLog->Log ( _L ( "In lm_fetching_presenceL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+
+ gboolean result = lm_connection_send ( connection, message, NULL );
+ // Close the connection
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve and update presence information
+ //
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)jabber_presence_handler_cb,
+ main_loop,
+ NULL );
+
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_HANDLER_PRIORITY_NORMAL );
+
+ //------------------------------------------------------------------------
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ // Remove a reference on message
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ lm_message_handler_unref(handler);
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_fetching_presenceL passed" ) );
+
+ return KErrNone;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_subscribe_contact_L
+// Description : fetching contact list
+// Arguements :
+// connection :
+// message :
+// error :
+// Returns :
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_subscribe_contact_L ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ //LmMessageNode *q_node;
+ //LmMessageSubType type;
+
+ iLog->Log ( _L ( "In lm_subscribe_contact_L" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // Open a connection with the server
+ GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection,
+ ( LmResultFunction ) connection_open_cb,
+ main_loop1, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop1 );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ GMainLoop *main_loop2 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop2,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop2 );
+ g_main_loop_unref ( main_loop2 );
+ g_free ( username );
+
+
+ gchar *jid = "rakesh.harsha@gmail.com";
+ message = lm_message_new (jid, LM_MESSAGE_TYPE_PRESENCE );
+ lm_message_node_set_attribute ( message->node, "type", "subscribe" );
+ //Send the message
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ // Remove a reference on message
+ lm_message_unref ( message );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_subscribe_contact_L passed" ) );
+ return KErrNone;
+ }
+
+
+
+ //-----------------------------------------------------------------------------
+// Ctstlm::lm_authenticate_WithUnexistingJID
+// Description : Tries to authenticate a user against the server.
+// Arguements :
+// connection : an LmConnection
+// username : Username used to authenticate
+// password : Password corresponding to Username
+// resource : Resource used for this connection
+// error : location to store error, or NULL
+// Returns : TRUE if no errors were detected & authentication was
+// successful,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_authenticate_WithUnexistingJID ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ //ConnectData *connect_data = NULL;
+ AuthData *auth_data = NULL;
+ //GMainLoop *main_loop = NULL;
+ //GMainContext *context = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_authenticate" ) );
+
+ auth_data = g_new0 ( AuthData, 1 );
+ if ( !auth_data )
+ {
+ iLog->Log ( _L ( "memory allocation failed for auth_data" ) );
+ return KErrGeneral;
+ }
+
+ if ( read_data ( auth_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( auth_data->connect_data );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ auth_data->rCode = RC_ERROR;
+
+ //connection = lm_connection_new_with_context ( connect_data->server,context );
+ connection = lm_connection_new ( auth_data->connect_data->server );
+ if ( connection == NULL )
+ {
+ iLog->Log ( _L ( "lm_connection_new_with_context failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, auth_data->connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, auth_data->connect_data->proxy_data );
+#endif
+ SSLInit ( connection );
+
+ if ( !lm_connection_open ( connection,
+ ( LmResultFunction ) connection_open_cb,
+ auth_data->main_loop,
+ NULL,
+ NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( auth_data->main_loop );
+ g_main_loop_unref ( auth_data->main_loop );
+
+ // Extract the username from the JID
+ gchar *username = get_user_name ( auth_data->connect_data->username );
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ auth_data->connect_data->password,
+ auth_data->connect_data->resource,
+ ( LmResultFunction ) wrong_input_auth_cb,
+ auth_data ,
+ NULL,
+ NULL ) )
+ {
+ auth_data->rCode = RC_ERROR;
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ g_free ( username );
+ g_main_loop_unref ( auth_data->main_loop );
+ free_data ( auth_data->connect_data );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( auth_data->main_loop );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( username );
+
+
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+
+ if ( auth_data->rCode == RC_ERROR )
+ {
+ iLog->Log ( _L ( "lm_authenticate_WithUnexistingJID failed" ) );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_free ( auth_data );
+
+ iLog->Log ( _L ( "lm_authenticate_WithUnexistingJID passed" ) );
+
+ return KErrNone;
+}
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_authenticate_WithBadPasswordL
+// Description : Tries to authenticate a user against the server.
+// Arguements :
+// connection : an LmConnection
+// username : Username used to authenticate
+// password : Password corresponding to Username
+// resource : Resource used for this connection
+// error : location to store error, or NULL
+// Returns : TRUE if no errors were detected & authentication was
+// successful,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_authenticate_WithBadPasswordL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ //ConnectData *connect_data = NULL;
+ AuthData *auth_data = NULL;
+ //GMainLoop *main_loop = NULL;
+ //GMainContext *context = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_authenticate" ) );
+
+ auth_data = g_new0 ( AuthData, 1 );
+ if ( !auth_data )
+ {
+ iLog->Log ( _L ( "memory allocation failed for auth_data" ) );
+ return KErrGeneral;
+ }
+
+ if ( read_data ( auth_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( auth_data->connect_data );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ //context = g_main_context_new ();
+ //main_loop = g_main_loop_new ( context, FALSE );
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ //auth_data->connect_data = connect_data;
+ auth_data->rCode = RC_ERROR;
+ //auth_data->main_loop = main_loop;
+
+ //connection = lm_connection_new_with_context ( connect_data->server,context );
+ connection = lm_connection_new ( auth_data->connect_data->server );
+ if ( connection == NULL )
+ {
+ iLog->Log ( _L ( "lm_connection_new_with_context failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, auth_data->connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, auth_data->connect_data->proxy_data );
+#endif
+ SSLInit ( connection );
+
+ if ( !lm_connection_open ( connection,
+ ( LmResultFunction ) auth_from_open_cb,
+ auth_data,
+ NULL,
+ NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( auth_data->main_loop );
+ g_main_loop_unref ( auth_data->main_loop );
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+
+ if ( auth_data->rCode == RC_ERROR )
+ {
+ iLog->Log ( _L ( "lm_authenticate_WithBadPasswordL failed" ) );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_free ( auth_data );
+
+ iLog->Log ( _L ( "lm_authenticate_WithBadPasswordL passed" ) );
+
+ return KErrNone;
+}
+
+ //-----------------------------------------------------------------------------
+// Ctstlm::lm_authenticate_WhenConnectionIsNotOpenedL
+// Description : Tries to authenticate a user against the server.handles
+// a reply to the authentication in callback method
+// Arguments :
+// connection : an LmConnection
+// username : Username used to authenticate
+// password : Password corresponding to Username
+// resource : Resource used for this connection
+// error : location to store error, or NULL
+// Returns : TRUE if no errors were detected & authentication was
+// successful,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_authenticate_WhenConnectionIsNotOpenedL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+
+ iLog->Log ( _L ( "In lm_authenticate_WhenConnectionIsNotOpenedL" ) );
+
+ // Read data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( connection == NULL)
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ SSLInit ( connection );
+
+
+
+ // Get the username from the JID
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server without doing a connection open
+ if (! lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_open_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_authenticate_WhenConnectionIsNotOpened passed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ //returning kerrnone since we are testing negative scenario and this call is
+ //expected to return false
+ return KErrNone;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ iLog->Log ( _L ( "lm_authenticate_WhenConnectionIsNotOpened when connection is not opened failed since connection must be already open" ) );
+ //Returning KErrNone, since the test case could not be tested as the connection must be open
+ //The control will never come here for the test case :)
+ return KErrNone;
+ }
+
+
+ //-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_open_with_badserver server name
+// Description : Tries to authenticate a user against the wrong server.
+// Arguements :
+// connection : an LmConnection
+// username : Username used to authenticate
+// password : Password corresponding to Username
+// resource : Resource used for this connection
+// error : location to store error, or NULL
+// Returns : TRUE if no errors were detected & authentication was
+// successful,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_open_with_badserverL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ //ConnectData *connect_data = NULL;
+ AuthData *auth_data = NULL;
+ //GMainLoop *main_loop = NULL;
+ //GMainContext *context = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_open_with_badserverL" ) );
+
+ auth_data = g_new0 ( AuthData, 1 );
+ if ( !auth_data )
+ {
+ iLog->Log ( _L ( "memory allocation failed for auth_data" ) );
+ return KErrGeneral;
+ }
+
+ if ( read_data ( auth_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( auth_data->connect_data );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ //context = g_main_context_new ();
+ //main_loop = g_main_loop_new ( context, FALSE );
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ //auth_data->connect_data = connect_data;
+ auth_data->rCode = RC_ERROR;
+ //auth_data->main_loop = main_loop;
+
+ //connection = lm_connection_new_with_context ( connect_data->server,context );
+ connection = lm_connection_new ( auth_data->connect_data->server );
+ if ( connection == NULL )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection, auth_data->connect_data->username );
+
+#ifdef __WINSCW__
+ SetProxy ( connection, auth_data->connect_data->proxy_data );
+#endif
+ SSLInit ( connection );
+
+ if ( !lm_connection_open ( connection,
+ ( LmResultFunction ) wrong_input_in_open_cb,
+ auth_data,
+ NULL,
+ NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ) );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( auth_data->main_loop );
+ iLog->Log ( _L ( "main loop exited returned" ) );
+ g_main_loop_unref ( auth_data->main_loop );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+
+ if ( auth_data->rCode == RC_ERROR )
+ {
+ iLog->Log ( _L ( "lm_connection_open_with_badserver failed" ) );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_free ( auth_data );
+
+ iLog->Log ( _L ( "lm_connection_open_with_badserver passed" ) );
+
+ return KErrNone;
+}
+
+
+// ----------------------------------------------------------------------------
+// Ctstlm::lm_message_node_get_child
+// Description:Fetches the child from node. If child is not found as an
+// immediate child of node, NULL is returned
+// Arguements :
+// node : an LmMessageNode
+// name : name of the new child
+// value : value of the new child
+// Returns : the child node or NULL if child not found
+// ----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_message_node_get_childL ( CStifItemParser& /*aItem*/ )
+{
+ LmMessage *message = NULL;
+ LmMessageNode *Node = NULL;
+ const gchar *Username = "Nokia";
+ const gchar *Password = "Nokia";
+
+ iLog->Log ( _L ( "In lm_message_node_get_child" ) );
+
+ // Construct a message with type = LM_MESSAGE_TYPE_MESSAGE
+ iLog->Log ( _L ( "Construct a message" ) );
+
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ if ( !message )
+ {
+ iLog->Log ( _L ( "lm_message_new failed" ) );
+ return KErrGeneral;
+ }
+
+ // Retrive the root node from message
+ iLog->Log ( _L ( "Retrive the root node from the message" ) );
+
+ Node = lm_message_get_node ( message );
+ if ( !Node )
+ {
+ iLog->Log ( _L ( "lm_message_get_node failed" ) );
+ lm_message_unref ( message );
+ return KErrGeneral;
+ }
+
+ // Add childrens
+ iLog->Log ( _L ( "Adding childrens 'username' and 'password'" ) );
+ lm_message_node_add_child ( Node, "username", Username );
+ lm_message_node_add_child ( Node, "password", Password );
+
+ // Verify the childs
+ iLog->Log ( _L ( "Verify the childs" ) );
+
+ if ( !lm_message_node_get_child ( Node, "username" ) )
+ {
+ iLog->Log ( _L ( "lm_message_get_child failed" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ if ( !lm_message_node_get_child ( Node, "password" ) )
+ {
+ iLog->Log ( _L ( "lm_message_get_child failed" ) );
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+ return KErrGeneral;
+ }
+
+ lm_message_unref ( message );
+ lm_message_node_unref ( Node );
+
+ iLog->Log ( _L ( "lm_message_node_get_child passed" ) );
+
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_receive_messages
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_receive_messages ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* /*message*/,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+
+
+//-----------------------------------------------------------------------------
+// function_name : connection_auth_cb
+// description : callback function set by lm_connection_authenticate
+// in lm_connection_sendL()
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void lm_login_cb ( LmConnection * /*connection*/,
+ gboolean success,
+ gpointer data )
+ {
+ gboolean result = success;
+ AuthData *auth_data = ( AuthData * ) data;
+ //Result is false when the wrong input parameters were successfully handled.
+ if (result == FALSE)
+ {
+ auth_data->rCode = RC_OK;
+ }
+ else
+ {
+ //Result is true, when the wrong input was not handled successfully.
+ auth_data->rCode = RC_ERROR;
+ }
+ g_main_loop_quit ( auth_data->main_loop );
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_login_testL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_login_testL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ //ConnectData *connect_data = NULL;
+ AuthData *auth_data = NULL;
+
+
+ iLog->Log ( _L ( "In lm_login_testL" ) );
+
+ auth_data = g_new0 ( AuthData, 1 );
+ if ( !auth_data )
+ {
+ iLog->Log ( _L ( "memory allocation failed for auth_data" ) );
+ return KErrGeneral;
+ }
+
+ // Read a data from the CFG file
+ if ( read_data ( auth_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( auth_data->connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( auth_data->connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( auth_data->connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, auth_data->connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, auth_data->connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ auth_data->main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( auth_data->main_loop );
+ free_data ( auth_data->connect_data );
+
+ g_free(auth_data);
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( auth_data->main_loop );
+
+ g_main_loop_unref ( auth_data->main_loop );
+
+
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( auth_data->connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ auth_data->connect_data->password,
+ auth_data->connect_data->resource,
+ ( LmResultFunction ) lm_login_cb,
+ auth_data,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( username );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( auth_data->main_loop );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( username );
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+
+ if ( auth_data->rCode == RC_ERROR )
+ {
+ iLog->Log ( _L ( "lm_login_testL failed" ) );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+ g_free ( auth_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_login_testL passed" ) );
+
+ return KErrNone;
+}
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send400charL
+// Description : Asynchronous call to send a message of 400 characters
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send400charL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+
+ iLog->Log ( _L ( "In lm_connection_send" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+
+ gchar* msg = {"sdfsadFsdfsadfsdfsdjfksdjfl;jdsf;jsadfl;jsdvdfggdfg: \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer \
+ fjsdljfsldfjsfwerpwerpweripwierweirpiwepriwperiwperipwer"};
+
+ lm_message_node_add_child ( message->node, "body",
+ msg );
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ // Remove a reference on message
+ lm_message_unref ( message );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+ return KErrNone;
+
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send_repeatedL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send_repeatedL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+
+ iLog->Log ( _L ( "In lm_connection_send_repeatedL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_repeatedL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_repeatedL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_repeatedL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_repeatedL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+ return KErrNone;
+}
+//--------------------------------------------------------------------------------
+// function_name : handle_add_contact
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_add_contact ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_SET:
+ {
+ /*
+ <iq to='juliet@example.com/balcony' type='set' id='a78b4q6ha463'>
+ <query xmlns='jabber:iq:roster'>
+ <item jid='nurse@example.com'
+ name='Nurse'
+ subscription='none'>
+ <group>Servants</group>
+ </item>
+ </query>
+ </iq>
+ */
+ q_node = lm_message_node_get_child (reply->node, "query");
+ if (q_node)
+ {
+ item_node = lm_message_node_get_child (q_node, "item");
+ if(item_node)
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(item_node,"jid");
+ }
+
+ }
+
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*<iq from='prima@chat.gizmoproject.com/mytest12345rt'
+ to='prima@chat.gizmoproject.com/mytest12345rt'
+ id='164121175000' type='error'>
+ <query xmlns='jabber:iq:roster'>
+ <item jid='testlmnokia1111@chat.gizmoproject.com'/>
+ </query>
+ <error code='404' type='cancel'>
+ <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+ //return NULL;
+ LmMessageNode* error_node=NULL;
+ LmMessageNode* error_node_child=NULL;
+ error_node = lm_message_node_get_child (reply->node, "error");
+ if(error_node)
+ {
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ error_node_child = lm_message_node_get_child (error_node, "item-not-found");
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_add_contactL
+// Description : Asynchronous call to add a new contact
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_add_contactL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode *q_node,*item_node;
+ LmMessageHandler* handler = NULL;
+
+ iLog->Log ( _L ( "In lm_add_contactL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /***********fetch contact list********************/
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,"xmlns", "jabber:iq:roster",NULL);
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+ // Send message to the server
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /****send own presence********/
+
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ gboolean result = lm_connection_send ( connection, message, NULL );
+ lm_message_unref ( message );
+
+ /*********Send request to add a contact**********************/
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ item_node = lm_message_node_add_child ( q_node, "item", NULL );
+
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:roster" );
+ lm_message_node_set_attribute ( item_node, "jid", connect_data->msg_data->recipient );
+ //If we specify the name we cannot add the contact, maybe the name has to be unique.
+ /*lm_message_node_set_attribute ( item_node, "name", "harsh_rakesh" );
+ if ( group )
+ {
+ lm_message_node_add_child ( item, "group", group );
+ }*/
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_add_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ // Send subscription request to the server
+ message = lm_message_new_with_sub_type ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE );
+ result = lm_connection_send ( connection, message, NULL ) ;
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_add_contactL passed" ) );
+
+ return KErrNone;
+}
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_remove_contactL
+// Description : Asynchronous call to add a new contact
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_remove_contactL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode *q_node,*item_node;
+ LmMessageHandler* handler = NULL;
+ TBool result = EFalse;
+
+ iLog->Log ( _L ( "In lm_remove_contactL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /***********fetch contact list********************/
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,"xmlns", "jabber:iq:roster",NULL);
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+ // Send message to the server
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /*********Send request to ADD a contact**********************/
+ //If we specify the name we cannot add the contact, maybe the name has to be unique.
+ /*lm_message_node_set_attribute ( item_node, "name", "harsh_rakesh" );
+ if ( group )
+ {
+ lm_message_node_add_child ( item, "group", group );
+ }
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ item_node = lm_message_node_add_child ( q_node, "item", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:roster" );
+ lm_message_node_set_attribute ( item_node, "jid", connect_data->msg_data->recipient );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_add_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ // Send subscription request to the server
+ message = lm_message_new_with_sub_type ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE );
+ result = lm_connection_send ( connection, message, NULL ) ;
+ lm_message_unref ( message );
+
+ /*********Send request to REMOVE a contact**********************/
+ /*
+ <iq from='juliet@example.com/balcony' type='set' id='roster_4'>
+ <query xmlns='jabber:iq:roster'>
+ <item jid='nurse@example.com' subscription='remove'/>
+ </query>
+ </iq>
+ */
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ item_node = lm_message_node_add_child ( q_node, "item", NULL );
+
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:roster" );
+ lm_message_node_set_attribute ( item_node, "jid", connect_data->msg_data->recipient );
+ lm_message_node_set_attribute ( item_node, "subscription", "remove" );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_add_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_remove_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /***********FETCH contact list********************/
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,"xmlns", "jabber:iq:roster",NULL);
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+ // Send message to the server
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /*********Send request to ADD a contact**********************/
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ item_node = lm_message_node_add_child ( q_node, "item", NULL );
+
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:roster" );
+ lm_message_node_set_attribute ( item_node, "jid", connect_data->msg_data->recipient);
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_add_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ // Send subscription request to the server
+ message = lm_message_new_with_sub_type ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE );
+ result = lm_connection_send ( connection, message, NULL ) ;
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ /***********FETCH contact list********************/
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,"xmlns", "jabber:iq:roster",NULL);
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+ // Send message to the server
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /*********Send request to REMOVE a contact**********************/
+ /*
+ <iq from='juliet@example.com/balcony' type='set' id='roster_4'>
+ <query xmlns='jabber:iq:roster'>
+ <item jid='nurse@example.com' subscription='remove'/>
+ </query>
+ </iq>
+ */
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ item_node = lm_message_node_add_child ( q_node, "item", NULL );
+
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:roster" );
+ lm_message_node_set_attribute ( item_node, "jid", connect_data->msg_data->recipient );
+ lm_message_node_set_attribute ( item_node, "subscription", "remove" );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_add_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_remove_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /***********FETCH contact list********************/
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,"xmlns", "jabber:iq:roster",NULL);
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+ // Send message to the server
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ /*********Send request to ADD a contact**********************/
+ //If we specify the name we cannot add the contact, maybe the name has to be unique.
+ /*lm_message_node_set_attribute ( item_node, "name", "harsh_rakesh" );
+ if ( group )
+ {
+ lm_message_node_add_child ( item, "group", group );
+ }
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ item_node = lm_message_node_add_child ( q_node, "item", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:roster" );
+ lm_message_node_set_attribute ( item_node, "jid", connect_data->msg_data->recipient );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_add_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ // Send subscription request to the server
+ message = lm_message_new_with_sub_type ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE );
+ result = lm_connection_send ( connection, message, NULL ) ;
+ lm_message_unref ( message );
+
+ /***********cleanup*****************/
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_remove_contactL passed" ) );
+
+ return KErrNone;
+}
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send_receiveL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send and receive
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send_receiveL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessage *messagetoself = NULL;
+ LmMessageHandler *handler = NULL;
+ HandleData *handle_data = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_send" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ //------------------------------------------------------------------------
+ //Send own presence
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+
+ gboolean result = lm_connection_send ( connection, message, NULL );
+
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve msgs
+ //
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)handle_messages,
+ main_loop,
+ NULL );
+
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_FIRST );
+
+ // Construct a message for sending to self
+ messagetoself = lm_message_new ( connect_data->username,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, messagetoself, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( messagetoself );
+ lm_message_unref ( message );
+ g_main_loop_unref ( main_loop );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ // Wait for the message sent to self
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_handler_unref(handler);
+ // Remove a reference on message
+ lm_message_unref ( message );
+ lm_message_unref ( messagetoself );
+
+ //------------------------------------------------------------------------
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+ return KErrNone;
+}
+
+
+
+//-----------------------------------------------------------------------------
+// funnction_name : connection_open_cancel_cb
+// description : callback function called by lm_connection_open
+// Returns : None
+//-----------------------------------------------------------------------------
+//
+static void
+connection_open_cancel_cb ( LmConnection * /*connection*/,
+ gboolean success /*success*/,
+ gpointer data )
+ {
+
+ gboolean result = success ;
+ GMainLoop *main_loop = ( GMainLoop * ) data;
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_cancel_openL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_cancel_openL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_cancel_openL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cancel_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ if(!lm_connection_is_open(connection))
+ {
+ lm_connection_cancel_open(connection);
+ //lm_connection_unref(connection);
+ }
+
+ //g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_cancel_openL passed" ) );
+
+ return KErrNone;
+ }
+
+//--------------------------------------------------------------------------------
+// function_name : handle_get_privacy_lists
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_get_privacy_lists ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq type='result' id='getlist1' to='romeo@example.net/orchard'>
+ <query xmlns='jabber:iq:privacy'>
+ <active name='private'/>
+ <default name='public'/>
+ <list name='public'/>
+ <list name='private'/>
+ <list name='special'/>
+ </query>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* list_name1,*list_name2,*list_name3,*list_name4;
+ q_node = lm_message_node_get_child (reply->node, "query");
+ item_node = lm_message_node_get_child (q_node, "list");
+ list_name1 = lm_message_node_get_attribute(item_node,"name");
+
+ item_node = lm_message_node_get_child(q_node, "list");
+ list_name2 = lm_message_node_get_attribute(item_node,"name");
+
+ item_node = lm_message_node_get_child (q_node, "active");
+ if(item_node!=NULL)
+ list_name3 = lm_message_node_get_attribute(item_node,"name");
+
+ item_node = lm_message_node_get_child (q_node, "default");
+ if(item_node!=NULL)
+ list_name4 = lm_message_node_get_attribute(item_node,"name");
+
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*
+ <error type='cancel'>
+ <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+
+ </error>
+ OR
+ <error type='modify'>
+ <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ */
+ const char* error_type;
+ q_node = lm_message_node_get_child (reply->node, "query");
+ item_node = lm_message_node_get_child (q_node, "error");
+ error_type = lm_message_node_get_attribute(item_node,"type");
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+
+ if (!q_node)
+ {
+ //return NULL;
+ }
+
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_get_privacy_listsL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_get_privacy_listsL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_get_privacy_listsL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_get_privacy_listsL passed" ) );
+
+ return KErrNone;
+}
+
+
+//--------------------------------------------------------------------------------
+// function_name : handle_set_privacy_lists
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_set_privacy_lists ( LmMessageHandler*/* handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node = NULL;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq type='result' id='edit1' to='romeo@example.net/orchard'/>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*
+ <iq to='romeo@example.net/orchard' type='error' id='getlist6'>
+ <error type='modify'>
+ <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+ if (q_node)
+ {
+ LmMessageNode* error_node = NULL;
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ const char* error_type;
+ error_type = lm_message_node_get_attribute(error_node,"type");
+ item_node = lm_message_node_get_child (q_node, "feature-not-implemented");
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_privacy_listsL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_privacy_listsL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_privacy_listsL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='edit1'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'>
+ <item type='jid'
+ value='tybalt@example.com'
+ action='deny'
+ order='3'/>
+ <item type='jid'
+ value='paris@example.org'
+ action='deny'
+ order='5'/>
+ <item action='allow' order='68'/>
+ </list>
+ <list name='active'>
+ <item type='jid'
+ value='tybalt@example.com'
+ action='deny'
+ order='3'/>
+ <item type='jid'
+ value='paris@example.org'
+ action='deny'
+ order='5'/>
+ <item action='allow' order='68'/>
+ </list>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "deny" );
+ lm_message_node_set_attribute ( item_node2, "order", "3" );
+
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "active" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "deny" );
+ lm_message_node_set_attribute ( item_node2, "order", "4" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_set_privacy_listsL passed" ) );
+
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_send_image_cb
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_send_image_cb ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ SendStreamData *stream_data = ( SendStreamData * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*<message from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard'
+ id='msg1' type='error'>
+ ...
+ <error code='504' type='cancel'>
+ <remote-server-timeout xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </message>*/
+
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ q_node = lm_message_node_get_child (reply->node, "error");
+ if (q_node)
+ {
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(q_node,"code");
+ item_node = lm_message_node_get_child (q_node, "feature-not-implemented");
+ if(item_node==NULL)
+ {
+ item_node = lm_message_node_get_child (q_node, "remote-server-timeout");
+ }
+ }
+
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ if ( stream_data->main_loop )
+ {
+ g_main_loop_quit ( stream_data->main_loop );
+ }
+ lm_message_unref(stream_data->message);
+ lm_message_handler_unref(stream_data->handler);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//--------------------------------------------------------------------------------
+// function_name : handle_send_image_stream_msg_open_cb
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_send_image_stream_msg_open_cb ( LmMessageHandler* /*handler*/,
+ LmConnection* connection,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ SendStreamData *stream_data = ( SendStreamData * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node = NULL;
+ LmMessageNode *item_node1 = NULL;
+ LmMessageNode *item_node2 = NULL;
+ LmMessageNode* item_node = NULL;
+ LmMessage * message = NULL;
+ LmMessageHandler* handler = NULL;
+ type = lm_message_get_sub_type (reply);
+ /*
+ //success response
+ <iq type='result' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard'
+ id='inband_1'/>
+
+ //error response
+ <iq type='error' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard'
+ id='inband_1'/>
+ <error code='501' type='cancel'>
+ <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(q_node,"id");
+
+ /****************************************************/
+ // send bytes in message
+ /*
+ <message from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony' id='msg1'>
+ <data xmlns='http://jabber.org/protocol/ibb' sid='mySID' seq='0'>
+ qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
+ WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
+ IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
+ AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
+ kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
+ </data>
+ <amp xmlns='http://jabber.org/protocol/amp'>
+ <rule condition='deliver' value='stored' action='error'/>
+ <rule condition='match-resource' value='exact' action='error'/>
+ </amp>
+ </message>
+ */
+ message = lm_message_new ( NULL, LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_set_attribute ( message->node, "to", "donna.prima@gmail.com" );
+ q_node = lm_message_node_add_child ( message->node, "data",
+ "qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ \
+ WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu \
+ IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P \
+ AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH \
+ kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA" );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/ibb" );
+ lm_message_node_set_attribute ( q_node, "sid", "mySID" );
+ lm_message_node_set_attribute ( q_node, "seq", "0" );
+
+ q_node = lm_message_node_add_child ( message->node, "amp", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/amp" );
+ item_node1 = lm_message_node_add_child ( q_node, "rule", NULL );
+ lm_message_node_set_attribute ( item_node1, "condition", "deliver" );
+ lm_message_node_set_attribute ( item_node1, "value", "stored" );
+ lm_message_node_set_attribute ( item_node1, "action", "error" );
+ item_node2 = lm_message_node_add_child ( q_node, "rule", NULL );
+ lm_message_node_set_attribute ( item_node1, "condition", "match-resource" );
+ lm_message_node_set_attribute ( item_node1, "value", "exact" );
+ lm_message_node_set_attribute ( item_node1, "action", "error" );
+
+ stream_data->message = message;
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_send_image_cb, stream_data, NULL );
+
+ stream_data->handler = handler;
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ //lm_connection_close ( connection, NULL );
+ //lm_connection_unref ( connection );
+ lm_message_unref ( stream_data->message );
+ lm_message_handler_unref(stream_data->handler);
+ if ( stream_data->main_loop)
+ {
+ g_main_loop_quit ( stream_data->main_loop );
+ }
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ /****************************************************/
+ break;
+ }
+
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ q_node = lm_message_node_get_child (reply->node, "error");
+ if (q_node)
+ {
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(q_node,"code");
+ item_node = lm_message_node_get_child (q_node, "feature-not-implemented");
+ }
+ if ( stream_data->main_loop)
+ {
+ g_main_loop_quit ( stream_data->main_loop );
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send_image_bytestream_msgL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send_image_bytestream_msgL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+ SendStreamData* stream_data = NULL;
+ iLog->Log ( _L ( "In lm_connection_send_imageL" ) );
+
+ stream_data = g_new0 ( SendStreamData, 1 );
+ if (! stream_data )
+ {
+ return KErrGeneral;
+ }
+ if ( read_data ( stream_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( stream_data->connect_data );
+ g_free ( stream_data );
+ return KErrGeneral;
+ }
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ stream_data->rCode = RC_ERROR;
+
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( stream_data->connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( stream_data->connect_data );
+ g_free(stream_data);
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, stream_data->connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, stream_data->connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ stream_data->main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( stream_data->main_loop );
+ free_data ( stream_data->connect_data );
+ g_free(stream_data);
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( stream_data->main_loop );
+ g_main_loop_unref ( stream_data->main_loop );
+
+
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( stream_data->connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ stream_data->connect_data->password,
+ stream_data->connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ stream_data->main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( stream_data->connect_data );
+ g_main_loop_unref ( stream_data->main_loop );
+ g_free(stream_data);
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( stream_data->main_loop );
+ g_main_loop_unref ( stream_data->main_loop );
+ g_free ( username );
+
+ /**************************************/
+ //Opening a byte stream
+ /*
+ <iq type='set' from='romeo@montague.net/orchard'
+ to='juliet@capulet.com/balcony' id='inband_1'>
+ <open sid='mySID' block-size='4096' xmlns='http://jabber.org/protocol/ibb'/>
+ </iq>
+ */
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ lm_message_node_set_attribute ( message->node, "to", "donna.prima@gmail.com" );
+ q_node = lm_message_node_add_child ( message->node, "open", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/ibb" );
+ lm_message_node_set_attribute ( q_node, "sid", "mySID" );
+ lm_message_node_set_attribute ( q_node, "block-size", "4096" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_send_image_stream_msg_open_cb, stream_data, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( stream_data->connect_data );
+ g_main_loop_unref ( stream_data->main_loop );
+ g_free(stream_data);
+ return KErrGeneral;
+ }
+ g_main_loop_run ( stream_data->main_loop );
+ g_main_loop_unref ( stream_data->main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ /***************************************/
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send_imageL passed" ) );
+
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_send_image_iq_cb
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_send_image_iq_cb ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ SendStreamData* stream_data = ( SendStreamData * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*<iq from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='ibb1' type='error'>
+ ...
+ <error code='504' type='cancel'>
+ <remote-server-timeout xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ q_node = lm_message_node_get_child (reply->node, "error");
+ if (q_node)
+ {
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(q_node,"code");
+ item_node = lm_message_node_get_child (q_node, "feature-not-implemented");
+ if(item_node==NULL)
+ {
+ item_node = lm_message_node_get_child (q_node, "remote-server-timeout");
+ }
+ }
+
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ if ( stream_data->main_loop )
+ {
+ g_main_loop_quit ( stream_data->main_loop );
+ }
+ lm_message_unref(stream_data->message);
+ lm_message_handler_unref(stream_data->handler);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//--------------------------------------------------------------------------------
+// function_name : handle_send_image_stream_iq_open_cb
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_send_image_stream_iq_open_cb ( LmMessageHandler* /*handler*/,
+ LmConnection* connection,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ SendStreamData *stream_data = ( SendStreamData * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node = NULL;
+ LmMessageNode* item_node = NULL;
+ LmMessage * message = NULL;
+ LmMessageHandler* handler = NULL;
+ type = lm_message_get_sub_type (reply);
+ /*
+ //success response
+ <iq type='result' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard'
+ id='inband_1'/>
+
+ //error response
+ <iq type='error' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard'
+ id='inband_1'/>
+ <error code='501' type='cancel'>
+ <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(q_node,"id");
+
+ /****************************************************/
+ // send bytes in message
+ /*
+ <iq from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony' type='set' id='ibb1'>
+ <data xmlns='http://jabber.org/protocol/ibb' sid='mySID' seq='0'>
+ qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
+ WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
+ IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
+ AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
+ kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
+ </data>
+ </iq>
+ */
+ message = lm_message_new_with_sub_type( NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+ lm_message_node_set_attribute ( message->node, "to", "donna.prima@gmail.com" );
+ q_node = lm_message_node_add_child ( message->node, "data",
+ "qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ \
+ WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu \
+ IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P \
+ AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH \
+ kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA" );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/ibb" );
+ lm_message_node_set_attribute ( q_node, "sid", "mySID" );
+ lm_message_node_set_attribute ( q_node, "seq", "0" );
+ stream_data->message = message;
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_send_image_iq_cb, stream_data, NULL );
+ stream_data->handler = handler;
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ lm_message_unref ( stream_data->message );
+ lm_message_handler_unref(stream_data->handler);
+ if ( stream_data->main_loop)
+ {
+ g_main_loop_quit ( stream_data->main_loop );
+ }
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ /****************************************************/
+ break;
+ }
+
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ q_node = lm_message_node_get_child (reply->node, "error");
+ if (q_node)
+ {
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(q_node,"code");
+ item_node = lm_message_node_get_child (q_node, "feature-not-implemented");
+ }
+ if ( stream_data->main_loop)
+ {
+ g_main_loop_quit ( stream_data->main_loop );
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send_image_bytestream_iqL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send_image_bytestream_iqL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node= NULL;
+ LmMessageHandler *handler = NULL;
+ SendStreamData* stream_data = NULL;
+ iLog->Log ( _L ( "In lm_connection_send_imageL" ) );
+
+ stream_data = g_new0 ( SendStreamData, 1 );
+ if (! stream_data )
+ {
+ return KErrGeneral;
+ }
+ if ( read_data ( stream_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( stream_data->connect_data );
+ g_free ( stream_data );
+ return KErrGeneral;
+ }
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ stream_data->rCode = RC_ERROR;
+
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( stream_data->connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( stream_data->connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, stream_data->connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, stream_data->connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ stream_data->main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( stream_data->main_loop );
+ free_data ( stream_data->connect_data );
+ g_free(stream_data);
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( stream_data->main_loop );
+ g_main_loop_unref ( stream_data->main_loop );
+
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( stream_data->connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ stream_data->connect_data->password,
+ stream_data->connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ stream_data->main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( stream_data->connect_data );
+ g_main_loop_unref ( stream_data->main_loop );
+ g_free(stream_data);
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( stream_data->main_loop );
+ g_main_loop_unref ( stream_data->main_loop );
+ g_free ( username );
+ /**************************************/
+ //Opening a byte stream
+ /*
+ <iq type='set' from='romeo@montague.net/orchard'
+ to='juliet@capulet.com/balcony' id='inband_1'>
+ <open sid='mySID' block-size='4096' xmlns='http://jabber.org/protocol/ibb'/>
+ </iq>
+ */
+ stream_data->main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ lm_message_node_set_attribute ( message->node, "to", "donna.prima@gmail.com" );
+ q_node = lm_message_node_add_child ( message->node, "open", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/ibb" );
+ lm_message_node_set_attribute ( q_node, "sid", "mySID" );
+ lm_message_node_set_attribute ( q_node, "block-size", "4096" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_send_image_stream_iq_open_cb, stream_data, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( stream_data->connect_data );
+ g_free(stream_data);
+ g_main_loop_unref ( stream_data->main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( stream_data->main_loop );
+ g_main_loop_unref ( stream_data->main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ /****************************************************/
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( stream_data->connect_data );
+ g_free(stream_data);
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send_imageL passed" ) );
+
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_send_multiple_connL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_send_multiple_connL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection1 = NULL;
+ LmConnection *connection2 = NULL;
+ ConnectData *connect_data1 = NULL;
+ LmMessage *message;
+ iLog->Log ( _L ( "In lm_connection_send_multiple_connL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data1, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data1 );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection1 = lm_connection_new ( connect_data1->server );
+ connection2 = lm_connection_new ( connect_data1->server );
+
+
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection1 || !connection2 )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data1 );
+ //free_data ( connect_data2 );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port and Set the JID
+ lm_connection_set_port ( connection1, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection1, connect_data1->username );
+
+ // Set the gtalk's SSL port and Set the JID
+ lm_connection_set_port ( connection2, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection2, connect_data1->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection1, connect_data1->proxy_data );
+ SetProxy ( connection2, connect_data1->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection1 );
+ SSLInit ( connection2 );
+ /********************************************************/
+ //CONNECTION1
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection1, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection1 );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data1 );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data1->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection1,
+ username,
+ connect_data1->password,
+ connect_data1->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection1, NULL );
+ lm_connection_unref ( connection1 );
+ free_data ( connect_data1 );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /****************************************************/
+ //CONNECTION1 MSG
+ // Construct a message
+ message = lm_message_new ( connect_data1->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data1->msg_data->message);
+ // Send message to the server
+ if ( !lm_connection_send ( connection1, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection1, NULL );
+ lm_connection_unref ( connection1 );
+ lm_connection_unref ( connection2 );
+ lm_message_unref ( message );
+ free_data ( connect_data1 );
+ return KErrGeneral;
+ }
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ /***********************************************/
+ //CONNECTION2
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection2, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_close ( connection1, NULL );
+ lm_connection_unref ( connection1 );
+ lm_connection_unref ( connection2 );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data1 );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ username = get_user_name ( connect_data1->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection2,
+ username,
+ connect_data1->password,
+ /*connect_data2->resource*/
+ "RSC1234",
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection1, NULL );
+ lm_connection_unref ( connection1 );
+ lm_connection_close ( connection2, NULL );
+ lm_connection_unref ( connection2 );
+ free_data ( connect_data1 );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ /***********************************************/
+ // CONNECTION2 MSG
+ // Construct a message
+ message = lm_message_new ( connect_data1->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data1->msg_data->message);
+ // Send message to the server
+ if ( !lm_connection_send ( connection2, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection2, NULL );
+ lm_connection_unref ( connection2 );
+ lm_message_unref ( message );
+ free_data ( connect_data1);
+ return KErrGeneral;
+ }
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ /**********************************************/
+ // Close the connection
+ lm_connection_close ( connection1, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection1 );
+ free_data ( connect_data1 );
+
+ // Close the connection
+ lm_connection_close ( connection2, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection2 );
+
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send_multiple_connL passed" ) );
+
+ return KErrNone;
+}
+//--------------------------------------------------------------------------------
+// function_name : handle_block_contact
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_block_contact ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq type='result' id='edit1' to='romeo@example.net/orchard'/>
+ */
+ /*
+ <iq to='romeo@example.net/orchard' type='set' id='push1'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+
+ <iq to='romeo@example.net/home' type='set' id='push2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ break;
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ //return NULL;
+ break;
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+ // q_node = lm_message_node_get_child (reply->node, "query");
+
+ if (!q_node)
+ {
+ //return NULL;
+ }
+
+ //item_node = lm_message_node_get_child (q_node, "id");
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_block_contactL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_block_contactL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node = NULL;
+ LmMessageNode* item_node1 = NULL;
+ LmMessageNode* item_node2 = NULL;
+ LmMessageNode* item_node3 = NULL;
+
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_block_contactL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ /**********************************/
+ /*<iq>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='foo'>
+ <item
+ type='[jid|group|subscription]'
+ value='bar'
+ action='[allow|deny]'
+ order='unsignedInt'>
+ [<message/>]
+ [<presence-in/>]
+ [<presence-out/>]
+ [<iq/>]
+ </item>
+ </list>
+ </query>
+ </iq>*/
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "deny" );
+ lm_message_node_set_attribute ( item_node2, "order", "1" );
+ item_node3 = lm_message_node_add_child ( item_node2, "presence-in", NULL );
+ item_node3 = lm_message_node_add_child ( item_node2, "message", NULL );
+
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_block_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+ /**********************************/
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='get' id='getlist2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_get_one_privacy_listL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ /************************************/
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_block_contactL passed" ) );
+
+ return KErrNone;
+}
+//--------------------------------------------------------------------------------
+// function_name : handle_unblock_contact
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_unblock_contact ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node,*item_node;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq type='result' id='edit1' to='romeo@example.net/orchard'/>
+ */
+ /*
+ <iq to='romeo@example.net/orchard' type='set' id='push1'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+
+ <iq to='romeo@example.net/home' type='set' id='push2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ break;
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ //return NULL;
+ break;
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+ // q_node = lm_message_node_get_child (reply->node, "query");
+
+ if (!q_node)
+ {
+ //return NULL;
+ }
+
+ //item_node = lm_message_node_get_child (q_node, "id");
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_unblock_contactL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_unblock_contactL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node = NULL;
+ LmMessageNode* item_node1 = NULL;
+ LmMessageNode* item_node2 = NULL;
+ LmMessageNode* item_node3 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_unblock_contactL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /**********************************/
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ /*<iq>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='foo'>
+ <item
+ type='[jid|group|subscription]'
+ value='bar'
+ action='[allow|deny]'
+ order='unsignedInt'>
+ [<message/>]
+ [<presence-in/>]
+ [<presence-out/>]
+ [<iq/>]
+ </item>
+ </list>
+ </query>
+ </iq>*/
+
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "allow" );
+ lm_message_node_set_attribute ( item_node2, "order", "1" );
+ item_node3 = lm_message_node_add_child ( item_node2, "presence-in", NULL );
+ item_node3 = lm_message_node_add_child ( item_node2, "message", NULL );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_unblock_contact, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_connection_unblock_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ /**********************************/
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='get' id='getlist2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_get_one_privacy_listL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ /************************************/
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_unblock_contactL passed" ) );
+
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_set_active_list
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_set_active_list ( LmMessageHandler*/* handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *error_node = NULL;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq type='result' id='edit1' to='romeo@example.net/orchard'/>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* id;
+ id = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*<iq to='romeo@example.net/orchard' type='error' id='active2'>
+ <query xmlns='jabber:iq:privacy'>
+ <active name='The Empty Set'/>
+ </query>
+ <error code='404' type='cancel'>
+ <item-not-found
+ xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>*/
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_active_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_active_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_active_listL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='active1'>
+ <query xmlns='jabber:iq:privacy'>
+ <active name='special'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "active", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_active_list, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_set_active_listL passed" ) );
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_unexist_active_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_unexist_active_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_unexist_active_listL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='active1'>
+ <query xmlns='jabber:iq:privacy'>
+ <active name='special'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "active", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "publicunexist" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_active_list, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_set_unexist_active_listL passed" ) );
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_decline_active_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_decline_active_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_decline_active_listL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop);
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='active3'>
+ <query xmlns='jabber:iq:privacy'>
+ <active/>
+ </query>
+ </iq>
+
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "active", NULL );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_active_list, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_connection_set_decline_active_listL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_set_decline_active_listL passed" ) );
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_get_one_privacy_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_get_one_privacy_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_get_one_privacy_listL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='get' id='getlist2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_get_one_privacy_listL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_get_one_privacy_listL passed" ) );
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_one_privacy_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_one_privacy_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_one_privacy_listL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='edit1'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'>
+ <item type='jid'
+ value='tybalt@example.com'
+ action='deny'
+ order='3'/>
+ <item type='jid'
+ value='paris@example.org'
+ action='deny'
+ order='5'/>
+ <item action='allow' order='68'/>
+ </list>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "deny" );
+ lm_message_node_set_attribute ( item_node2, "order", "3" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_connection_set_one_privacy_listL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_set_one_privacy_listL passed" ) );
+
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_create_one_privacy_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_create_one_privacy_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_create_one_privacy_listL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='edit1'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'>
+ <item type='jid'
+ value='tybalt@example.com'
+ action='deny'
+ order='3'/>
+ <item type='jid'
+ value='paris@example.org'
+ action='deny'
+ order='5'/>
+ <item action='allow' order='68'/>
+ </list>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "publicnewlist" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "allow" );
+ lm_message_node_set_attribute ( item_node2, "order", "10" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_connection_create_one_privacy_listL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ /*****************************/
+ //Now retrieve all the privacy lists and see if it is created
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ /*******************************/
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_create_one_privacy_listL passed" ) );
+
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_get_many_privacy_lists
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_get_many_privacy_lists ( LmMessageHandler*/* handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *error_node = NULL;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+
+ /*<iq to='romeo@example.net/orchard' type='error/result' id='getlist6'> */
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* id;
+ id = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*
+ <iq to='romeo@example.net/orchard' type='error' id='getlist6'>
+ <error type='modify'>
+ <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ const char* error_type;
+ error_type = lm_message_node_get_attribute(error_node,"type");
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_get_many_privacy_list_from_listnameL
+// Description : Asynchronous call to get more than one privacy list details by
+// specifying the name. The server should return error, since we
+// can only retrieve info of one list at a time
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_get_many_privacy_list_from_listnameL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2, *item_node3 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_get_many_privacy_list_from_listname" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='get' id='getlist2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='public'/>
+ <list name='active'/>
+ <list name='default'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "public" );
+ item_node2 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node2, "name", "private" );
+ item_node3 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node3, "name", "default" );
+
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_many_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_get_many_privacy_list_from_listname failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_get_many_privacy_list_from_listname passed" ) );
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_get_one_unexist_privacy_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_get_one_unexist_privacy_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_get_one_unexist_privacy_list" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='get' id='getlist2'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='publicunexist'/>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node, "name", "publicunexist" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_get_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_get_one_unexist_privacy_list failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_get_one_unexist_privacy_list passed" ) );
+ return KErrNone;
+}
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_connection_set_one_unexist_privacy_listL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_connection_set_one_unexist_privacy_listL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode* q_node, *item_node1, *item_node2 = NULL;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "In lm_connection_set_one_unexist_privacy_list" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+// Construct a message with type=LM_MESSAGE_TYPE_IQ
+ /*
+ <iq from='romeo@example.net/orchard' type='set' id='edit1'>
+ <query xmlns='jabber:iq:privacy'>
+ <list name='publicunexist'>
+ <item type='jid'
+ value='tybalt@example.com'
+ action='deny'
+ order='3'/>
+ <item type='jid'
+ value='paris@example.org'
+ action='deny'
+ order='5'/>
+ <item action='allow' order='68'/>
+ </list>
+ </query>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "jabber:iq:privacy" );
+ item_node1 = lm_message_node_add_child ( q_node, "list", NULL );
+ lm_message_node_set_attribute ( item_node1, "name", "publicunexist" );
+ item_node2 = lm_message_node_add_child ( item_node1, "item", NULL );
+ lm_message_node_set_attribute ( item_node2, "type", "jid" );
+ lm_message_node_set_attribute ( item_node2, "value", "rakesh_harsh@chat.gizmoproject.com" );
+ lm_message_node_set_attribute ( item_node2, "action", "deny" );
+ lm_message_node_set_attribute ( item_node2, "order", "3" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_set_privacy_lists, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_set_one_unexist_privacy_list passed" ) );
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_service_discovery
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_service_discovery ( LmMessageHandler*/* handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node = NULL;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq from='capulet.com' to='juliet@capulet.com/chamber'
+ type='result' id='disco1'>
+ <query xmlns='http://jabber.org/protocol/disco#info'>
+ ...
+ <feature var='urn:xmpp:blocking'/>
+ ...
+ </query>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*
+ <iq to='romeo@example.net/orchard' type='error' id='getlist6'>
+ <error type='modify'>
+ <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+ if (reply->node)
+ {
+ LmMessageNode* error_node = NULL;
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ const char* error_type;
+ error_type = lm_message_node_get_attribute(error_node,"type");
+ item_node = lm_message_node_get_child (reply->node, "feature-not-implemented");
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_service_discoveryL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_service_discoveryL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode * q_node = NULL;
+ LmMessageHandler *handler = NULL;
+ iLog->Log ( _L ( "In lm_service_discoveryL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ /*
+ <iq from='juliet@capulet.com/chamber' to='capulet.com' type='get' id='disco1'>
+ <query xmlns='http://jabber.org/protocol/disco#info'/>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (connect_data->server,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/disco#info" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_service_discovery, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_service_discoveryL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_service_discoveryL passed" ) );
+
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_service_discovery_connected_resourceL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_service_discovery_connected_resourceL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode * q_node = NULL;
+ LmMessageHandler *handler = NULL;
+ iLog->Log ( _L ( "In lm_service_discovery_connected_resourceL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ /*
+ <iq from='juliet@capulet.com/chamber' to='capulet.com' type='get' id='disco1'>
+ <query xmlns='http://jabber.org/protocol/disco#info'/>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type ("testlmnokia@chat.gizmoproject.com/mytest12345rt17",
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "query", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "http://jabber.org/protocol/disco#info" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_service_discovery, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_add_contactL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_service_discovery_connected_resourceL passed" ) );
+
+ return KErrNone;
+}
+
+
+//--------------------------------------------------------------------------------
+// function_name : handle_simple_communications_blocking
+// description : callback function to handle messages
+// XEP-0191: Simple Communications Blocking
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_simple_communications_blocking ( LmMessageHandler*/* handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *q_node = NULL;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+ /*
+ <iq from='capulet.com' to='juliet@capulet.com/chamber'
+ type='result' id='disco1'>
+ <query xmlns='http://jabber.org/protocol/disco#info'>
+ ...
+ <feature var='urn:xmpp:blocking'/>
+ ...
+ </query>
+ </iq>
+ */
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /*
+ <iq to='romeo@example.net/orchard' type='error' id='getlist6'>
+ <error type='modify'>
+ <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </iq>
+ */
+ if (reply->node)
+ {
+ LmMessageNode* error_node = NULL;
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ const char* error_type;
+ error_type = lm_message_node_get_attribute(error_node,"type");
+ item_node = lm_message_node_get_child (error_node, "feature-not-implemented");
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_simple_communications_blockingL
+// Description : Asynchronous call to send a message
+// XEP-0191: Simple Communications Blocking
+// Not implemented by Gizmo
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_simple_communications_blockingL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode * q_node = NULL;
+ LmMessageHandler *handler = NULL;
+ iLog->Log ( _L ( "In lm_simple_communications_blockingL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ /*
+ <iq type='get' id='blocklist1'>
+ <blocklist xmlns='urn:xmpp:blocking'/>
+ </iq>
+ */
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET );
+ q_node = lm_message_node_add_child ( message->node, "blocklist", NULL );
+ lm_message_node_set_attribute ( q_node, "xmlns", "urn:xmpp:blocking" );
+
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_simple_communications_blocking, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply in lm_simple_communications_blockingL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_simple_communications_blockingL passed" ) );
+
+ return KErrNone;
+}
+//--------------------------------------------------------------------------------
+// function_name : handle_send_im
+// description : callback function to handle messages
+// XEP-0191: Simple Communications Blocking
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_send_im ( LmMessageHandler*/* handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ GMainLoop *main_loop = ( GMainLoop * )user_data;
+ LmMessageSubType type;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ /* //with gizmo
+ <message from='testlmnokia1111@chat.gizmoproject.com'
+ to='prima@chat.gizmoproject.com/mytest12345rt'
+ type='error' id='98332763125'>
+ <body>Hello</body>
+ <error code='503' type='cancel'>
+ <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ </error>
+ </message>
+ */
+ if (reply->node)
+ {
+ LmMessageNode* error_node = NULL;
+ const char* msg_error_type;
+ msg_error_type = lm_message_node_get_attribute(reply->node,"type");
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ const char* error_type;
+ error_type = lm_message_node_get_attribute(error_node,"type");
+ item_node = lm_message_node_get_child (error_node, "feature-not-implemented");
+ if(item_node == NULL)
+ {
+ item_node = lm_message_node_get_child (error_node, "service-unavailable");
+ }
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ if ( main_loop )
+ {
+ g_main_loop_quit ( main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_send_im_with_replyL
+// Description : Asynchronous call to send a message. Needs a response
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_send_im_with_replyL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageHandler *handler = NULL;
+ iLog->Log ( _L ( "In lm_send_im_with_replyL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ //------------------------------------------------------------------------
+ //Send own presence
+// message = lm_message_new_with_sub_type ( NULL,
+// LM_MESSAGE_TYPE_PRESENCE,
+// LM_MESSAGE_SUB_TYPE_AVAILABLE );
+
+ // gboolean result = lm_connection_send ( connection, message, NULL );
+ // lm_message_unref ( message );
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve msgs
+ //
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_send_im_with_replyL failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)handle_send_im,
+ main_loop,
+ NULL );
+
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_FIRST );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+ lm_message_handler_unref(handler);
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_send_im_with_replyL passed" ) );
+
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_receive_any_messageL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send and receive
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_receive_any_messageL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageHandler *handler = NULL;
+ HandleData *handle_data = NULL;
+
+ iLog->Log ( _L ( "In lm_receive_any_message" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ //------------------------------------------------------------------------
+ //Send own presence
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+
+ gboolean result = lm_connection_send ( connection, message, NULL );
+
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve msgs
+ //
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)handle_messages,
+ main_loop,
+ NULL );
+
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_FIRST );
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ //------------------------------------------------------------------------
+ lm_message_unref(message);
+ lm_message_handler_unref(handler);
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+ return KErrNone;
+}
+
+//--------------------------------------------------------------------------------
+// function_name : handle_multiple_session_messages
+// description : callback function to handle messages
+// Returns : LmHandlerResult
+//--------------------------------------------------------------------------------
+static LmHandlerResult
+handle_multiple_session_messages ( LmMessageHandler* /*handler*/,
+ LmConnection* /*connection*/,
+ LmMessage* reply,
+ gpointer user_data )
+ {
+ HandleData *handle_data = ( HandleData * )user_data;
+
+ if ( handle_data )
+ {
+ handle_data->Test_Success = RC_OK;
+ LmMessageSubType type;
+ LmMessageNode *q_node = NULL;
+ LmMessageNode *item_node = NULL;
+ type = lm_message_get_sub_type (reply);
+
+ switch (type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ {
+ const char* reply_string;
+ reply_string = lm_message_node_get_attribute(reply->node,"id");
+ break;
+ }
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ {
+ if (q_node)
+ {
+ LmMessageNode* error_node = NULL;
+ error_node = lm_message_node_get_child(reply->node,"error");
+ const char* error_code;
+ error_code = lm_message_node_get_attribute(error_node,"code");
+ const char* error_type;
+ error_type = lm_message_node_get_attribute(error_node,"type");
+ item_node = lm_message_node_get_child (q_node, "feature-not-implemented");
+ }
+ break;
+ }
+ // default:
+ // g_assert_not_reached ();
+ // break;
+ }
+
+
+ g_main_loop_quit ( handle_data->main_loop );
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_login_multiple_sessionsL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send and receive
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_login_multiple_sessionsL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection1 = NULL;
+ LmConnection *connection2 = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageHandler *handler1 = NULL;
+ LmMessageHandler *handler2 = NULL;
+ HandleData *handle_data = NULL;
+
+ iLog->Log ( _L ( "In lm_receive_any_message" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection1 = lm_connection_new ( connect_data->server );
+ connection2 = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection1 || !connection2 )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port and Set the JID
+ lm_connection_set_port ( connection1, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection1, connect_data->username );
+ lm_connection_set_port ( connection2, GTALK_SSL_PORT );
+ lm_connection_set_jid ( connection2, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection1, connect_data->proxy_data );
+ SetProxy ( connection2, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection1 );
+ SSLInit ( connection2 );
+ /*********************************************************/
+ //Login with connection1
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection1, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection1 );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection1,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection1, NULL );
+ lm_connection_unref ( connection1 );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ //Send own presence
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ gboolean result = lm_connection_send ( connection1, message, NULL );
+
+ //Dont unref message here. It will be used to send agn .
+ //lm_message_unref(message);
+
+
+ // Register a handler to recieve msgs
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ handler1 = lm_message_handler_new (
+ (LmHandleMessageFunction)handle_multiple_session_messages,
+ main_loop,
+ NULL );
+ lm_connection_register_message_handler ( connection1,
+ handler1,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_FIRST );
+ /*********************************************************/
+ //Login with CONNECTION2
+ GMainLoop* main_loop1 = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection2, ( LmResultFunction ) connection_open_cb,
+ main_loop1, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection2 );
+ g_main_loop_unref ( main_loop1 );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop1 );
+ g_main_loop_unref ( main_loop1 );
+ main_loop1 = g_main_loop_new ( NULL, FALSE );
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection2,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection2, NULL );
+ lm_connection_unref ( connection2 );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop1 );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ //Send own presence
+ result = lm_connection_send ( connection2, message, NULL );
+ lm_message_unref(message);
+ /*********************************************************/
+ // Conn2 should have logged out. Send message should not work.
+ // Construct a message
+// main_loop1 = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ // Send message to the server
+ handler2 = lm_message_handler_new ( handle_send_im, main_loop, NULL );
+ if ( !lm_connection_send_with_reply ( connection1, message, handler2, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_send_im_with_replyL failed" ) );
+ lm_connection_close ( connection1, NULL );
+ lm_connection_unref ( connection1 );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_unref(message);
+ lm_message_handler_unref(handler2);
+
+ /***********************************************************/
+ //Run the registered main loop for logout callbacks
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+ // Close the connection
+ lm_connection_close ( connection1, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection1 );
+
+ // Close the connection
+ lm_connection_close ( connection2, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection2 );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_change_own_presenceL
+// Description : Changing own presence information
+// Arguements :
+// connection :
+// message :
+// error :
+// Returns :
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_change_own_presenceL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode *show_node = NULL;
+ LmMessageNode *status_node = NULL;
+ LmMessageHandler *handler = NULL;
+ GMainLoop *main_loop = NULL;
+
+ iLog->Log ( _L ( "In lm_change_own_presenceL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /*
+ <presence xml:lang='en'>
+ <show>dnd</show>
+ <status>Wooing Juliet</status>
+ <status xml:lang='cz'>Ja dvořím Juliet</status>
+ </presence>
+ */
+
+ //publish own presence
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ gboolean result = lm_connection_send ( connection, message, NULL );
+ //lm_connection_send_with_reply(
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve and update presence information
+ //
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)jabber_presence_handler_cb,
+ main_loop,
+ NULL );
+
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_HANDLER_PRIORITY_NORMAL );
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_handler_unref(handler);
+ //------------------------------------------------------------------------
+
+
+
+ //Change presence again
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ lm_message_node_set_attributes ( message->node, "xml:lang", "en", NULL );
+ show_node = lm_message_node_add_child ( message->node, "show", "busy" );
+ status_node = lm_message_node_add_child ( message->node, "status", "goal goal goal" );
+ result = lm_connection_send ( connection, message, NULL );
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ //Change presence again
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ lm_message_node_set_attributes ( message->node, "xml:lang", "en", NULL );
+ show_node = lm_message_node_add_child ( message->node, "show", "away" );
+ status_node = lm_message_node_add_child ( message->node, "status", "imagine a world without nokia!" );
+ result = lm_connection_send ( connection, message, NULL );
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ //Change presence again
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ lm_message_node_set_attributes ( message->node, "xml:lang", "en", NULL );
+ show_node = lm_message_node_add_child ( message->node, "show", "available" );
+ status_node = lm_message_node_add_child ( message->node, "status", "there comes a time..." );
+ result = lm_connection_send ( connection, message, NULL );
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_fetching_presenceL passed" ) );
+
+ return KErrNone;
+ }
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_login_test_invalid_settingsL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_login_test_invalid_portL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+
+ iLog->Log ( _L ( "In lm_login_test_invalid_portL" ) );
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, SSL_INVALID_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop* main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ iLog->Log ( _L ( "lm_login_test_invalid_port: Invalid settings is handled correctly" ) );
+ return KErrNone;
+}
+
+//-----------------------------------------------------------------------------
+// Ctstlm:: lm_login_test_invalid_serverL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm:: lm_login_test_invalid_serverL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+
+
+ iLog->Log ( _L ( "In lm_login_test_invalid_serverL" ) );
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, SSL_INVALID_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop* main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ iLog->Log ( _L ( " lm_login_test_invalid_server: Invalid settings is handled correctly" ) );
+ return KErrNone;
+}
+
+
+//-----------------------------------------------------------------------------
+// Ctstlm::lm_memory_leak_testL
+// Description : Asynchronous call to send a message
+// Arguements :
+// connection : an LmConnection used to send message
+// message : LmMessage to send
+// error : location to store error, or NULL
+// Returns : Returns TRUE if no errors were detected while sending,
+// FALSE otherwise
+//-----------------------------------------------------------------------------
+//
+TInt Ctstlm::lm_memory_leak_testL ( CStifItemParser& aItem )
+ {
+ LmConnection *connection = NULL;
+ //ConnectData *connect_data = NULL;
+ AuthData *auth_data = NULL;
+
+
+ iLog->Log ( _L ( "In lm_memory_leak_testL" ) );
+
+ auth_data = g_new0 ( AuthData, 1 );
+ if ( !auth_data )
+ {
+ iLog->Log ( _L ( "memory allocation failed for auth_data" ) );
+ return KErrGeneral;
+ }
+
+ // Read a data from the CFG file
+ if ( read_data ( auth_data->connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( auth_data->connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( auth_data->connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( auth_data->connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, auth_data->connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, auth_data->connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ auth_data->main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( auth_data->main_loop );
+ free_data ( auth_data->connect_data );
+ g_free(auth_data);
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( auth_data->main_loop );
+
+ g_main_loop_unref ( auth_data->main_loop );
+
+
+ auth_data->main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( auth_data->connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ auth_data->connect_data->password,
+ auth_data->connect_data->resource,
+ ( LmResultFunction ) lm_login_cb,
+ auth_data,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( username );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( auth_data->main_loop );
+ g_main_loop_unref ( auth_data->main_loop );
+ g_free ( username );
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( auth_data->connect_data );
+
+ if ( auth_data->rCode == RC_ERROR )
+ {
+ iLog->Log ( _L ( "lm_memory_leak_testL failed" ) );
+ g_free ( auth_data );
+ return KErrGeneral;
+ }
+ g_free ( auth_data );
+
+
+
+ return KErrNone;
+}
+// NFT test cases
+
+TInt Ctstlm::lm_nft_updating_presenceL(CStifItemParser& aItem)
+ {
+
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode *show_node = NULL;
+ LmMessageNode *status_node = NULL;
+ LmMessageHandler *handler = NULL;
+ GMainLoop *main_loop = NULL;
+
+ iLog->Log ( _L ( "In lm_nft_updating_presenceL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /*
+ <presence xml:lang='en'>
+ <show>dnd</show>
+ <status>Wooing Juliet</status>
+ <status xml:lang='cz'>Ja dvořím Juliet</status>
+ </presence>
+ */
+
+ //publish own presence
+ //updating presence multiple time
+ for (TInt i =1 ;i<100 ;i++)
+ {
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ gboolean result = lm_connection_send ( connection, message, NULL );
+ //lm_connection_send_with_reply(
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ //Change presence again
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ lm_message_node_set_attributes ( message->node, "xml:lang", "en", NULL );
+ show_node = lm_message_node_add_child ( message->node, "show", "busy" );
+ status_node = lm_message_node_add_child ( message->node, "status", "goal goal goal" );
+ result = lm_connection_send ( connection, message, NULL );
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ }
+
+
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_updating_presenceL" ) );
+
+ return KErrNone;
+
+ }
+
+TInt Ctstlm ::lm_nft_presence_notificationL(CStifItemParser& aItem)
+ {
+
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageNode *show_node = NULL;
+ LmMessageNode *status_node = NULL;
+ LmMessageHandler *handler = NULL;
+ GMainLoop *main_loop = NULL;
+ HandleData *handle_data = NULL;
+
+ iLog->Log ( _L ( "lm_nft_presence_notificationL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+#ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+#endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ /*
+ <presence xml:lang='en'>
+ <show>dnd</show>
+ <status>Wooing Juliet</status>
+ <status xml:lang='cz'>Ja dvořím Juliet</status>
+ </presence>
+ */
+
+ //publish own presence
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+ gboolean result = lm_connection_send ( connection, message, NULL );
+ //lm_connection_send_with_reply(
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve and update presence information
+ //
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ handle_data = g_new0 ( HandleData, 1 );
+ handle_data->main_loop=main_loop;
+ handle_data->count=0;
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)handle_100_presence_notification,
+ handle_data,
+ NULL );
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_HANDLER_PRIORITY_NORMAL );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ lm_message_handler_unref(handler);
+
+
+
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_presence_notificationL" ) );
+
+ return KErrNone;
+
+
+ }
+
+ TInt Ctstlm::lm_nft_send_text_messageL(CStifItemParser& aItem)
+ {
+
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+
+ iLog->Log ( _L ( "In lm_nft_send_text_messageL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<100 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ //free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_send_text_messageL" ) );
+
+ return KErrNone;
+
+ }
+ TInt Ctstlm::lm_nft_open_conversation_with_multipleL(CStifItemParser& aItem)
+ {
+
+
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+
+ iLog->Log ( _L ( "lm_nft_open_conversation_with_multipleL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ // Construct a message
+ //receipient1
+ const char *receipient = "rakesh.harsh@gmail.com";
+ message = lm_message_new ( receipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient1 = "rakesh.harsha@gmail.com";
+ message = lm_message_new ( receipient1,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient2 = "testlm123@gmail.com";
+ message = lm_message_new ( receipient2,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+
+ const char *receipient3 = "nokiatestlm@gmail.com";
+ message = lm_message_new ( receipient3,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient4 = "testui123@gmail.com";
+ message = lm_message_new ( receipient4,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient5 = "immeco10@gmail.com";
+ message = lm_message_new ( receipient5,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient6 = "immeco11@gmail.com";
+ message = lm_message_new ( receipient6,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient7 = "immeco11@gmail.com";
+ message = lm_message_new ( receipient7,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient8 = "test.isoserver@gmail.com";
+ message = lm_message_new ( receipient8,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient9 = "tele1236@gmail.com";
+ message = lm_message_new ( receipient9,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ const char *receipient10 = "meco5555@gmail.com";
+ message = lm_message_new ( receipient10,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+ for(TInt i =0 ; i<20 ;i++)
+ {
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ }
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_open_conversation_with_multipleL" ) );
+
+ return KErrNone;
+
+ }
+ TInt Ctstlm::lm_nft_fetch300_contactL(CStifItemParser& aItem)
+ {
+
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+ LmMessageNode *q_node;
+ //LmMessageSubType type;
+ LmMessageHandler *handler = NULL;
+
+ iLog->Log ( _L ( "lm_nft_fetch300_contactL" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ //Open call
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction )connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+
+
+ // Construct a message
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ q_node = lm_message_node_add_child (message->node, "query", NULL);
+ lm_message_node_set_attributes (q_node,
+ "xmlns", "jabber:iq:roster",
+ NULL);
+ // Send message to the server
+ handler = lm_message_handler_new ( handle_fetch_contactlist_messages, main_loop, NULL );
+
+ if ( !lm_connection_send_with_reply ( connection, message, handler, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send_with_reply failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ return KErrGeneral;
+ }
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_fetch300_contactL" ) );
+
+ return KErrNone;
+
+ }
+
+ TInt Ctstlm::lm_nft_loginlogoutmultipletime(CStifItemParser& aItem)
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message;
+
+ iLog->Log ( _L ( "lm_nft_loginlogoutmultipletime" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+ //second time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ //*main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //*username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//third time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ // gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//fourth time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ // gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//five time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//fifth time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//sixth time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//seventh time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//eight time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//ninth time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_connection_send passed" ) );
+
+//tenth time
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ // *main_loop = g_main_loop_new ( NULL, FALSE );
+
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+
+ g_main_loop_run ( main_loop );
+
+ g_main_loop_unref ( main_loop );
+
+
+ // GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+
+ // Get the username from the JID
+ //gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop1,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop1 );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop1 );
+
+ g_main_loop_unref ( main_loop1 );
+
+
+ g_free ( username );
+
+ // Construct a message
+ message = lm_message_new ( connect_data->msg_data->recipient,
+ LM_MESSAGE_TYPE_MESSAGE );
+ lm_message_node_add_child ( message->node, "body",
+ connect_data->msg_data->message);
+
+ // Send message to the server
+ if ( !lm_connection_send ( connection, message, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_send failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ lm_message_unref ( message );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+
+ // Remove a reference on message
+ lm_message_unref ( message );
+
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_loginlogoutmultipletime" ) );
+
+
+ return KErrNone;
+}
+
+ TInt Ctstlm::lm_nft_receiving100_message_L(CStifItemParser& aItem)
+ {
+ LmConnection *connection = NULL;
+ ConnectData *connect_data = NULL;
+ LmMessage *message = NULL;
+ LmMessageHandler *handler = NULL;
+ HandleData *handle_data = NULL;
+
+ iLog->Log ( _L ( "lm_nft_receiving100_message_L" ) );
+
+ // Read a data from the CFG file
+ if ( read_data ( connect_data, aItem ) != RC_OK )
+ {
+ iLog->Log ( _L ( "read_data failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+ iLog->Log ( _L ( "after read_data" ) );
+
+ // Open a new closed connection
+ connection = lm_connection_new ( connect_data->server );
+ iLog->Log ( _L ( "after lm_connection_new " ) );
+ if ( !connection )
+ {
+ iLog->Log ( _L ( "lm_connection_new failed" ) );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ // Set the gtalk's SSL port
+ lm_connection_set_port ( connection, GTALK_SSL_PORT );
+
+ // Set the JID
+ lm_connection_set_jid ( connection, connect_data->username );
+
+ // Proxy settings for Emulator
+ #ifdef __WINSCW__
+ SetProxy ( connection, connect_data->proxy_data );
+ #endif
+
+ // Set the connection to use SSL
+ SSLInit ( connection );
+
+ GMainLoop *main_loop = g_main_loop_new ( NULL, FALSE );
+ iLog->Log ( _L ( "before lm_connection_open" ) );
+ if ( !lm_connection_open ( connection, ( LmResultFunction ) connection_open_cb,
+ main_loop, NULL, NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_open failed" ));
+ lm_connection_unref ( connection );
+ g_main_loop_unref ( main_loop );
+ free_data ( connect_data );
+ return KErrGeneral;
+ }
+
+ iLog->Log ( _L ( "after lm_connection_open" ) );
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+
+ main_loop = g_main_loop_new ( NULL, FALSE );
+ // Get the username from the JID
+ gchar *username = get_user_name ( connect_data->username );
+
+ // Authenticate with the server
+ if ( !lm_connection_authenticate ( connection,
+ username,
+ connect_data->password,
+ connect_data->resource,
+ ( LmResultFunction ) connection_auth_cb,
+ main_loop,NULL,NULL ) )
+ {
+ iLog->Log ( _L ( "lm_connection_authenticate failed" ) );
+ lm_connection_close ( connection, NULL );
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+ return KErrGeneral;
+ }
+
+ g_main_loop_run ( main_loop );
+ g_main_loop_unref ( main_loop );
+ g_free ( username );
+
+ //------------------------------------------------------------------------
+ //Send own presence
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_AVAILABLE );
+
+ gboolean result = lm_connection_send ( connection, message, NULL );
+ // GMainLoop *main_loop1;
+
+ //------------------------------------------------------------------------
+ //
+ // Register a handler to recieve msgs
+ //
+ handle_data = g_new0 ( HandleData, 1 );
+ GMainLoop *main_loop1 = g_main_loop_new ( NULL, FALSE );
+ handle_data->main_loop=main_loop1;
+ handle_data->count=0;
+ handler = lm_message_handler_new (
+ (LmHandleMessageFunction)handle_100_messages,
+ handle_data,
+ NULL );
+
+ lm_connection_register_message_handler ( connection,
+ handler,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_FIRST );
+
+ g_main_loop_run ( main_loop1 );
+ g_main_loop_unref ( main_loop1 );
+ //------------------------------------------------------------------------
+
+ lm_message_unref(message);
+ lm_message_handler_unref(handler);
+ // Close the connection
+ lm_connection_close ( connection, NULL );
+ // Remove a reference on connection
+ lm_connection_unref ( connection );
+ free_data ( connect_data );
+
+ // Message sending passed
+ iLog->Log ( _L ( "lm_nft_receiving100_message_L" ) );
+
+ return KErrNone;
+}
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: constant declaration class
+ *
+ *
+*/
+
+#include <platform_paths.hrh>
+
+
+#include "../messagequeue_api/group/bld.inf"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* ============================================================================
+* Name : msg_enums.h
+* Part of : message queue library
+* Version : %version: 2 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/msg_enums.h MW_LAYER_PLATFORM_EXPORT_PATH(msg_enums.h)
+../inc/msgliterals.h MW_LAYER_PLATFORM_EXPORT_PATH(msgliterals.h)
+../inc/msgqinternal.h MW_LAYER_PLATFORM_EXPORT_PATH(msgqinternal.h)
+../inc/msgqlib.h MW_LAYER_PLATFORM_EXPORT_PATH(msgqlib.h)
+
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/inc/msg_enums.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,225 @@
+/*
+* ============================================================================
+* Name : msg_enums.h
+* Part of : message queue library
+* Version : %version: 3 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+#ifndef __MSG_ENUMS_H__
+#define __MSG_ENUMS_H__
+
+#include <stdio.h>
+#include <gtypes.h>
+#define MAX_PARAM_LEN 1024
+
+
+/**
+* set of resuest ids from the clients
+*/
+//enum Request_Types Request_Types;
+enum Request_Types
+ {
+ // login
+ ELogin_Request = 1,
+ // logout
+ ELogout_Request,
+ EServer_DisConnect_Request,
+ //Fetch Contact : only used when there are no contacts
+ EFetch_Contacts_Error,
+ //to send a message
+ ESend_Request,
+ //For send error
+ ESend_Error,
+ //to fetch the presence
+ EPresence_Request,
+ // to add a list
+ EAdd_List_Request,
+ // to delete a list
+ EDelete_List_Request,
+ // to rename a list
+ ERename_List_Request,
+ // to add a contact
+ EAdd_Contact_Request,
+ // to delete a contact
+ EDelete_Contact_Request,
+ //accept a local pending request
+ EAccept_Contact_Request,
+ //Reject local pending request
+ EReject_Contact_Request,
+ // to rename a contact
+ ERename_Conatct_Request,
+ //to receive message
+ EText_Message_Receive,
+ //The order here should not be changed
+ //The logic in code is heavily dependant
+ //on the order of these three enums
+ // to fetch the contacts from server
+ ECurrent_Member_Contacts,
+ //local pending
+ ELocal_Pending_Contacts,
+ //remote pending
+ ERemote_Pending_Contacts,
+
+ //user is our client and contact is othr end
+ //user -> contact
+ //contact -> user
+
+ //Some other contact trying to add client
+ ETrying_To_Add_Contact,
+ //User added a contact
+ EKnown_Contact_Added,
+ //User added contact and it is remote pending
+ ESubscribe_Remote_Pending,
+ //Remote pending request rejected or user removed the contact from list
+ ESubscribe_Removed_Or_Rejected,
+ //Remote pending request accepted for subscribe of contact presence
+ //So now the user can know the presence of contact
+ ESubscribe_RP_Accepted,
+ //Remote pending request accepted for publish of users presence
+ //So now the contact can know the presence of user
+ EPublish_RP_Accepted,
+ //Removed from publish list
+ EPublish_Removed_Or_Rejected,
+ //
+ ETrying_To_Add_Contact_Known,
+ //
+ ETrying_To_Add_Contact_Publish,
+
+ //to update own presence
+ EUpdateOwnPresence,
+ //to update own avtar
+ EUpdateOwnAvtar,
+ //clear avatar
+ EClearOwnAvatar,
+ //presence notification
+ EPresenceNotification,
+
+ //Kill the process
+ EKill_Process,
+ //Search for contacts
+ ESearch,
+
+ //get the search keys
+ ESearch_Get_Keys,
+
+ //Search state changed
+ ESearch_State_During,
+
+ //Search state changed : Done
+ ESearch_State_Finished,
+
+ EUserEndGprs,
+
+ //Fetch the contacts
+ EFetchCachedContacts,
+
+ // add if required
+ } ;
+
+/**
+* message types send and recieve via queue
+*/
+enum Message_Types
+ {
+ EInteger,
+ EString,
+ EChar,
+ EEnums
+ // add here if need
+ };
+/**
+* Message header for request
+*/
+typedef struct message_hdr_req message_hdr_req;
+
+struct message_hdr_req
+ {
+ gint message_type; //Type of the message
+ gchar continue_flag;
+ gint protocol_id;//from TRequestId
+ gint session_id;//from TRequestId
+ gint request_id;//from TRequestId
+ };
+
+/**
+* Message header for response
+*/
+typedef struct message_hdr_resp message_hdr_resp;
+
+struct message_hdr_resp
+ {
+ //Warning : !!!!!!!!!!!!!! The order should not be changed
+ message_hdr_req hdr_req;
+ gchar continue_flag;
+ gint response; //success or not
+ gint error_type; //if not, error type
+ };
+
+
+/**
+* operations state enums variables
+*/
+
+enum Login_State
+ {
+ // default request error
+ EGeneral_Err = -1,
+ // connected to server successfully
+ EConnected,
+ // connecting to server in progress
+ EConnecting,
+ // not connected to server or logged off
+ ENotConnected
+
+ // add if required
+ };
+
+/**
+* error codes..
+*/
+enum error_codes
+ {
+ INVALID_PARAMETERES = -7000,
+ DBUS_CONNECTION_ERROR,
+ TP_CONNMGR_ERROR,
+ TP_CONNECTION_ERROR,
+ TP_HASHTABLE_ERROR,
+ MEM_ALLOCATION_ERROR,
+ NOT_CONNECTED,
+ CONNECTION_STATUS_ERROR,
+ MSG_Q_SEND_FAILED,
+ TP_SEARCH_CHAN_ERROR,
+ TP_SEARCH_IFACE_ERROR,
+ TP_AVATAR_IFACE_ERROR,
+
+ ELOGIN_AUTHENTICATION, //CASE 3 FRM SPEC
+ ELOGIN_NONE_SPECIFIED,//CAN BE USER CANCELLING THE A/P ETC., CASE 0 FRM SPEC
+ ELOGIN_NETWORK_ERROR, //For the network errors
+ ELOGIN_AUTHORIZATION, //ALL SSL RELATED ERRORS OTHR CASES
+ };
+
+#endif //__MSG_ENUMS_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/inc/msgliterals.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,73 @@
+/*
+* ============================================================================
+* Name : isoliterals.h
+* Part of : isolation server.
+* Version : %version: 1 %
+*
+* Copyright © 2007-2008 Nokia. All rights reserved.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+* ============================================================================
+* Template version: 1.0
+*/
+
+
+#ifndef __MSGLITERALS_H__
+#define __MSGLITERALS_H__
+
+#include <msgqlib.h>
+
+#define REQUEST_QUEUE 1
+
+#define RESPONSE_QUEUE 2
+
+#define RESPONSE_DATA_QUEUE 3
+
+#define MAX_SIZE_DATA 1024
+
+#define MAX_MSG_Q_SIZE 10
+
+#define MAX_MSG_RECEIPIENTS ( 10 + 1 )
+#define MAX_MSG_SIZE 1024
+
+#define PORTSRV 443
+
+
+#define TIME_OUT 500
+
+#define ServerAddr "talk.google.com"
+#define TestId "mytest"
+#define ServerStr "server"
+#define ResourceStr "resource"
+#define AccountStr "account"
+#define PasswdStr "password"
+#define PortStr "port"
+#define OldsslStr "old-ssl"
+
+#define NewChannelStr "NewChannel"
+#define StatusChangedStr "StatusChanged"
+
+/**
+ * Macro for isoserver implementation to suppress warnings
+ * from unused formal parameters.
+ */
+#define UNUSED_FORMAL_PARAM(p) (void) p
+
+#endif //__MSGLITERALS_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/inc/msgqinternal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,69 @@
+/**
+ * @file MsgQInternal.h
+ * Description: Internal Header file for MsgQLib
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef MSGQINTERNAL_H
+#define MSGQINTERNAL_H
+
+#include <msgqlib.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* data strucure used for maintaining message queues */
+
+typedef struct MsgQInfo* MSGQ_INFO_PTR;
+
+typedef struct MsgQInfo {
+ MSGQ_INFO_PTR next; /* next entry in list */
+ ULONG qName; /* queue name */
+ int qId; /* queue id */
+ int semId ; /* semaphore id */
+ ULONG sendState; /* message can be sent */
+ ULONG numMsgs; /* number of messages queued */
+ ULONG maxNumMsgs; /* maximum number of messages queued */
+ struct msqid_ds* slMqInfo_p; /* msg q info */
+}MSGQ_INFO;
+
+
+/* Linked List used for maintaining list of all message queues created */
+
+typedef struct MsgQInfoList* MSGQ_INFO_LIST_PTR;
+
+typedef struct MsgQInfoList {
+ MSGQ_INFO_LIST_PTR next; /* next entry in list */
+ ULONG qName; /* queue name */
+} MSGQ_INFO_LIST;
+
+/* Forward Declaration of Internal Functions */
+int InstallMsqQTable(ULONG qName, int qId, int semId, int* err);
+void AddToMsgQTable(ULONG qName);
+int RemoveFromMsqQTable(ULONG qName, int* err);
+void DeleteFromMsgQTable(ULONG qName);
+MSGQ_INFO* MsgQTableLookup(ULONG qName);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* MSGQINTERNAL_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/inc/msgqlib.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,168 @@
+/**
+ * @file MsgQLib.h
+ * Description: Header file for MsgQLib
+ * Copyright (c) 2007 Nokia Corporation.
+* All rights reserved.
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice, this list
+* of conditions and the following disclaimer.Redistributions in binary form must
+* reproduce the above copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of the Nokia Corporation nor the names of its contributors may be used
+* to endorse or promote products derived from this software without specific prior written
+* permission.
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+* SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __MSGQLIB_H__
+#define __MSGQLIB_H__
+
+#include <_ansi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* MsgQLib sizes */
+#define MAX_MSG_LEN 2048
+
+/* hash table parameters - table size must be a prime number */
+#define MSGQ_TBL_SZ 101
+
+/* message send states */
+#define MSG_Q_READY 0
+#define MSG_Q_CLEANING 1
+
+
+#define NO_WAIT 0
+#define WAIT_FOREVER 0xFFFF
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+/* errors */
+#define KMsgQLibErr 0x100
+#define KMsgQLibNoMemoryErr (KMsgQLibErr | 1) /* out of memory */
+#define KMsgQLibQIdErr (KMsgQLibErr | 2) /* queue already in use or invalid */
+#define KMsgQLibParamErr (KMsgQLibErr | 3) /* illegal parm(s)/val(s) */
+#define KMsgQLibQFlushErr (KMsgQLibErr | 4) /* queue being flushed */
+#define KMsgQLibQShortErr (KMsgQLibErr | 5) /* internal error: inconsistency between #of msgs*/
+
+#define MSG_Q_FIFO 1
+#define MSG_Q_PRIORITY 2
+#define MSG_PRI_NORMAL 3
+#define MSG_PRI_URGENT 4
+#define SEM_Q_FIFO 5
+#define SEM_Q_PRIORITY 6
+
+#define OK 0
+#define ERROR -1
+
+typedef unsigned long ULONG ;
+typedef unsigned short ushort_t;
+
+
+/**
+ *
+ * Creates a message queue with the argument passed
+ *
+ * @param qName - queue name
+ * @param maxMsgs - max messages in the queue
+ * @param qOptions - message queue options
+ * MSG_Q_FIFO
+ * MSG_Q_PRIORITY
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ */
+IMPORT_C int MsgQCreate (ULONG qName, ULONG maxMsgs, ULONG qOptions, int* err);
+
+/**
+ *
+ * This function deletes a message queue
+ *
+ * @param qName - queue name
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ **/
+IMPORT_C int MsgQDelete (ULONG qName, int* err);
+
+/**
+ *
+ * This function sends a message with internal copy
+ *
+ * @param qName - queue name
+ * @param msg - message to send
+ * @param nBytes - length of message
+ * @param priority - message priority
+ * @param timeout - milliseconds to wait
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ **/
+
+IMPORT_C int MsgQSend (ULONG qName, char* msg, ULONG nBytes, ULONG priority, int timeout, int* err);
+
+/**
+ *
+ * This function receives a message with internal copy
+ *
+ * @param qName - queue name
+ * @param msg - buffer for received message
+ * @param maxNBytes - length of buffer
+ * @param timeout - milliseconds to wait
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ **/
+
+IMPORT_C int MsgQReceive (ULONG qName, char* msg, ULONG maxNBytes, int timeout, int* err);
+
+/**
+ *
+ * This function checks how many messages are in a queue
+ *
+ * @param qName - queue name
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ **/
+IMPORT_C int MsgQCheck (ULONG qName, int* err);
+
+/**
+ * This function checks the maximum number of messages in a queue
+ *
+ * @param qName - queue name
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ **/
+IMPORT_C int MsgQMaxCheck (ULONG qName, int* err);
+
+/**
+ *
+ * This function empties the specified queue
+ *
+ * @param qName - queue name
+ * @param err - error code to be returned
+ *
+ * @return Returns status and error code
+ **/
+IMPORT_C int MsgQClean (ULONG qName, int* err);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __MSGQLIB_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/bmarm/messagequeue_apiu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/bwins/messagequeue_apiu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/conf/messagequeue_api.cfg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+[Test]
+title TestMessageQCreate
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMessageQCreate
+delete messagequeue_apiobj
+[Endtest]
+
+[Test]
+title TestMessageQSend
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMessageQSend
+delete messagequeue_apiobj
+[Endtest]
+
+[Test]
+title TestMessageQDelete
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMessageQDelete
+delete messagequeue_apiobj
+[Endtest]
+
+[Test]
+title TestMessageQReceive
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMessageQReceive
+delete messagequeue_apiobj
+[Endtest]
+
+[Test]
+title TestMessageQClean
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMessageQClean
+delete messagequeue_apiobj
+[Endtest]
+
+[Test]
+title TestMessageQCheck
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMessageQCheck
+delete messagequeue_apiobj
+[Endtest]
+
+[Test]
+title TestMsgQMaxCheck
+create messagequeue_api messagequeue_apiobj
+messagequeue_apiobj TestMsgQMaxCheck
+delete messagequeue_apiobj
+[Endtest]
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/eabi/messagequeue_apiu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+
+ DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in
+// Example:
+/*
+
+*/
+../init/TestFramework.ini /epoc32/winscw/c/TestFramework/TestFramework.ini
+../conf/messagequeue_api.cfg /epoc32/winscw/c/TestFramework/messagequeue_api.cfg
+
+
+
+PRJ_MMPFILES
+//messagequeue_api.mmp
+//messagequeue_api_nrm.mmp
+PRJ_TESTMMPFILES
+messagequeue_api.mmp
+
+
+
+
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/group/messagequeue_api.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,89 @@
+/*TYPE TESTCLASS*/
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MMP file for STIF Test Framework's TestScripter
+* testclass test module.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET messagequeue_api.dll
+TARGETTYPE dll
+UID 0x1000008D 0x101FB3E3
+
+CAPABILITY ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID 0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+// SECUREID 0x00000000
+
+//TARGETPATH ?target_path
+DEFFILE messagequeue_api.def
+
+USERINCLUDE ../inc
+
+
+
+SOURCEPATH ../src
+
+SOURCE messagequeue_api.cpp
+SOURCE messagequeue_apiBlocks.cpp
+
+//RESOURCE resource_file
+//RESOURCE resource_file2
+
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_BOOST_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+OS_LAYER_LIBUTILITY_SYSTEMINCLUDE
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+LIBRARY stiftestengine.lib
+LIBRARY libc.lib
+LIBRARY libglib.lib
+LIBRARY libm.lib
+LIBRARY OpenCMessageQueueLibrary.lib
+LIBRARY libdbus.lib
+
+LANG SC
+
+/*
+START WINS
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+
+// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH ?emulated_path_on_target_machine
+HEADER
+SOURCE ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/group/messagequeue_api.pkg Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,70 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\messagequeue_api.dll" - "!:\Sys\Bin\messagequeue_api.dll"
+
+;CFG FILES
+ "..\conf\messagequeue_api.cfg"-"C:\TestFramework\messagequeue_api.cfg"
+
+
+
+"..\init\TestFramework.ini"-"C:\TestFramework\TestFramework.ini"
+
+
+
+
+; Embedded SIS
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/group/messagequeue_api_DoxyFile.py Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,239 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Symbian Foundation License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+
+# Doxyfile 1.4.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = messagequeue_api
+PROJECT_NUMBER =
+OUTPUT_DIRECTORY = \messagequeue_api\
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = YES
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF =
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = YES
+OPTIMIZE_OUTPUT_JAVA = NO
+SUBGROUPING = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = NO
+EXTRACT_LOCAL_METHODS = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = YES
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = NO
+GENERATE_TESTLIST = NO
+GENERATE_BUGLIST = NO
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = YES
+FILE_VERSION_FILTER =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = \messagequeue_api\
+FILE_PATTERNS = *.h \
+ *.rh \
+ *.hrh
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = NO
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = YES
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = YES
+TOC_EXPAND = YES
+DISABLE_INDEX = YES
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = YES
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = YES
+RTF_OUTPUT = Doc
+COMPACT_RTF = YES
+RTF_HYPERLINKS = YES
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = YES
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED = NONSHARABLE_CLASS
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = YES
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/group/messagequeue_api_DoxyFile.txt Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,239 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Symbian Foundation License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+
+# Doxyfile 1.4.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = messagequeue_api
+PROJECT_NUMBER =
+OUTPUT_DIRECTORY = \messagequeue_api\
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = YES
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF =
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = YES
+OPTIMIZE_OUTPUT_JAVA = NO
+SUBGROUPING = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = NO
+EXTRACT_LOCAL_METHODS = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = YES
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = NO
+GENERATE_TESTLIST = NO
+GENERATE_BUGLIST = NO
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = YES
+FILE_VERSION_FILTER =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = \messagequeue_api\
+FILE_PATTERNS = *.h \
+ *.rh \
+ *.hrh
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = NO
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = YES
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = YES
+TOC_EXPAND = YES
+DISABLE_INDEX = YES
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = YES
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = YES
+RTF_OUTPUT = Doc
+COMPACT_RTF = YES
+RTF_HYPERLINKS = YES
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = YES
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED = NONSHARABLE_CLASS
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = YES
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/group/messagequeue_api_nrm.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,75 @@
+/*TYPE TESTCLASS*/
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MMP file for STIF Test Framework's TestScripter
+* testclass test module.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET messagequeue_api.dll
+TARGETTYPE dll
+UID 0x1000008D 0x101FB3E3
+
+CAPABILITY ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID 0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+// SECUREID 0x00000000
+
+//TARGETPATH ?target_path
+DEFFILE messagequeue_api.def
+
+USERINCLUDE ../inc
+
+OS_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH ../src
+
+SOURCE messagequeue_api.cpp
+SOURCE messagequeue_apiBlocks.cpp
+
+//RESOURCE resource_file
+//RESOURCE resource_file2
+
+LIBRARY euser.lib
+LIBRARY stiftestinterface.lib
+LIBRARY stiftestengine.lib
+
+LANG SC
+
+/*
+START WINS
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+
+// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH ?emulated_path_on_target_machine
+HEADER
+SOURCE ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/inc/messagequeue_api.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: STIF testclass declaration
+*
+*/
+
+#ifndef MESSAGEQUEUE_API_H
+#define MESSAGEQUEUE_API_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+// Logging path
+_LIT( Kmessagequeue_apiLogPath, "\\logs\\testframework\\messagequeue_api\\" );
+// Log file
+_LIT( Kmessagequeue_apiLogFile, "messagequeue_api.txt" );
+_LIT( Kmessagequeue_apiLogFileWithTitle, "messagequeue_api_[%S].txt" );
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class Cmessagequeue_api;
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// CLASS DECLARATION
+
+/**
+* Cmessagequeue_api test class for STIF Test Framework TestScripter.
+* ?other_description_lines
+*
+* @lib ?library
+* @since ?Series60_version
+*/
+NONSHARABLE_CLASS(Cmessagequeue_api) : public CScriptBase
+ {
+ public: // Constructors and destructor
+
+ /**
+ * Two-phased constructor.
+ */
+ static Cmessagequeue_api* NewL( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * Destructor.
+ */
+ virtual ~Cmessagequeue_api();
+
+ public: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ public: // Functions from base classes
+
+ /**
+ * From CScriptBase Runs a script line.
+ * @since ?Series60_version
+ * @param aItem Script line containing method name and parameters
+ * @return Symbian OS error code
+ */
+ virtual TInt RunMethodL( CStifItemParser& aItem );
+
+ protected: // New functions
+
+ /**
+ * ?member_description.
+ * @since ?Series60_version
+ * @param ?arg1 ?description
+ * @return ?description
+ */
+ //?type ?member_function( ?type ?arg1 );
+
+ protected: // Functions from base classes
+
+ /**
+ * From ?base_class ?member_description
+ */
+ //?type ?member_function();
+
+ private:
+
+ /**
+ * C++ default constructor.
+ */
+ Cmessagequeue_api( CTestModuleIf& aTestModuleIf );
+
+ /**
+ * By default Symbian 2nd phase constructor is private.
+ */
+ void ConstructL();
+
+ // Prohibit copy constructor if not deriving from CBase.
+ // ?classname( const ?classname& );
+ // Prohibit assigment operator if not deriving from CBase.
+ // ?classname& operator=( const ?classname& );
+
+ /**
+ * Frees all resources allocated from test methods.
+ * @since ?Series60_version
+ */
+ void Delete();
+
+ /**
+ * Test methods are listed below.
+ */
+
+ /**
+ * Example test method.
+ * @since ?Series60_version
+ * @param aItem Script line containing parameters.
+ * @return Symbian OS error code.
+ */
+ virtual TInt TestMessageQCreate( CStifItemParser& aItem );
+ virtual TInt TestMessageQSend( CStifItemParser& aItem );
+ virtual TInt TestMessageQDelete( CStifItemParser& aItem );
+ virtual TInt TestMessageQReceive(CStifItemParser& aItem );
+ virtual TInt TestMessageQClean(CStifItemParser& aItem );
+ virtual TInt TestMessageQCheck(CStifItemParser& aItem );
+ virtual TInt TestMsgQMaxCheck(CStifItemParser& aItem );
+
+
+ /**
+ * Method used to log version of test class
+ */
+ void SendTestClassVersion();
+
+ //ADD NEW METHOD DEC HERE
+ //[TestMethods] - Do not remove
+
+ public: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ protected: // Data
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ private: // Data
+
+ // ?one_line_short_description_of_data
+ //?data_declaration;
+
+ // Reserved pointer for future extension
+ //TAny* iReserved;
+
+ public: // Friend classes
+ //?friend_class_declaration;
+ protected: // Friend classes
+ //?friend_class_declaration;
+ private: // Friend classes
+ //?friend_class_declaration;
+
+ };
+
+#endif // MESSAGEQUEUE_API_H
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/init/TestFramework.ini Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,48 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Engine_Defaults]
+
+TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment',
+ 'TestCases' or 'FullReport'
+
+CreateTestReport= YES # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT # Possible values: TXT or HTML
+TestReportOutput= FILE # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\messagequeue_api.cfg
+[End_Module]
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= C:\testframework\isolationserver_manual.cfg
+[End_Module]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Logger_Defaults]
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/src/messagequeue_api.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,200 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file contains testclass implementation.
+*
+*/
+
+// INCLUDE FILES
+#include <StifTestInterface.h>
+#include "messagequeue_api.h"
+#include <SettingServerClient.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+// ?value_n: ?description_line1
+// ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+ ?arg_type arg, // ?description
+ ?arg_type arg) // ?description
+ {
+
+ ?code // ?comment
+
+ // ?comment
+ ?code
+ }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::Cmessagequeue_api
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Cmessagequeue_api::Cmessagequeue_api(
+ CTestModuleIf& aTestModuleIf ):
+ CScriptBase( aTestModuleIf )
+ {
+ User::After(1000000);
+ }
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Cmessagequeue_api::ConstructL()
+ {
+ //Read logger settings to check whether test case name is to be
+ //appended to log file name.
+ RSettingServer settingServer;
+ TInt ret = settingServer.Connect();
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Struct to StifLogger settigs.
+ TLoggerSettings loggerSettings;
+ // Parse StifLogger defaults from STIF initialization file.
+ ret = settingServer.GetLoggerSettings(loggerSettings);
+ if(ret != KErrNone)
+ {
+ User::Leave(ret);
+ }
+ // Close Setting server session
+ settingServer.Close();
+
+ TFileName logFileName;
+
+ if(loggerSettings.iAddTestCaseTitle)
+ {
+ TName title;
+ TestModuleIf().GetTestCaseTitleL(title);
+ logFileName.Format(Kmessagequeue_apiLogFileWithTitle, &title);
+ }
+ else
+ {
+ logFileName.Copy(Kmessagequeue_apiLogFile);
+ }
+
+ iLog = CStifLogger::NewL( Kmessagequeue_apiLogPath,
+ logFileName,
+ CStifLogger::ETxt,
+ CStifLogger::EFile,
+ EFalse );
+
+ SendTestClassVersion();
+ }
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Cmessagequeue_api* Cmessagequeue_api::NewL(
+ CTestModuleIf& aTestModuleIf )
+ {
+ Cmessagequeue_api* self = new (ELeave) Cmessagequeue_api( aTestModuleIf );
+
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+
+ return self;
+
+ }
+
+// Destructor
+Cmessagequeue_api::~Cmessagequeue_api()
+ {
+
+ // Delete resources allocated from test methods
+ Delete();
+
+ // Delete logger
+ delete iLog;
+
+ }
+
+//-----------------------------------------------------------------------------
+// Cmessagequeue_api::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void Cmessagequeue_api::SendTestClassVersion()
+ {
+ TVersion moduleVersion;
+ moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
+ moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
+ moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
+
+ TFileName moduleName;
+ moduleName = _L("messagequeue_api.dll");
+
+ TBool newVersionOfMethod = ETrue;
+ TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+ }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL(
+ CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+ {
+
+ return ( CScriptBase* ) Cmessagequeue_api::NewL( aTestModuleIf );
+
+ }
+
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/opensrv_plat/messagequeue_api/tsrc/src/messagequeue_apiBlocks.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,662 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file contains testclass implementation.
+*
+*/
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <StifTestInterface.h>
+#include <msgqlib.h>
+#include <msg_enums.h>
+#include <msgliterals.h>
+#include <stdlib.h>
+#include <msgqinternal.h>
+#include "messagequeue_api.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+// ?value_n: ?description_line1
+// ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+ ?arg_type arg, // ?description
+ ?arg_type arg) // ?description
+ {
+
+ ?code // ?comment
+
+ // ?comment
+ ?code
+ }
+*/
+ //-----------------------------------------------------------------------------
+// function_name : running isolation server exe
+// description : Deallocates all the data
+// Returns : None
+//-----------------------------------------------------------------------------
+ int run_isoserver()
+ {
+ // running isoserver
+ RProcess isosrv_launcher;
+ TInt lunch_err = 0;
+ _LIT(KProcess, "isoserver.exe");
+ lunch_err = isosrv_launcher.Create( KProcess, KNullDesC );
+ if ( KErrNone != lunch_err )
+ {
+ return KErrGeneral;
+
+ }
+ isosrv_launcher.Resume();
+ return KErrNone;
+ }
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::Delete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+//
+void Cmessagequeue_api::Delete()
+ {
+
+ }
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt Cmessagequeue_api::RunMethodL(
+ CStifItemParser& aItem )
+ {
+
+ static TStifFunctionInfo const KFunctions[] =
+ {
+ // Copy this line for every implemented function.
+ // First string is the function name used in TestScripter script file.
+ // Second is the actual implementation member function.
+ ENTRY( "TestMessageQCreate", Cmessagequeue_api::TestMessageQCreate ),
+ ENTRY( "TestMessageQSend", Cmessagequeue_api::TestMessageQSend ),
+ ENTRY( "TestMessageQDelete", Cmessagequeue_api::TestMessageQDelete ),
+ ENTRY( "TestMessageQReceive", Cmessagequeue_api::TestMessageQReceive ),
+ ENTRY( "TestMessageQClean", Cmessagequeue_api::TestMessageQClean ),
+ ENTRY( "TestMessageQCheck", Cmessagequeue_api::TestMessageQCheck ),
+ ENTRY( "TestMsgQMaxCheck", Cmessagequeue_api::TestMsgQMaxCheck ),
+ //ADD NEW ENTRY HERE
+ // [test cases entries] - Do not remove
+
+ };
+
+ const TInt count = sizeof( KFunctions ) /
+ sizeof( TStifFunctionInfo );
+
+ return RunInternalL( KFunctions, count, aItem );
+
+ }
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::ExampleL
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Cmessagequeue_api::TestMessageQCreate( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ return KErrNone;
+
+ }
+
+
+TInt Cmessagequeue_api::TestMessageQSend( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ return KErrNone;
+
+ }
+
+
+TInt Cmessagequeue_api::TestMessageQDelete( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ result=MsgQDelete( REQUEST_QUEUE, &err );
+ if(result)
+ {
+ iLog->Log ( _L ( "failing at message queue" ) );
+ return KErrGeneral;
+ }
+ return KErrNone;
+
+ }
+
+TInt Cmessagequeue_api::TestMessageQReceive( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for response request
+ result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err);
+
+ if (status < 0)
+ {
+ return KErrGeneral;
+
+ }
+
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ result=MsgQDelete( REQUEST_QUEUE, &err );
+ if(result)
+ {
+ iLog->Log ( _L ( "failing at message queue" ) );
+ return KErrGeneral;
+ }
+ return KErrNone;
+
+ }
+
+
+TInt Cmessagequeue_api::TestMessageQCheck( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0,r1=0 ,r2=0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ r1 = MsgQCheck(REQUEST_QUEUE,&err);
+
+ result = MsgQClean(REQUEST_QUEUE,&err);
+
+ r2 = MsgQCheck(REQUEST_QUEUE,&err);
+
+ if(r1==r2)
+ {
+ iLog->Log ( _L ( "message q clean is failed" ) );
+ return KErrGeneral;
+ }
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ result=MsgQDelete( REQUEST_QUEUE, &err );
+ if(result)
+ {
+ iLog->Log ( _L ( "failing at message queue" ) );
+ return KErrGeneral;
+ }
+ return KErrNone;
+
+}
+
+TInt Cmessagequeue_api::TestMessageQClean( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0,r1=0 ,r2=0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ r1 = MsgQCheck(REQUEST_QUEUE,&err);
+
+ r1 = MsgQMaxCheck(REQUEST_QUEUE,&err);
+
+ result = MsgQClean(REQUEST_QUEUE,&err);
+
+ r2 = MsgQCheck(REQUEST_QUEUE,&err);
+
+ if(r1==r2)
+ {
+ iLog->Log ( _L ( "message q clean is failed" ) );
+ return KErrGeneral;
+ }
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ result=MsgQDelete( REQUEST_QUEUE, &err );
+ if(result)
+ {
+ iLog->Log ( _L ( "failing at message queue" ) );
+ return KErrGeneral;
+ }
+ return KErrNone;
+
+}
+
+TInt Cmessagequeue_api::TestMsgQMaxCheck( CStifItemParser& aItem )
+ {
+ char smsg[MAX_MSG_SIZE];
+ char rmsg[MAX_MSG_SIZE];
+ int index=0;
+ int timeout = 100;
+ int nBytes;
+ int result = 0,r1=0 ,r2=0;
+ int err = 0;
+ int status = 0;
+ int run_iso;
+ FILE *fp;
+ message_hdr_req *msgHdr = NULL;
+ message_hdr_resp* msg_struct = NULL;
+ TInt return_value = 0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ //running isoserver
+ run_iso = run_isoserver();
+ if(run_iso)
+ {
+ iLog->Log ( _L ( "running isolation server is failed" ) );
+ return KErrGeneral;
+ }
+ //create message queue for send request
+ result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err);
+ if(err)
+ {
+ iLog->Log ( _L ( "creating requet queue is failed" ) );
+ return KErrGeneral;
+ }
+
+ //request formation
+ memset( smsg, '\0', MAX_MSG_SIZE );
+
+ //message header use
+ msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+
+ msgHdr->message_type = ELogin_Request;
+
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ /* Send Message to queueOne */
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+
+ r1 = MsgQCheck(REQUEST_QUEUE,&err);
+
+ r1 = MsgQMaxCheck(REQUEST_QUEUE,&err);
+
+ result = MsgQClean(REQUEST_QUEUE,&err);
+
+ r2 = MsgQCheck(REQUEST_QUEUE,&err);
+
+ if(r1==r2)
+ {
+ iLog->Log ( _L ( "message q clean is failed" ) );
+ return KErrGeneral;
+ }
+ index=0;
+ memset( smsg, '\0', MAX_MSG_SIZE );
+ memset( rmsg, '\0', MAX_MSG_SIZE );
+ memset( msgHdr, '\0', sizeof( message_hdr_req ) );
+ msgHdr->message_type = EKill_Process;
+ memcpy( smsg, msgHdr, sizeof( message_hdr_req ) );
+ index += sizeof( message_hdr_req );
+ result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err);
+ free(msgHdr);
+ result=MsgQDelete( REQUEST_QUEUE, &err );
+ if(result)
+ {
+ iLog->Log ( _L ( "failing at message queue" ) );
+ return KErrGeneral;
+ }
+ return KErrNone;
+
+}
+
+// -----------------------------------------------------------------------------
+// Cmessagequeue_api::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*
+TInt Cmessagequeue_api::?member_function(
+ CItemParser& aItem )
+ {
+
+ ?code
+
+ }
+*/
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// None
+
+// [End of File] - Do not remove
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+ <package id="opensrv" name="Open Services" levels="prt lib server eng">
+ <collection id="loudmouth" name="Loudmouth" level="prt">
+ <component id="loudmouth_build" filter="s60" name="Loudmouth Build" introduced="^2">
+ <unit bldFile="loudmouth/group"/>
+ </component>
+ <component id="loudmouth_test" filter="s60" name="Loudmouth Test" purpose="development" introduced="^2">
+ <!-- <unit bldFile="loudmouth/tsrc/group"/> -->
+ </component>
+ </collection>
+ <collection id="libtelepathy" name="Telepathy Library" level="lib">
+ <component id="libtelepathy_build" filter="s60" name="Telepathy Library Build" introduced="^2">
+ <unit bldFile="libtelepathy/group"/>
+ </component>
+ <component id="libtelepathy_test" filter="s60" name="Telepathy Library Test" purpose="development" introduced="^2">
+ <!-- <unit bldFile="libtelepathy/tsrc/group"/> -->
+ </component>
+ </collection>
+ <collection id="telepathygabble" name="Telepathy Gabble" level="eng">
+ <component id="telepathygabble_build" filter="s60" name="Telepathy Gabble Build" introduced="^2">
+ <unit bldFile="telepathygabble/group"/>
+ </component>
+ </collection>
+ <collection id="isolationserver" name="Isolation Server" level="server">
+ <component id="messagequeue" filter="s60" name="Message Queue" introduced="^2">
+ <unit bldFile="isolationserver/messagequeue/group"/>
+ </component>
+ <component id="isoserver" filter="s60" name="ISO Server" introduced="^2">
+ <unit bldFile="isolationserver/isoserver/group"/>
+ </component>
+ <component id="isolationserver_test" filter="s60" name="Isloation Server Test" purpose="development" introduced="^2">
+ <!-- <unit bldFile="isolationserver/tsrc/group"/> -->
+ </component>
+ <component id="isolationserver_build" filter="s60" name="Isloation Server Build" introduced="^2">
+ <unit bldFile="isolationserver/group"/>
+ </component>
+ </collection>
+ <collection id="opensrv_info" name="Open Services Info" level="eng">
+ <component id="opensrv_plat" filter="s60" name="Open Services Platform Interfaces" class="api" introduced="^2">
+ <unit bldFile="opensrv_plat/group"/>
+ <!-- <unit bldFile="opensrv_plat/messagequeue_api/tsrc/group"/> -->
+ </component>
+ </collection>
+ </package>
+</SystemDefinition>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+ name CDATA #REQUIRED
+ schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+ name CDATA #REQUIRED
+ levels CDATA #IMPLIED
+ span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+ name CDATA #REQUIRED
+ level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+ unitID ID #REQUIRED
+ name CDATA #REQUIRED
+ mrp CDATA #REQUIRED
+ filter CDATA #IMPLIED
+ bldFile CDATA #REQUIRED
+ priority CDATA #IMPLIED
+ contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+ name CDATA #REQUIRED
+ mrp CDATA #REQUIRED
+ filter CDATA #IMPLIED
+ contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+ name CDATA #REQUIRED
+ version CDATA #REQUIRED
+ late (Y|N) #IMPLIED
+ filter CDATA #IMPLIED
+ contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+ name ID #REQUIRED
+ description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+ name ID #REQUIRED
+ description CDATA #REQUIRED
+ target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+ name ID #REQUIRED
+ abldTarget CDATA #REQUIRED
+ description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+ name ID #REQUIRED
+ abldOption CDATA #REQUIRED
+ description CDATA #REQUIRED
+ enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+ name ID #REQUIRED
+ description CDATA #REQUIRED
+ filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+ command CDATA #REQUIRED
+ targetList IDREFS #IMPLIED
+ unitParallel (Y | N | y | n) #REQUIRED
+ targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+ name CDATA #REQUIRED
+ cwd CDATA #REQUIRED
+ command CDATA #REQUIRED>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/bwins/libgabble-convenienceU.DEF Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,27 @@
+EXPORTS
+ _gabble_connection_manager_register @ 1 NONAME
+ gabble_connection_get_type @ 2 NONAME
+ gabble_connection_manager_get_type @ 3 NONAME
+ gabble_debug_set_flags @ 4 NONAME
+ gabble_debug_set_flags_from_env @ 5 NONAME
+ gabble_disco_get_type @ 6 NONAME
+ gabble_im_channel_get_type @ 7 NONAME
+ gabble_im_factory_get_type @ 8 NONAME
+ gabble_media_channel_get_type @ 9 NONAME
+ gabble_media_factory_get_type @ 10 NONAME
+ gabble_media_session_get_type @ 11 NONAME
+ gabble_media_stream_get_type @ 12 NONAME
+ gabble_muc_channel_get_type @ 13 NONAME
+ gabble_muc_factory_get_type @ 14 NONAME
+ gabble_presence_cache_get_type @ 15 NONAME
+ gabble_presence_get_type @ 16 NONAME
+ gabble_register_get_type @ 17 NONAME
+ gabble_roomlist_channel_get_type @ 18 NONAME
+ gabble_roster_channel_get_type @ 19 NONAME
+ gabble_roster_get_type @ 20 NONAME
+ gabble_search_channel_get_type @ 21 NONAME
+ gabble_search_factory_get_type @ 22 NONAME
+ gabble_vcard_manager_get_type @ 23 NONAME
+ telepathy_errors_get_type @ 24 NONAME
+ telepathy_errors_quark @ 25 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/data/jabber.service Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.Telepathy.ConnectionManager.gabble
+Exec=\\epoc32\\RELEASE\\winscw\\udeb\\tg.exe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/data/jabber.service_hw Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.Telepathy.ConnectionManager.gabble
+Exec=z:\\sys\\bin\\tg.exe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/data/org.freedesktop.Telepathy.ConnectionManager.gabble.service Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.Telepathy.ConnectionManager.gabble
+Exec=telepathy-gabble
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/data/org.freedesktop.Telepathy.ConnectionManager.gabble.service.in Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.Telepathy.ConnectionManager.gabble
+Exec=@bindir@/telepathy-gabble
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/eabi/libgabble-convenienceu.def Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,27 @@
+EXPORTS
+ _gabble_connection_manager_register @ 1 NONAME
+ gabble_connection_get_type @ 2 NONAME
+ gabble_connection_manager_get_type @ 3 NONAME
+ gabble_debug_set_flags @ 4 NONAME
+ gabble_debug_set_flags_from_env @ 5 NONAME
+ gabble_disco_get_type @ 6 NONAME
+ gabble_im_channel_get_type @ 7 NONAME
+ gabble_im_factory_get_type @ 8 NONAME
+ gabble_media_channel_get_type @ 9 NONAME
+ gabble_media_factory_get_type @ 10 NONAME
+ gabble_media_session_get_type @ 11 NONAME
+ gabble_media_stream_get_type @ 12 NONAME
+ gabble_muc_channel_get_type @ 13 NONAME
+ gabble_muc_factory_get_type @ 14 NONAME
+ gabble_presence_cache_get_type @ 15 NONAME
+ gabble_presence_get_type @ 16 NONAME
+ gabble_register_get_type @ 17 NONAME
+ gabble_roomlist_channel_get_type @ 18 NONAME
+ gabble_roster_channel_get_type @ 19 NONAME
+ gabble_roster_get_type @ 20 NONAME
+ gabble_search_channel_get_type @ 21 NONAME
+ gabble_search_factory_get_type @ 22 NONAME
+ gabble_vcard_manager_get_type @ 23 NONAME
+ telepathy_errors_get_type @ 24 NONAME
+ telepathy_errors_quark @ 25 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/group/bld.inf Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * bld.inf
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ */
+// Project configuration file for dbus
+
+// Project platforms
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+#include <platform_paths.hrh>
+
+// Project exports
+PRJ_EXPORTS
+../rom/telepathygabble.iby CORE_MW_LAYER_IBY_EXPORT_PATH(telepathygabble.iby)
+../data/jabber.service /epoc32/winscw/c/data/dbus/dbus1/services/jabber.service
+../data/jabber.service_hw /epoc32/winscw/c/data/dbus/dbus1/services/jabber.service_hw
+
+
+// MMP files for project components
+PRJ_MMPFILES
+libgabble-convenience.mmp
+telepathy-gabble.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/group/libgabble-convenience.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,146 @@
+/*
+ * libgabble-convenience.mmp
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+// General properties
+#include<platform_paths.hrh>
+TARGET libgabble-convenience.dll
+TARGETTYPE DLL
+CAPABILITY CAP_GENERAL_DLL
+UID 0x1000008d 0x2000F852
+
+VERSION 10.0
+
+#ifndef WINSCW
+// Allow global writeable static data
+EPOCALLOWDLLDATA
+#endif
+
+// Macros
+MACRO SYMBIAN
+MACRO HAVE_CONFIG_H
+MACRO HAVE_ERRNO_H VERBOSE
+
+#ifdef WINSCW
+MACRO EMULATOR
+#endif
+
+
+SOURCEPATH ../src
+
+// User include paths
+USERINCLUDE ../inc
+USERINCLUDE ../../loudmouth/inc
+
+
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+// Source files
+SOURCEPATH ../src
+
+SOURCE gabble-connection-manager-signals-marshal.c
+SOURCE gabble-connection-signals-marshal.c
+SOURCE gabble-register-signals-marshal.c
+SOURCE gabble-im-channel-signals-marshal.c
+SOURCE gabble-muc-channel-signals-marshal.c
+SOURCE gabble-media-channel-signals-marshal.c
+SOURCE gabble-media-session-signals-marshal.c
+SOURCE gabble-media-session-enumtypes.c
+SOURCE gabble-media-stream-signals-marshal.c
+SOURCE gabble-presence-cache-signals-marshal.c
+SOURCE gabble-roster-channel-signals-marshal.c
+SOURCE gabble-roomlist-channel-signals-marshal.c
+SOURCE group-mixin-signals-marshal.c
+SOURCE properties-mixin-signals-marshal.c
+SOURCE telepathy-errors-enumtypes.c
+SOURCE text-mixin-signals-marshal.c
+
+SOURCE tp-channel-factory-iface-signals-marshal.c
+SOURCE capabilities.c
+SOURCE debug.c
+SOURCE disco.c
+SOURCE gabble-error.c
+SOURCE gabble-connection-manager.c
+SOURCE gabble-connection.c
+SOURCE gabble-im-channel.c
+SOURCE gabble-muc-channel.c
+SOURCE gabble-media-channel.c
+SOURCE gabble-media-session.c
+SOURCE gabble-media-stream.c
+SOURCE gabble-presence.c
+SOURCE gabble-presence-cache.c
+SOURCE gabble-register.c
+SOURCE gabble-roster-channel.c
+SOURCE gabble-roomlist-channel.c
+SOURCE gheap.c
+SOURCE gintset.c
+SOURCE group-mixin.c
+SOURCE handles.c
+SOURCE handle-set.c
+SOURCE jingle-info.c
+SOURCE im-factory.c
+SOURCE search-keys-info.c
+
+SOURCE search-factory.c
+SOURCE gabble-search-channel.c
+SOURCE search-mixin.c
+SOURCE search-mixin-signals-marshal.c
+
+SOURCE media-factory.c
+SOURCE muc-factory.c
+SOURCE properties-mixin.c
+SOURCE roster.c
+SOURCE telepathy-errors.c
+SOURCE telepathy-helpers.c
+SOURCE text-mixin.c
+SOURCE tp-channel-iface.c
+SOURCE tp-channel-factory-iface.c
+SOURCE util.c
+SOURCE vcard-manager.c
+SOURCE base64.c
+SOURCE sha1.c
+
+#ifdef WINSCW
+SOURCE libgabble_wsd.cpp
+#endif
+
+
+// Library dependencies
+#ifdef GCCE
+STATICLIBRARY libcrt0_gcce.lib
+#else
+STATICLIBRARY libcrt0.lib
+#endif
+LIBRARY libc.lib
+LIBRARY libglib.lib
+LIBRARY libgobject.lib
+LIBRARY libdbus.lib
+LIBRARY libdbus-glib.lib
+LIBRARY loudmouth.lib
+#ifdef WINSCW
+LIBRARY euser.lib // Needed in order to use Symbian services
+//wsd solution
+LIBRARY ewsd.lib
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/group/telepathy-gabble.mmp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,85 @@
+/*
+ * telepathy-gabble.mmp
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+
+ */
+// General properties
+#include<platform_paths.hrh>
+TARGET tg.exe
+TARGETTYPE exe
+CAPABILITY NetworkServices
+
+UID 0x1000008d 0x2000F853
+
+VERSION 10.0
+//EPOCHEAPSIZE 4096 4194304 // min. 4KB ja max 4MB
+#ifndef WINSCW
+EPOCHEAPSIZE 4194304 67108864 // min. 4MB ja max 64MB
+EPOCSTACKSIZE 61440
+#endif
+#ifndef WINSCW
+// Allow global writeable static data
+EPOCALLOWDLLDATA
+#endif
+
+// Macros
+MACRO SYMBIAN
+MACRO HAVE_CONFIG_H
+MACRO HAVE_ERRNO_H VERBOSE
+
+SOURCEPATH ../src
+
+// User include paths
+USERINCLUDE ../inc
+USERINCLUDE ../../loudmouth/inc
+
+// System include paths
+
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_GLIB_SYSTEMINCLUDE
+OS_LAYER_SSL_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+OS_LAYER_DBUS_SYSTEMINCLUDE
+
+
+
+
+// Source files
+SOURCEPATH ../src
+
+SOURCE gabble.c
+
+// Library dependencies
+#ifdef GCCE
+STATICLIBRARY libcrt0_gcce.lib
+#else
+STATICLIBRARY libcrt0.lib
+#endif
+LIBRARY libc.lib
+LIBRARY euser.lib // Needed in order to use Symbian services
+LIBRARY libglib.lib
+LIBRARY libgobject.lib
+LIBRARY libdbus.lib
+LIBRARY libgabble-convenience.lib
+LIBRARY libdbus-glib.lib
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/ansi.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,42 @@
+/*
+ * ansi.h - Header for GabbleConnection
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __ANSI_H__
+#define __ANSI_H__
+
+#define ANSI_RESET "\x1b[0m"
+#define ANSI_BOLD_ON "\x1b[1m"
+#define ANSI_INVERSE_ON "\x1b[7m"
+#define ANSI_BOLD_OFF "\x1b[22m"
+#define ANSI_FG_BLACK "\x1b[30m"
+#define ANSI_FG_RED "\x1b[31m"
+#define ANSI_FG_GREEN "\x1b[32m"
+#define ANSI_FG_YELLOW "\x1b[33m"
+#define ANSI_FG_BLUE "\x1b[34m"
+#define ANSI_FG_MAGENTA "\x1b[35m"
+#define ANSI_FG_CYAN "\x1b[36m"
+#define ANSI_FG_WHITE "\x1b[37m"
+#define ANSI_BG_RED "\x1b[41m"
+#define ANSI_BG_GREEN "\x1b[42m"
+#define ANSI_BG_YELLOW "\x1b[43m"
+#define ANSI_BG_BLUE "\x1b[44m"
+#define ANSI_BG_MAGENTA "\x1b[45m"
+#define ANSI_BG_CYAN "\x1b[46m"
+#define ANSI_BG_WHITE "\x1b[47m"
+
+#endif /* __ANSI_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/base64.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,28 @@
+/*
+ * base64.h - Base 64 encoding/decoding implementation
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __BASE64_H__
+#define __BASE64_H__
+
+#include <glib.h>
+
+gchar *base64_encode (guint len, const gchar *str);
+GString *base64_decode (const gchar *str);
+
+#endif /* __BASE64_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/capabilities.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,81 @@
+/*
+ * capabilities.h - Connection.Interface.Capabilities constants and utilities
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_CAPABILITIES__H__
+#define __GABBLE_CAPABILITIES__H__
+
+#include <glib-object.h>
+
+#include "gabble-presence.h"
+
+#define BUNDLE_VOICE_V1 "voice-v1"
+#define BUNDLE_JINGLE_AUDIO "jingle-audio"
+#define BUNDLE_JINGLE_VIDEO "jingle-video"
+
+typedef struct _Feature Feature;
+
+struct _Feature
+{
+ const gchar *bundle;
+ const gchar *ns;
+ GabblePresenceCapabilities caps;
+};
+
+/*
+ * capabilities_get_features
+ *
+ * Return a linked list of const Feature structs corresponding to the given
+ * GabblePresenceCapabilities.
+ */
+GSList *
+capabilities_get_features (GabblePresenceCapabilities caps);
+
+/*
+ * capabilities_fill_cache
+ *
+ * Fill up the given GabblePresenceCache with known feature nodes
+ */
+void
+capabilities_fill_cache (GabblePresenceCache *cache);
+
+/*
+ * capabilities_get_initial_caps
+ *
+ * Return the GabblePresenceCapabilities we always have
+ */
+GabblePresenceCapabilities
+capabilities_get_initial_caps ();
+
+typedef GabblePresenceCapabilities (*TypeFlagsToCapsFunc) (guint typeflags);
+typedef guint (*CapsToTypeFlagsFunc) (GabblePresenceCapabilities caps);
+
+typedef struct _CapabilityConversionData CapabilityConversionData;
+
+struct _CapabilityConversionData
+{
+ const gchar *iface;
+ TypeFlagsToCapsFunc tf2c_fn;
+ CapsToTypeFlagsFunc c2tf_fn;
+};
+
+extern const CapabilityConversionData capabilities_conversions[];
+
+#endif /* __GABBLE_CAPABILITIES__H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/config.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,104 @@
+/*
+ * config.h - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* DBus services directory */
+#undef DBUS_SERVICES_DIR
+
+/* Enable backtrace output on crashes */
+#undef ENABLE_BACKTRACE
+
+/* Enable debug code */
+#undef ENABLE_DEBUG
+
+/* Enable handle leak debug code */
+#undef ENABLE_HANDLE_LEAK_DEBUG
+
+/* Define to 1 if you have the `backtrace' function. */
+#undef HAVE_BACKTRACE
+
+/* Define to 1 if you have the `backtrace_symbols_fd' function. */
+#undef HAVE_BACKTRACE_SYMBOLS_FD
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <execinfo.h> header file. */
+#undef HAVE_EXECINFO_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `signal' function. */
+#undef HAVE_SIGNAL
+
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#define VERSION "1.0"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/debug.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,102 @@
+/*
+ * debug.h - Header for GabbleConnection
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __DEBUG_H__
+#define __DEBUG_H_
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "gabble_enums.h"
+
+
+/*#ifdef ENABLE_DEBUG bsr */
+
+G_BEGIN_DECLS
+
+/*Moved to gabble_enums.h
+typedef enum
+{
+ GABBLE_DEBUG_PRESENCE = 1 << 0,
+ GABBLE_DEBUG_GROUPS = 1 << 1,
+ GABBLE_DEBUG_ROSTER = 1 << 2,
+ GABBLE_DEBUG_DISCO = 1 << 3,
+ GABBLE_DEBUG_PROPERTIES = 1 << 4,
+ GABBLE_DEBUG_ROOMLIST = 1 << 5,
+ GABBLE_DEBUG_MEDIA = 1 << 6,
+ GABBLE_DEBUG_MUC = 1 << 7,
+ GABBLE_DEBUG_CONNECTION = 1 << 8,
+ GABBLE_DEBUG_IM = 1 << 9,
+ GABBLE_DEBUG_PERSIST = 1 << 10,
+ GABBLE_DEBUG_VCARD = 1 << 11,
+} GabbleDebugFlags;
+*/
+
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+void gabble_debug_set_flags_from_env ();
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+void gabble_debug_set_flags (GabbleDebugFlags flags);
+
+gboolean gabble_debug_flag_is_set (GabbleDebugFlags flag);
+void gabble_debug (GabbleDebugFlags flag, const gchar *format, ...);
+ /* bsr G_GNUC_PRINTF (2, 3); */
+#ifdef ENABLE_DEBUG /* bsr */
+#ifdef DEBUG_FLAG
+
+/*#define DEBUG(format, ...) \
+ gabble_debug(DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__)
+*/
+
+#define DEBUG G_DEBUG
+ static inline void G_DEBUG (const gchar *format, ...)
+ {
+ gabble_debug(DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__)
+ }
+
+#define DEBUGGING gabble_debug_flag_is_set(DEBUG_FLAG)
+
+#define NODE_DEBUG(n, s) \
+G_STMT_START { \
+ gchar *debug_tmp = lm_message_node_to_string (n); \
+ gabble_debug (DEBUG_FLAG, "%s: " s ":\n%s", G_STRFUNC, debug_tmp); \
+ g_free (debug_tmp); \
+} G_STMT_END
+
+#else /* DEBUG_FLAG */
+#define DEBUG 0
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+#else /* ENABLE_DEBUG */
+
+#define DEBUG
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+
+#endif /* ENABLE_DEBUG */
+
+G_END_DECLS
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/disco.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,137 @@
+/*
+ * disco.h - Headers for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+
+#ifndef __GABBLE_DISCO_H__
+#define __GABBLE_DISCO_H__
+
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+
+#include "gabble-types.h"
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ GABBLE_DISCO_TYPE_INFO,
+ GABBLE_DISCO_TYPE_ITEMS
+} GabbleDiscoType;
+
+typedef struct _GabbleDiscoClass GabbleDiscoClass;
+typedef struct _GabbleDiscoRequest GabbleDiscoRequest;
+
+/**
+ * GabbleDiscoError:
+ * @GABBLE_DISCO_ERROR_CANCELLED: The DISCO request was cancelled
+ * @GABBLE_DISCO_ERROR_TIMEOUT: The DISCO request timed out
+ * @GABBLE_DISCO_ERROR_UNKNOWN: An unknown error occured
+ */
+typedef enum
+{
+ GABBLE_DISCO_ERROR_CANCELLED,
+ GABBLE_DISCO_ERROR_TIMEOUT,
+ GABBLE_DISCO_ERROR_UNKNOWN
+} GabbleDiscoError;
+
+GQuark gabble_disco_error_quark (void);
+#define GABBLE_DISCO_ERROR gabble_disco_error_quark ()
+
+IMPORT_C GType gabble_disco_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_DISCO \
+ (gabble_disco_get_type())
+#define GABBLE_DISCO(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_DISCO, GabbleDisco))
+#define GABBLE_DISCO_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_DISCO, GabbleDiscoClass))
+#define GABBLE_IS_DISCO(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_DISCO))
+#define GABBLE_IS_DISCO_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_DISCO))
+#define GABBLE_DISCO_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_DISCO, GabbleDiscoClass))
+
+struct _GabbleDiscoClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleDisco {
+ GObject parent;
+ gpointer priv;
+};
+
+typedef void (*GabbleDiscoCb)(GabbleDisco *self, GabbleDiscoRequest *request, const gchar *jid, const gchar *node, LmMessageNode *query_result, GError* error, gpointer user_data);
+
+GabbleDisco *gabble_disco_new (GabbleConnection *);
+
+GabbleDiscoRequest *gabble_disco_request (GabbleDisco *self,
+ GabbleDiscoType type, const gchar *jid, const char *node,
+ GabbleDiscoCb callback, gpointer user_data, GObject *object,
+ GError **error);
+GabbleDiscoRequest *gabble_disco_request_with_timeout (GabbleDisco *self,
+ GabbleDiscoType type, const gchar *jid, const char *node,
+ guint timeout, GabbleDiscoCb callback, gpointer user_data,
+ GObject *object, GError **error);
+
+void gabble_disco_cancel_request (GabbleDisco *, GabbleDiscoRequest *);
+
+/* Pipelines */
+
+typedef struct _GabbleDiscoItem GabbleDiscoItem;
+
+struct _GabbleDiscoItem {
+ const gchar *jid;
+ const char *name;
+ const char *type;
+ const char *category;
+ GHashTable *features;
+};
+
+typedef void (*GabbleDiscoPipelineCb)(gpointer pipeline,
+ GabbleDiscoItem *item,
+ gpointer user_data);
+
+typedef void (*GabbleDiscoEndCb)(gpointer pipeline,
+ gpointer user_data);
+
+gpointer gabble_disco_pipeline_init (GabbleDisco *disco,
+ GabbleDiscoPipelineCb callback,
+ GabbleDiscoEndCb end_callback,
+ gpointer user_data);
+
+void gabble_disco_pipeline_run (gpointer self, const char *server);
+void gabble_disco_pipeline_destroy (gpointer self);
+
+/* Service discovery */
+
+void gabble_disco_service_discovery (GabbleDisco *disco, const char *server);
+const GabbleDiscoItem *
+gabble_disco_service_find (GabbleDisco *disco,
+ const char *type,
+ const char *category,
+ const char *feature);
+
+G_END_DECLS
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-connection-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,697 @@
+/*
+ * gabble-connection-glue.h -
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_connection_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_connection_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:1) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* NONE:STRING,UINT,UINT,BOOLEAN,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:2) */
+extern void dbus_glib_marshal_gabble_connection_VOID__STRING_UINT_UINT_BOOLEAN_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_VOID__STRING_UINT_UINT_BOOLEAN_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_UINT_UINT_BOOLEAN_POINTER) (gpointer data1,
+ gpointer arg_1,
+ guint arg_2,
+ guint arg_3,
+ gboolean arg_4,
+ gpointer arg_5,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_UINT_UINT_BOOLEAN_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 6);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_UINT_UINT_BOOLEAN_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_boolean (param_values + 4),
+ g_marshal_value_peek_pointer (param_values + 5),
+ data2);
+}
+#define dbus_glib_marshal_gabble_connection_NONE__STRING_UINT_UINT_BOOLEAN_POINTER dbus_glib_marshal_gabble_connection_VOID__STRING_UINT_UINT_BOOLEAN_POINTER
+
+/* BOOLEAN:BOXED,BOXED,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:3) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_BOXED_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_BOXED_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:4) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,STRING,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:5) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_STRING_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_STRING_POINTER_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:STRING,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:6) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__STRING_BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__STRING_BOXED_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:7) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:8) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__STRING_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* NONE:UINT,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:9) */
+extern void dbus_glib_marshal_gabble_connection_VOID__UINT_BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_VOID__UINT_BOXED_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_BOXED_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+}
+#define dbus_glib_marshal_gabble_connection_NONE__UINT_BOXED_POINTER dbus_glib_marshal_gabble_connection_VOID__UINT_BOXED_POINTER
+
+/* NONE:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:10) */
+extern void dbus_glib_marshal_gabble_connection_VOID__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_VOID__BOXED_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+}
+#define dbus_glib_marshal_gabble_connection_NONE__BOXED_POINTER dbus_glib_marshal_gabble_connection_VOID__BOXED_POINTER
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:11) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:UINT,POINTER (/tmp/dbus-binding-tool-c-marshallers.R2YJIU:12) */
+extern void dbus_glib_marshal_gabble_connection_BOOLEAN__UINT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_BOOLEAN__UINT_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_connection_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_connection_methods[] = {
+ { (GCallback) gabble_connection_connect, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_connection_disconnect, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER, 48 },
+ { (GCallback) gabble_connection_get_interfaces, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 99 },
+ { (GCallback) gabble_connection_get_protocol, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 167 },
+ { (GCallback) gabble_connection_get_self_handle, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 232 },
+ { (GCallback) gabble_connection_get_status, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 299 },
+ { (GCallback) gabble_connection_hold_handles, dbus_glib_marshal_gabble_connection_NONE__UINT_BOXED_POINTER, 362 },
+ { (GCallback) gabble_connection_inspect_handles, dbus_glib_marshal_gabble_connection_NONE__UINT_BOXED_POINTER, 443 },
+ { (GCallback) gabble_connection_list_channels, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 541 },
+ { (GCallback) gabble_connection_release_handles, dbus_glib_marshal_gabble_connection_NONE__UINT_BOXED_POINTER, 613 },
+ { (GCallback) gabble_connection_request_channel, dbus_glib_marshal_gabble_connection_NONE__STRING_UINT_UINT_BOOLEAN_POINTER, 697 },
+ { (GCallback) gabble_connection_request_handles, dbus_glib_marshal_gabble_connection_NONE__UINT_BOXED_POINTER, 822 },
+ { (GCallback) gabble_connection_get_alias_flags, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 918 },
+ { (GCallback) gabble_connection_request_aliases, dbus_glib_marshal_gabble_connection_NONE__BOXED_POINTER, 1004 },
+ { (GCallback) gabble_connection_set_aliases, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER, 1106 },
+ { (GCallback) gabble_connection_advertise_capabilities, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_BOXED_POINTER_POINTER, 1192 },
+ { (GCallback) gabble_connection_get_capabilities, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER_POINTER, 1318 },
+ { (GCallback) gabble_connection_add_status, dbus_glib_marshal_gabble_connection_BOOLEAN__STRING_BOXED_POINTER, 1429 },
+ { (GCallback) gabble_connection_clear_status, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER, 1523 },
+ { (GCallback) gabble_connection_get_presence, dbus_glib_marshal_gabble_connection_NONE__BOXED_POINTER, 1594 },
+ { (GCallback) gabble_connection_get_statuses, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 1707 },
+ { (GCallback) gabble_connection_remove_status, dbus_glib_marshal_gabble_connection_BOOLEAN__STRING_POINTER, 1804 },
+ { (GCallback) gabble_connection_request_presence, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER, 1887 },
+ { (GCallback) gabble_connection_set_last_activity_time, dbus_glib_marshal_gabble_connection_BOOLEAN__UINT_POINTER, 1976 },
+ { (GCallback) gabble_connection_set_status, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER, 2064 },
+ { (GCallback) gabble_connection_get_properties, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_POINTER_POINTER, 2154 },
+ { (GCallback) gabble_connection_list_properties, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER_POINTER, 2241 },
+ { (GCallback) gabble_connection_set_properties, dbus_glib_marshal_gabble_connection_NONE__BOXED_POINTER, 2315 },
+ { (GCallback) gabble_connection_set_avatar, dbus_glib_marshal_gabble_connection_BOOLEAN__BOXED_STRING_POINTER_POINTER, 2683 },
+ { (GCallback) gabble_connection_clear_avatar, dbus_glib_marshal_gabble_connection_BOOLEAN__POINTER, 2790 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_connection_object_info = {
+ 0,
+ dbus_glib_gabble_connection_methods,
+ 33,
+"org.freedesktop.Telepathy.Connection\0Connect\0S\0\0org.freedesktop.Telepathy.Connection\0Disconnect\0S\0\0org.freedesktop.Telepathy.Connection\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Connection\0GetProtocol\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Connection\0GetSelfHandle\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Connection\0GetStatus\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Connection\0HoldHandles\0A\0handle_type\0I\0u\0handles\0I\0au\0\0org.freedesktop.Telepathy.Connection\0InspectHandles\0A\0handle_type\0I\0u\0handles\0I\0au\0arg2\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Connection\0ListChannels\0S\0arg0\0O\0F\0N\0a(osuu)\0\0org.freedesktop.Telepathy.Connection\0ReleaseHandles\0A\0handle_type\0I\0u\0handles\0I\0au\0\0org.freedesktop.Telepathy.Connection\0RequestChannel\0A\0type\0I\0s\0handle_type\0I\0u\0handle\0I\0u\0suppress_handler\0I\0b\0arg4\0O\0F\0N\0o\0\0org.freedesktop.Telepathy.Connection\0RequestHandles\0A\0handle_type\0I\0u\0names\0I\0as\0arg2\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Connection.Interface.Aliasing\0GetAliasFlags\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Connection.Interface.Aliasing\0RequestAliases\0A\0contacts\0I\0au\0arg1\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Connection.Interface.Aliasing\0SetAliases\0S\0aliases\0I\0a{us}\0\0org.freedesktop.Telepathy.Connection.Interface.Capabilities\0AdvertiseCapabilities\0S\0add\0I\0a(su)\0remove\0I\0as\0arg2\0O\0F\0N\0a(su)\0\0org.freedesktop.Telepathy.Connection.Interface.Capabilities\0GetCapabilities\0S\0handles\0I\0au\0arg1\0O\0F\0N\0a(usuu)\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0AddStatus\0S\0status\0I\0s\0parms\0I\0a{sv}\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0ClearStatus\0S\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0GetPresence\0A\0contacts\0I\0au\0arg1\0O\0F\0N\0a{u(ua{sa{sv}})}\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0GetStatuses\0S\0arg0\0O\0F\0N\0a{s(ubba{ss})}\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0RemoveStatus\0S\0status\0I\0s\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0RequestPresence\0S\0contacts\0I\0au\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0SetLastActivityTime\0S\0time\0I\0u\0\0org.freedesktop.Telepathy.Connection.Interface.Presence\0SetStatus\0S\0statuses\0I\0a{sa{sv}}\0\0org.freedesktop.Telepathy.Properties\0GetProperties\0S\0properties\0I\0au\0arg1\0O\0F\0N\0a(uv)\0\0org.freedesktop.Telepathy.Properties\0ListProperties\0S\0arg0\0O\0F\0N\0a(ussu)\0\0org.freedesktop.Telepathy.Properties\0SetProperties\0A\0properties\0I\0a(uv)\0\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0GetAvatarRequirements\0S\0arg0\0O\0F\0N\0asqqqqu\0\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0GetKnownAvatarTokens\0S\0contacts\0I\0au\0arg1\0O\0F\0N\0a{us}\0\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0RequestAvatars\0S\0contact\0I\0au\0\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0SetAvatar\0S\0avatar\0I\0ay\0mime_type\0I\0s\0arg2\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0ClearAvatar\0S\0\0\0",
+"org.freedesktop.Telepathy.Connection\0NewChannel\0org.freedesktop.Telepathy.Connection\0StatusChanged\0org.freedesktop.Telepathy.Connection.Interface.Aliasing\0AliasesChanged\0org.freedesktop.Telepathy.Connection.Interface.Capabilities\0CapabilitiesChanged\0org.freedesktop.Telepathy.Connection.Interface.Presence\0PresenceUpdate\0org.freedesktop.Telepathy.Properties\0PropertiesChanged\0org.freedesktop.Telepathy.Properties\0PropertyFlagsChanged\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0AvatarUpdated\0org.freedesktop.Telepathy.Connection.Interface.Avatars\0AvatarRetrieved\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-connection-manager-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,247 @@
+/*
+ * gabble-connection-manager-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ */
+
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_connection_manager_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_connection_manager_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.H9O3HT:1) */
+extern void dbus_glib_marshal_gabble_connection_manager_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_manager_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:STRING,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.H9O3HT:2) */
+extern void dbus_glib_marshal_gabble_connection_manager_BOOLEAN__STRING_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_manager_BOOLEAN__STRING_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:STRING,BOXED,POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.H9O3HT:3) */
+extern void dbus_glib_marshal_gabble_connection_manager_BOOLEAN__STRING_BOXED_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_connection_manager_BOOLEAN__STRING_BOXED_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer arg_5,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 6);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ g_marshal_value_peek_pointer (param_values + 5),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_connection_manager_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_connection_manager_methods[] = {
+ { (GCallback) gabble_connection_manager_get_parameters, dbus_glib_marshal_gabble_connection_manager_BOOLEAN__STRING_POINTER_POINTER, 0 },
+ { (GCallback) gabble_connection_manager_list_protocols, dbus_glib_marshal_gabble_connection_manager_BOOLEAN__POINTER_POINTER, 90 },
+ { (GCallback) gabble_connection_manager_request_connection, dbus_glib_marshal_gabble_connection_manager_BOOLEAN__STRING_BOXED_POINTER_POINTER_POINTER, 165 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_connection_manager_object_info = {
+ 0,
+ dbus_glib_gabble_connection_manager_methods,
+ 3,
+"org.freedesktop.Telepathy.ConnectionManager\0GetParameters\0S\0proto\0I\0s\0arg1\0O\0F\0N\0a(susv)\0\0org.freedesktop.Telepathy.ConnectionManager\0ListProtocols\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.ConnectionManager\0RequestConnection\0S\0proto\0I\0s\0parameters\0I\0a{sv}\0arg2\0O\0F\0N\0s\0arg3\0O\0F\0N\0o\0\0\0",
+"org.freedesktop.Telepathy.ConnectionManager\0NewConnection\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-connection-manager-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+ * gabble-connection-manager-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_connection_manager_marshal_MARSHAL_H__
+#define __gabble_connection_manager_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:STRING,STRING,STRING (gabble-connection-manager-signals-marshal.list:1) */
+extern void gabble_connection_manager_marshal_VOID__STRING_STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_connection_manager_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-connection-manager.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,171 @@
+/*
+ * gabble-connection-manager.h - Header for GabbleConnectionManager
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_CONNECTION_MANAGER_H__
+#define __GABBLE_CONNECTION_MANAGER_H__
+
+#include <glib-object.h>
+//vinod
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-protocol.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gabble-connection.h"
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+//end
+#define GABBLE_CONN_MGR_BUS_NAME "org.freedesktop.Telepathy.ConnectionManager.gabble"
+#define GABBLE_CONN_MGR_OBJECT_PATH "/org/freedesktop/Telepathy/ConnectionManager/gabble"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleConnectionManager GabbleConnectionManager;
+typedef struct _GabbleConnectionManagerClass GabbleConnectionManagerClass;
+
+struct _GabbleConnectionManagerClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleConnectionManager {
+ GObject parent;
+
+ gpointer priv;
+};
+
+typedef struct {
+ const gchar *name; /* name as passed over dbus */
+ const gchar *dtype; /* D-Bus type string */
+ const GType gtype; /* glib type string */
+ guint flags; /* combination of TP_CONN_MGR_PARAM_FLAG_foo */
+ const gpointer def; /* default - gchar * or GINT_TO_POINTER */
+ const gsize offset; /* internal use only */
+} GabbleParamSpec;
+
+typedef struct {
+ const gchar *name;
+ const GabbleParamSpec *parameters; /* terminated by a NULL name */
+} GabbleProtocolSpec;
+
+//start: vinod
+/* private data */
+
+typedef struct _GabbleParams GabbleParams;
+
+struct _GabbleParams {
+ guint set_mask;
+
+ gchar *account;
+ gchar *password;
+ gchar *server;
+ gchar *resource;
+ gint priority;
+ guint port;
+ gboolean old_ssl;
+ gboolean do_register;
+ gboolean low_bandwidth;
+ gchar *https_proxy_server;
+ guint https_proxy_port;
+ gchar *fallback_conference_server;
+ gchar *stun_server;
+ guint stun_port;
+ gboolean ignore_ssl_errors;
+ gchar *alias;
+};
+
+//const GabbleProtocolSpec *gabble_protocols; /* terminated by a NULL name */
+static const GabbleParamSpec jabber_params[] = {
+ { "account", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, TP_CONN_MGR_PARAM_FLAG_REQUIRED | TP_CONN_MGR_PARAM_FLAG_REGISTER, NULL, G_STRUCT_OFFSET(GabbleParams, account) },
+ { "password", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, TP_CONN_MGR_PARAM_FLAG_REQUIRED | TP_CONN_MGR_PARAM_FLAG_REGISTER, NULL, G_STRUCT_OFFSET(GabbleParams, password) },
+ { "server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(GabbleParams, server) },
+ { "resource", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GABBLE_PARAMS_DEFAULT_RESOURCE, G_STRUCT_OFFSET(GabbleParams, resource) },
+ { "priority", DBUS_TYPE_INT16_AS_STRING, G_TYPE_INT, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(0), G_STRUCT_OFFSET(GabbleParams, priority) },
+ { "port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(GABBLE_PARAMS_DEFAULT_PORT), G_STRUCT_OFFSET(GabbleParams, port) },
+ { "old-ssl", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), G_STRUCT_OFFSET(GabbleParams, old_ssl) },
+ { "register", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), G_STRUCT_OFFSET(GabbleParams, do_register) },
+ { "low-bandwidth", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), G_STRUCT_OFFSET(GabbleParams, low_bandwidth) },
+ { "https-proxy-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(GabbleParams, https_proxy_server) },
+ { "https-proxy-port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT), G_STRUCT_OFFSET(GabbleParams, https_proxy_port) },
+ { "fallback-conference-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(GabbleParams, fallback_conference_server) },
+ { "stun-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(GabbleParams, stun_server) },
+ { "stun-port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(GABBLE_PARAMS_DEFAULT_STUN_PORT), G_STRUCT_OFFSET(GabbleParams, stun_port) },
+ { "ignore-ssl-errors", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN, TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GINT_TO_POINTER(FALSE), G_STRUCT_OFFSET(GabbleParams, ignore_ssl_errors) },
+ { "alias", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL, G_STRUCT_OFFSET(GabbleParams, alias) },
+ { NULL, NULL, 0, 0, NULL, 0 }
+};
+
+static const GabbleProtocolSpec _gabble_protocols[] = {
+ { "jabber", jabber_params },
+ //{ "jabber", jabber_params }
+ { NULL, NULL } //vinod
+
+};
+
+const GabbleProtocolSpec *gabble_protocols = _gabble_protocols;
+
+//end: vinod
+
+IMPORT_C GType gabble_connection_manager_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_CONNECTION_MANAGER \
+ (gabble_connection_manager_get_type())
+#define GABBLE_CONNECTION_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_CONNECTION_MANAGER, GabbleConnectionManager))
+#define GABBLE_CONNECTION_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_CONNECTION_MANAGER, GabbleConnectionManagerClass))
+#define GABBLE_IS_CONNECTION_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_CONNECTION_MANAGER))
+#define GABBLE_IS_CONNECTION_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_CONNECTION_MANAGER))
+#define GABBLE_CONNECTION_MANAGER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_CONNECTION_MANAGER, GabbleConnectionManagerClass))
+
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+void _gabble_connection_manager_register (GabbleConnectionManager *self);
+
+gboolean
+gabble_connection_manager_get_parameters (GabbleConnectionManager *self,
+ const gchar *proto,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_connection_manager_list_protocols (GabbleConnectionManager *self,
+ gchar ***ret,
+ GError **error);
+
+gboolean
+gabble_connection_manager_request_connection (GabbleConnectionManager *self,
+ const gchar *proto,
+ GHashTable *parameters,
+ gchar **ret,
+ gchar **ret1,
+ GError **error);
+
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_CONNECTION_MANAGER_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-connection-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ * gabble-connection-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_connection_marshal_MARSHAL_H__
+#define __gabble_connection_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:STRING,STRING,UINT,UINT,BOOLEAN (gabble-connection-signals-marshal.list:1) */
+extern void gabble_connection_marshal_VOID__STRING_STRING_UINT_UINT_BOOLEAN (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT (gabble-connection-signals-marshal.list:2) */
+extern void gabble_connection_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_connection_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-connection.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,334 @@
+/*
+ * gabble-connection.h - Header for GabbleConnection
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_CONNECTION_H__
+#define __GABBLE_CONNECTION_H__
+
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+
+#include "gabble-types.h"
+#include "gabble-error.h"
+#include "properties-mixin.h"
+#include "telepathy-constants.h"
+
+G_BEGIN_DECLS
+
+/* Default parameters for optional parameters */
+#define GABBLE_PARAMS_DEFAULT_RESOURCE "Telepathy"
+#define GABBLE_PARAMS_DEFAULT_PORT 5222
+#define GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT 443
+#define GABBLE_PARAMS_DEFAULT_STUN_PORT 3478
+
+/* order must match array of statuses in gabble-connection.c */
+/* in increasing order of presence */
+typedef enum
+{
+ GABBLE_PRESENCE_OFFLINE = 0,
+ GABBLE_PRESENCE_HIDDEN,
+ GABBLE_PRESENCE_XA,
+ GABBLE_PRESENCE_AWAY,
+ GABBLE_PRESENCE_DND,
+ GABBLE_PRESENCE_AVAILABLE,
+ GABBLE_PRESENCE_CHAT,
+ LAST_GABBLE_PRESENCE
+} GabblePresenceId;
+
+typedef enum
+{
+ GABBLE_CONNECTION_FEATURES_NONE = 0,
+ GABBLE_CONNECTION_FEATURES_GOOGLE_JINGLE_INFO = 1 << 0,
+ GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER = 1 << 1,
+ GABBLE_CONNECTION_FEATURES_PRESENCE_INVISIBLE = 1 << 2,
+ GABBLE_CONNECTION_FEATURES_PRIVACY = 1 << 3,
+ GABBLE_CONNECTION_FEATURES_SEARCH = 1 << 4,
+} GabbleConnectionFeatures;
+
+typedef struct _GabbleConnectionClass GabbleConnectionClass;
+
+typedef LmHandlerResult (*GabbleConnectionMsgReplyFunc) (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data);
+
+struct _GabbleConnectionClass {
+ GObjectClass parent_class;
+
+ GabblePropertiesMixinClass properties_class;
+};
+
+struct _GabbleConnection {
+ GObject parent;
+
+ GabblePropertiesMixin properties;
+
+ /* dbus object location */
+ gchar *bus_name;
+ gchar *object_path;
+
+ /* loudmouth connection */
+ LmConnection *lmconn;
+
+ /* connection status */
+ TpConnectionStatus status;
+
+ /* handles */
+ GabbleHandleRepo *handles;
+ GabbleHandle self_handle;
+
+ /* roster */
+ GabbleRoster *roster;
+
+ /* DISCO! */
+ GabbleDisco *disco;
+
+ /* connection feature flags */
+ GabbleConnectionFeatures features;
+
+ /* presence */
+ GabblePresenceCache *presence_cache;
+
+ /* vCard lookup helper */
+ GabbleVCardManager *vcard_manager;
+ /* search related info */
+ /* jid which supports search feature */
+ gchar *search_service_jid;
+ /* key names on which search request can be made */
+ gchar **search_key_names;
+ /* maps search key "label" to "var" */
+ GHashTable *search_key_ht;
+ /* instruction by service to do search */
+ gchar *search_instr;
+ /* gives the detailed info of search results*/
+ gchar **search_reported_fields;
+ /* needed to support search with and without data forms*/
+ gboolean search_form;
+ /*avatar sha1*/
+ gchar* self_avatar_sha1;
+ gpointer priv;
+};
+
+typedef enum {
+ GABBLE_CONNECTION_ALIAS_NONE = 0,
+ GABBLE_CONNECTION_ALIAS_FROM_JID,
+ GABBLE_CONNECTION_ALIAS_FROM_VCARD,
+ GABBLE_CONNECTION_ALIAS_FROM_CONNMGR,
+ GABBLE_CONNECTION_ALIAS_FROM_PRESENCE,
+ GABBLE_CONNECTION_ALIAS_FROM_ROSTER
+} GabbleConnectionAliasSource;
+
+IMPORT_C GType gabble_connection_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_CONNECTION \
+ (gabble_connection_get_type())
+#define GABBLE_CONNECTION(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_CONNECTION, GabbleConnection))
+#define GABBLE_CONNECTION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_CONNECTION, GabbleConnectionClass))
+#define GABBLE_IS_CONNECTION(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_CONNECTION))
+#define GABBLE_IS_CONNECTION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_CONNECTION))
+#define GABBLE_CONNECTION_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_CONNECTION, GabbleConnectionClass))
+
+gboolean _gabble_connection_set_properties_from_account (GabbleConnection *conn, const gchar *account, GError **error);
+gboolean _gabble_connection_register (GabbleConnection *conn, char **bus_name, char **object_path, GError **error);
+gboolean _gabble_connection_send (GabbleConnection *conn, LmMessage *msg, GError **error);
+gboolean _gabble_connection_send_with_reply (GabbleConnection *conn, LmMessage *msg, GabbleConnectionMsgReplyFunc reply_func, GObject *object, gpointer user_data, GError **error);
+void _gabble_connection_acknowledge_set_iq (GabbleConnection *conn, LmMessage *iq);
+void _gabble_connection_send_iq_error (GabbleConnection *conn, LmMessage *message, GabbleXmppError error, const gchar *errmsg);
+
+GabbleConnectionAliasSource _gabble_connection_get_cached_alias (GabbleConnection *, GabbleHandle, gchar **);
+
+const char *_gabble_connection_find_conference_server (GabbleConnection *);
+
+gboolean
+gabble_connection_add_status (GabbleConnection *self,
+ const gchar *status,
+ GHashTable *parms,
+ GError **error);
+
+gboolean
+gabble_connection_advertise_capabilities (GabbleConnection *self,
+ const GPtrArray *add,
+ const gchar **remove,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_connection_clear_status (GabbleConnection *self,
+ GError **error);
+
+gboolean
+gabble_connection_connect (GabbleConnection *self,
+ GError **error);
+
+//Mukesh - start
+gboolean
+gabble_connection_connect_blocking (GabbleConnection *self,
+ GError **error);
+//Mukesh - end
+
+gboolean
+gabble_connection_disconnect (GabbleConnection *self,
+ GError **error);
+
+gboolean
+gabble_connection_get_alias_flags (GabbleConnection *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_connection_get_capabilities (GabbleConnection *self,
+ const GArray *handles,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_connection_get_interfaces (GabbleConnection *self,
+ gchar ***ret,
+ GError **error);
+
+void
+gabble_connection_get_presence (GabbleConnection *self,
+ const GArray *contacts,
+ DBusGMethodInvocation *context);
+
+gboolean
+gabble_connection_get_properties (GabbleConnection *self,
+ const GArray *properties,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_connection_get_protocol (GabbleConnection *self,
+ gchar **ret,
+ GError **error);
+
+gboolean
+gabble_connection_get_self_handle (GabbleConnection *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_connection_get_status (GabbleConnection *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_connection_get_statuses (GabbleConnection *self,
+ GHashTable **ret,
+ GError **error);
+
+void
+gabble_connection_hold_handles (GabbleConnection *self,
+ guint handle_type,
+ const GArray *handles,
+ DBusGMethodInvocation *context);
+
+void
+gabble_connection_inspect_handles (GabbleConnection *self,
+ guint handle_type,
+ const GArray *handles,
+ DBusGMethodInvocation *context);
+
+gboolean
+gabble_connection_list_channels (GabbleConnection *self,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_connection_list_properties (GabbleConnection *self,
+ GPtrArray **ret,
+ GError **error);
+
+void
+gabble_connection_release_handles (GabbleConnection *self,
+ guint handle_type,
+ const GArray *handles,
+ DBusGMethodInvocation *context);
+
+gboolean
+gabble_connection_remove_status (GabbleConnection *self,
+ const gchar *status,
+ GError **error);
+
+void
+gabble_connection_request_aliases (GabbleConnection *self,
+ const GArray *contacts,
+ DBusGMethodInvocation *context);
+
+void
+gabble_connection_request_channel (GabbleConnection *self,
+ const gchar *type,
+ guint handle_type,
+ guint handle,
+ gboolean suppress_handler,
+ DBusGMethodInvocation *context);
+
+void
+gabble_connection_request_handles (GabbleConnection *self,
+ guint handle_type,
+ const gchar **names,
+ DBusGMethodInvocation *context);
+
+gboolean
+gabble_connection_request_presence (GabbleConnection *self,
+ const GArray *contacts,
+ GError **error);
+
+gboolean
+gabble_connection_set_aliases (GabbleConnection *self,
+ GHashTable *aliases,
+ GError **error);
+
+gboolean
+gabble_connection_set_last_activity_time (GabbleConnection *self,
+ guint time,
+ GError **error);
+
+void
+gabble_connection_set_properties (GabbleConnection *self,
+ const GPtrArray *properties,
+ DBusGMethodInvocation *context);
+
+gboolean
+gabble_connection_set_status (GabbleConnection *self,
+ GHashTable *statuses,
+ GError **error);
+
+gboolean
+gabble_connection_set_avatar( GabbleConnection *self, const GArray* bin_image, gchar* mime, gchar**avatar_sha1, GError** err );
+
+gboolean
+gabble_connection_clear_avatar( GabbleConnection *self,
+ GError **error);
+
+
+LmMessage* gabble_connection_build_avatar(GabbleConnection *self,
+ const GArray* bin_image, gchar* mime );
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_CONNECTION_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-error.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,84 @@
+/*
+ * gabble-error.h - Header for Gabble's error handling API
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_ERROR_H__
+#define __GABBLE_ERROR_H__
+
+#include <glib.h>
+#include "loudmouth/loudmouth.h"
+
+typedef enum {
+ XMPP_ERROR_REDIRECT = 0, /* 302 */
+ XMPP_ERROR_GONE, /* 302 */
+
+ XMPP_ERROR_BAD_REQUEST, /* 400 */
+ XMPP_ERROR_UNEXPECTED_REQUEST, /* 400 */
+ XMPP_ERROR_JID_MALFORMED, /* 400 */
+
+ XMPP_ERROR_NOT_AUTHORIZED, /* 401 */
+
+ XMPP_ERROR_PAYMENT_REQUIRED, /* 402 */
+
+ XMPP_ERROR_FORBIDDEN, /* 403 */
+
+ XMPP_ERROR_ITEM_NOT_FOUND, /* 404 */
+ XMPP_ERROR_RECIPIENT_UNAVAILABLE, /* 404 */
+ XMPP_ERROR_REMOTE_SERVER_NOT_FOUND, /* 404 */
+
+ XMPP_ERROR_NOT_ALLOWED, /* 405 */
+
+ XMPP_ERROR_NOT_ACCEPTABLE, /* 406 */
+
+ XMPP_ERROR_REGISTRATION_REQUIRED, /* 407 */
+ XMPP_ERROR_SUBSCRIPTION_REQUIRED, /* 407 */
+
+ XMPP_ERROR_REMOTE_SERVER_TIMEOUT, /* 408, 504 */
+
+ XMPP_ERROR_CONFLICT, /* 409 */
+
+ XMPP_ERROR_INTERNAL_SERVER_ERROR, /* 500 */
+ XMPP_ERROR_UNDEFINED_CONDITION, /* 500 */
+ XMPP_ERROR_RESOURCE_CONSTRAINT, /* 500 */
+
+ XMPP_ERROR_FEATURE_NOT_IMPLEMENTED, /* 501 */
+
+ XMPP_ERROR_SERVICE_UNAVAILABLE, /* 502, 503, 510 */
+
+ XMPP_ERROR_JINGLE_OUT_OF_ORDER,
+ XMPP_ERROR_JINGLE_UNKOWN_SESSION,
+ XMPP_ERROR_JINGLE_UNSUPPORTED_CONTENT,
+ XMPP_ERROR_JINGLE_UNSUPPORTED_TRANSPORT,
+
+ NUM_XMPP_ERRORS,
+
+ INVALID_XMPP_ERROR,
+} GabbleXmppError;
+
+GQuark gabble_xmpp_error_quark (void);
+#define GABBLE_XMPP_ERROR gabble_xmpp_error_quark ()
+
+GabbleXmppError gabble_xmpp_error_from_node (LmMessageNode *error_node);
+GError *gabble_xmpp_error_to_g_error (GabbleXmppError error);
+LmMessageNode *gabble_xmpp_error_to_node (GabbleXmppError error, LmMessageNode *parent_node, const gchar *errmsg);
+const gchar *gabble_xmpp_error_string (GabbleXmppError error);
+const gchar *gabble_xmpp_error_description (GabbleXmppError error);
+
+#endif /* __GABBLE_ERROR_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-im-channel-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,387 @@
+/*
+ * gabble-im-channel-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_im_channel_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_im_channel_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.8R94HT:1) */
+extern void dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.8R94HT:2) */
+extern void dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.8R94HT:3) */
+extern void dbus_glib_marshal_gabble_im_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_im_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:UINT,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.8R94HT:4) */
+extern void dbus_glib_marshal_gabble_im_channel_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_im_channel_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.8R94HT:5) */
+extern void dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOOLEAN,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.8R94HT:6) */
+extern void dbus_glib_marshal_gabble_im_channel_BOOLEAN__BOOLEAN_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_im_channel_BOOLEAN__BOOLEAN_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOOLEAN_POINTER_POINTER) (gpointer data1,
+ gboolean arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOOLEAN_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOOLEAN_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boolean (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_im_channel_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_im_channel_methods[] = {
+ { (GCallback) gabble_im_channel_close, dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_im_channel_get_channel_type, dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER, 43 },
+ { (GCallback) gabble_im_channel_get_handle, dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER_POINTER, 108 },
+ { (GCallback) gabble_im_channel_get_interfaces, dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER, 181 },
+ { (GCallback) gabble_im_channel_acknowledge_pending_messages, dbus_glib_marshal_gabble_im_channel_BOOLEAN__BOXED_POINTER, 246 },
+ { (GCallback) gabble_im_channel_get_message_types, dbus_glib_marshal_gabble_im_channel_BOOLEAN__POINTER_POINTER, 329 },
+ { (GCallback) gabble_im_channel_list_pending_messages, dbus_glib_marshal_gabble_im_channel_BOOLEAN__BOOLEAN_POINTER_POINTER, 406 },
+ { (GCallback) gabble_im_channel_send, dbus_glib_marshal_gabble_im_channel_BOOLEAN__UINT_STRING_POINTER, 504 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_im_channel_object_info = {
+ 0,
+ dbus_glib_gabble_im_channel_methods,
+ 8,
+"org.freedesktop.Telepathy.Channel\0Close\0S\0\0org.freedesktop.Telepathy.Channel\0GetChannelType\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Channel\0GetHandle\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Type.Text\0AcknowledgePendingMessages\0S\0ids\0I\0au\0\0org.freedesktop.Telepathy.Channel.Type.Text\0GetMessageTypes\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Type.Text\0ListPendingMessages\0S\0clear\0I\0b\0arg1\0O\0F\0N\0a(uuuuus)\0\0org.freedesktop.Telepathy.Channel.Type.Text\0Send\0S\0type\0I\0u\0text\0I\0s\0\0\0",
+"org.freedesktop.Telepathy.Channel\0Closed\0org.freedesktop.Telepathy.Channel.Type.Text\0LostMessage\0org.freedesktop.Telepathy.Channel.Type.Text\0Received\0org.freedesktop.Telepathy.Channel.Type.Text\0SendError\0org.freedesktop.Telepathy.Channel.Type.Text\0Sent\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-im-channel-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,30 @@
+/*
+ * gabble-im-channel-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_im_channel_marshal_MARSHAL_H__
+#define __gabble_im_channel_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif /* __gabble_im_channel_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-im-channel.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,114 @@
+/*
+ * gabble-im-channel.h - Header for GabbleIMChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_IM_CHANNEL_H__
+#define __GABBLE_IM_CHANNEL_H__
+
+#include <glib-object.h>
+#include <time.h>
+
+#include "handles.h"
+#include "telepathy-constants.h"
+#include "text-mixin.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleIMChannel GabbleIMChannel;
+typedef struct _GabbleIMChannelClass GabbleIMChannelClass;
+
+struct _GabbleIMChannelClass {
+ GObjectClass parent_class;
+
+ GabbleTextMixinClass text_class;
+};
+
+struct _GabbleIMChannel {
+ GObject parent;
+
+ GabbleTextMixin text;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_im_channel_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_IM_CHANNEL \
+ (gabble_im_channel_get_type())
+#define GABBLE_IM_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_IM_CHANNEL, GabbleIMChannel))
+#define GABBLE_IM_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_IM_CHANNEL, GabbleIMChannelClass))
+#define GABBLE_IS_IM_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_IM_CHANNEL))
+#define GABBLE_IS_IM_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_IM_CHANNEL))
+#define GABBLE_IM_CHANNEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_IM_CHANNEL, GabbleIMChannelClass))
+
+gboolean _gabble_im_channel_receive (GabbleIMChannel *chan, TpChannelTextMessageType type, GabbleHandle sender, const char *from, time_t timestamp, const char *text);
+
+gboolean
+gabble_im_channel_acknowledge_pending_messages (GabbleIMChannel *self,
+ const GArray *ids,
+ GError **error);
+
+gboolean
+gabble_im_channel_close (GabbleIMChannel *self,
+ GError **error);
+
+gboolean
+gabble_im_channel_get_channel_type (GabbleIMChannel *self,
+ gchar **ret,
+ GError **error);
+
+gboolean
+gabble_im_channel_get_handle (GabbleIMChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error);
+
+gboolean
+gabble_im_channel_get_interfaces (GabbleIMChannel *self,
+ gchar ***ret,
+ GError **error);
+
+gboolean
+gabble_im_channel_get_message_types (GabbleIMChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_im_channel_list_pending_messages (GabbleIMChannel *self,
+ gboolean clear,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_im_channel_send (GabbleIMChannel *self,
+ guint type,
+ const gchar *text,
+ GError **error);
+
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_IM_CHANNEL_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-channel-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,550 @@
+/*
+ * gabble-media-channel-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+
+ */
+
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_media_channel_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_media_channel_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:1) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:UINT,BOXED,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:2) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__UINT_BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__UINT_BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_BOXED_POINTER_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_BOXED_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:3) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:4) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:5) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:6) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:UINT,UINT,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:7) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__UINT_UINT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__UINT_UINT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_UINT_POINTER) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_UINT_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:8) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.64D0HT:9) */
+extern void dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_media_channel_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_media_channel_methods[] = {
+ { (GCallback) gabble_media_channel_close, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_media_channel_get_channel_type, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 43 },
+ { (GCallback) gabble_media_channel_get_handle, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER_POINTER, 108 },
+ { (GCallback) gabble_media_channel_get_interfaces, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 181 },
+ { (GCallback) gabble_media_channel_add_members, dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_STRING_POINTER, 246 },
+ { (GCallback) gabble_media_channel_get_all_members, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER, 336 },
+ { (GCallback) gabble_media_channel_get_group_flags, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 445 },
+ { (GCallback) gabble_media_channel_get_handle_owners, dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_POINTER_POINTER, 525 },
+ { (GCallback) gabble_media_channel_get_local_pending_members, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 621 },
+ { (GCallback) gabble_media_channel_get_members, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 711 },
+ { (GCallback) gabble_media_channel_get_remote_pending_members, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 789 },
+ { (GCallback) gabble_media_channel_get_self_handle, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 880 },
+ { (GCallback) gabble_media_channel_remove_members, dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_STRING_POINTER, 960 },
+ { (GCallback) gabble_media_channel_get_session_handlers, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 1053 },
+ { (GCallback) gabble_media_channel_list_streams, dbus_glib_marshal_gabble_media_channel_BOOLEAN__POINTER_POINTER, 1152 },
+ { (GCallback) gabble_media_channel_remove_streams, dbus_glib_marshal_gabble_media_channel_BOOLEAN__BOXED_POINTER, 1241 },
+ { (GCallback) gabble_media_channel_request_stream_direction, dbus_glib_marshal_gabble_media_channel_BOOLEAN__UINT_UINT_POINTER, 1324 },
+ { (GCallback) gabble_media_channel_request_streams, dbus_glib_marshal_gabble_media_channel_BOOLEAN__UINT_BOXED_POINTER_POINTER, 1438 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_media_channel_object_info = {
+ 0,
+ dbus_glib_gabble_media_channel_methods,
+ 18,
+"org.freedesktop.Telepathy.Channel\0Close\0S\0\0org.freedesktop.Telepathy.Channel\0GetChannelType\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Channel\0GetHandle\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0AddMembers\0S\0contacts\0I\0au\0message\0I\0s\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetAllMembers\0S\0arg0\0O\0F\0N\0au\0arg1\0O\0F\0N\0au\0arg2\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetGroupFlags\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetHandleOwners\0S\0handles\0I\0au\0arg1\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetLocalPendingMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetRemotePendingMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetSelfHandle\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0RemoveMembers\0S\0contacts\0I\0au\0message\0I\0s\0\0org.freedesktop.Telepathy.Channel.Interface.MediaSignalling\0GetSessionHandlers\0S\0arg0\0O\0F\0N\0a(os)\0\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0ListStreams\0S\0arg0\0O\0F\0N\0a(uuuuuu)\0\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0RemoveStreams\0S\0streams\0I\0au\0\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0RequestStreamDirection\0S\0stream_id\0I\0u\0stream_direction\0I\0u\0\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0RequestStreams\0S\0contact_handle\0I\0u\0types\0I\0au\0arg2\0O\0F\0N\0a(uuuuuu)\0\0\0",
+"org.freedesktop.Telepathy.Channel\0Closed\0org.freedesktop.Telepathy.Channel.Interface.Group\0GroupFlagsChanged\0org.freedesktop.Telepathy.Channel.Interface.Group\0MembersChanged\0org.freedesktop.Telepathy.Channel.Interface.MediaSignalling\0NewSessionHandler\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0StreamAdded\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0StreamDirectionChanged\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0StreamError\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0StreamRemoved\0org.freedesktop.Telepathy.Channel.Type.StreamedMedia\0StreamStateChanged\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-channel-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,63 @@
+/*
+ * gabble-media-channel-signals-marshal.h - Header for GabbleRoomlistChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_media_channel_marshal_MARSHAL_H__
+#define __gabble_media_channel_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,UINT,STRING (gabble-media-channel-signals-marshal.list:1) */
+extern void gabble_media_channel_marshal_VOID__UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:STRING,STRING (gabble-media-channel-signals-marshal.list:2) */
+extern void gabble_media_channel_marshal_VOID__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT (gabble-media-channel-signals-marshal.list:3) */
+extern void gabble_media_channel_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT,UINT (gabble-media-channel-signals-marshal.list:4) */
+extern void gabble_media_channel_marshal_VOID__UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_media_channel_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-channel.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,203 @@
+/*
+ * gabble-media-channel.h - Header for GabbleMediaChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ * Portions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_MEDIA_CHANNEL_H__
+#define __GABBLE_MEDIA_CHANNEL_H__
+
+#include <glib-object.h>
+
+#include "gabble-media-session.h"
+#include "group-mixin.h"
+#include "handles.h"
+#include "gabble-presence.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleMediaChannel GabbleMediaChannel;
+typedef struct _GabbleMediaChannelClass GabbleMediaChannelClass;
+
+struct _GabbleMediaChannelClass {
+ GObjectClass parent_class;
+
+ GabbleGroupMixinClass group_class;
+};
+
+struct _GabbleMediaChannel {
+ GObject parent;
+
+ GabbleGroupMixin group;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_media_channel_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_MEDIA_CHANNEL \
+ (gabble_media_channel_get_type())
+#define GABBLE_MEDIA_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MEDIA_CHANNEL, GabbleMediaChannel))
+#define GABBLE_MEDIA_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MEDIA_CHANNEL, GabbleMediaChannelClass))
+#define GABBLE_IS_MEDIA_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MEDIA_CHANNEL))
+#define GABBLE_IS_MEDIA_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MEDIA_CHANNEL))
+#define GABBLE_MEDIA_CHANNEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MEDIA_CHANNEL, GabbleMediaChannelClass))
+
+gboolean
+_gabble_media_channel_add_member (GObject *obj,
+ GabbleHandle handle,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_media_channel_add_members (GabbleMediaChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_media_channel_close (GabbleMediaChannel *self,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_all_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GArray **ret1,
+ GArray **ret2,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_channel_type (GabbleMediaChannel *self,
+ gchar **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_group_flags (GabbleMediaChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_handle (GabbleMediaChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_handle_owners (GabbleMediaChannel *self,
+ const GArray *handles,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_interfaces (GabbleMediaChannel *self,
+ gchar ***ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_local_pending_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_remote_pending_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_self_handle (GabbleMediaChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_get_session_handlers (GabbleMediaChannel *self,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_list_streams (GabbleMediaChannel *self,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_media_channel_remove_members (GabbleMediaChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_media_channel_remove_streams (GabbleMediaChannel *self,
+ const GArray *streams,
+ GError **error);
+
+gboolean
+gabble_media_channel_request_stream_direction (GabbleMediaChannel *self,
+ guint stream_id,
+ guint stream_direction,
+ GError **error);
+
+gboolean
+gabble_media_channel_request_streams (GabbleMediaChannel *self,
+ guint contact_handle,
+ const GArray *types,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+_gabble_media_channel_dispatch_session_action (GabbleMediaChannel *chan,
+ GabbleHandle peer,
+ const gchar *peer_resource,
+ const gchar *sid,
+ LmMessage *message,
+ LmMessageNode *session_node,
+ const gchar *action,
+ GError **error);
+
+void
+_gabble_media_channel_stream_state (GabbleMediaChannel *chan,
+ guint state);
+
+guint
+_gabble_media_channel_get_stream_id (GabbleMediaChannel *chan);
+
+GabblePresenceCapabilities
+_gabble_media_channel_typeflags_to_caps (TpChannelMediaCapabilities flags);
+
+//moved definition to .c file
+GabblePresenceCapabilities
+_gabble_media_channel_typeflags_to_caps_tmp (guint flags);
+
+TpChannelMediaCapabilities
+_gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps);
+
+//moved definition to .c file
+guint
+_gabble_media_channel_caps_to_typeflags_tmp (GabblePresenceCapabilities caps);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_MEDIA_CHANNEL_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-session-enumtypes.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,40 @@
+/*
+ * gabble-media-session-enumtypes.h - Header for GabbleRoomlistChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* Generated data (by glib-mkenums) */
+
+#ifndef __GABBLE_MEDIA_SESSION_ENUM_TYPES_H__
+#define __GABBLE_MEDIA_SESSION_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/* enumerations from "gabble-media-session.h" */
+GType gabble_media_session_mode_get_type (void);
+#define GABBLE_TYPE_MEDIA_SESSION_MODE (gabble_media_session_mode_get_type())
+GType jingle_session_state_get_type (void);
+#define GABBLE_TYPE_SESSION_STATE (jingle_session_state_get_type())
+GType debug_message_type_get_type (void);
+#define GABBLE_TYPE_MESSAGE_TYPE (debug_message_type_get_type())
+G_END_DECLS
+
+#endif /* __GABBLE_MEDIA_SESSION_ENUM_TYPES_H__ */
+
+/* Generated data ends here */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-session-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,190 @@
+/*
+ * gabble-media-session-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_media_session_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_media_session_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:UINT,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.C5J0HT:1) */
+extern void dbus_glib_marshal_gabble_media_session_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_session_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.C5J0HT:2) */
+extern void dbus_glib_marshal_gabble_media_session_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_session_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_media_session_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_media_session_methods[] = {
+ { (GCallback) gabble_media_session_error, dbus_glib_marshal_gabble_media_session_BOOLEAN__UINT_STRING_POINTER, 0 },
+ { (GCallback) gabble_media_session_ready, dbus_glib_marshal_gabble_media_session_BOOLEAN__POINTER, 78 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_media_session_object_info = {
+ 0,
+ dbus_glib_gabble_media_session_methods,
+ 2,
+"org.freedesktop.Telepathy.Media.SessionHandler\0Error\0S\0errno\0I\0u\0message\0I\0s\0\0org.freedesktop.Telepathy.Media.SessionHandler\0Ready\0S\0\0\0",
+"org.freedesktop.Telepathy.Media.SessionHandler\0NewStreamHandler\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-session-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ * gabble-media-session-signals-marshal.h - Header for GabbleRoomlistChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_media_session_marshal_MARSHAL_H__
+#define __gabble_media_session_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:STRING,UINT,UINT,UINT (gabble-media-session-signals-marshal.list:1) */
+extern void gabble_media_session_marshal_VOID__STRING_UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT (gabble-media-session-signals-marshal.list:2) */
+extern void gabble_media_session_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_media_session_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-session.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,221 @@
+/*
+ * gabble-media-session.h - Header for GabbleMediaSession
+ * Copyright (C) 2006 Collabora Ltd.
+ * Portions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_MEDIA_SESSION_H__
+#define __GABBLE_MEDIA_SESSION_H__
+
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+
+#include "gabble-types.h"
+#include "gabble-media-stream.h"
+#include "telepathy-constants.h"
+
+G_BEGIN_DECLS
+
+
+typedef enum
+{
+ MODE_GOOGLE,
+ MODE_JINGLE
+} GabbleMediaSessionMode;
+
+typedef enum {
+ JS_STATE_INVALID = -1,
+ JS_STATE_PENDING_CREATED = 0,
+ JS_STATE_PENDING_INITIATE_SENT,
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_PENDING_ACCEPT_SENT,
+ JS_STATE_ACTIVE,
+ JS_STATE_ENDED
+} JingleSessionState;
+
+typedef enum {
+ DEBUG_MSG_INFO = 0,
+ DEBUG_MSG_DUMP,
+ DEBUG_MSG_WARNING,
+ DEBUG_MSG_ERROR,
+ DEBUG_MSG_EVENT
+} DebugMessageType;
+
+typedef struct _GabbleMediaSession GabbleMediaSession;
+typedef struct _GabbleMediaSessionClass GabbleMediaSessionClass;
+
+struct _GabbleMediaSessionClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleMediaSession {
+ GObject parent;
+
+ JingleInitiator initiator;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_media_session_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_MEDIA_SESSION \
+ (gabble_media_session_get_type())
+#define GABBLE_MEDIA_SESSION(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSession))
+#define GABBLE_MEDIA_SESSION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSessionClass))
+#define GABBLE_IS_MEDIA_SESSION(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MEDIA_SESSION))
+#define GABBLE_IS_MEDIA_SESSION_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MEDIA_SESSION))
+#define GABBLE_MEDIA_SESSION_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSessionClass))
+
+#define NODE_DEBUG(n, s)
+
+/* CONVENIENCE MACROS */
+#define MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL(s, m) \
+ G_STMT_START { \
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT) \
+ { \
+ _gabble_media_session_debug (s, DEBUG_MSG_ERROR, m); \
+ NODE_DEBUG (sent_msg->node, "message sent"); \
+ NODE_DEBUG (reply_msg->node, "message reply"); \
+ _gabble_media_session_terminate (s, INITIATOR_LOCAL, TP_CHANNEL_GROUP_CHANGE_REASON_ERROR); \
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE; \
+ } \
+ } G_STMT_END
+
+gboolean
+gabble_media_session_error (GabbleMediaSession *self,
+ guint errno,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_media_session_ready (GabbleMediaSession *self,
+ GError **error);
+
+
+gboolean
+_gabble_media_session_handle_action (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *session_node,
+ const gchar *action,
+ GError **error);
+
+LmMessage *_gabble_media_session_message_new (GabbleMediaSession *session,
+ const gchar *action,
+ LmMessageNode **session_node);
+
+void _gabble_media_session_accept (GabbleMediaSession *session);
+void _gabble_media_session_remove_streams (GabbleMediaSession *session, GabbleMediaStream **streams, guint len);
+void _gabble_media_session_terminate (GabbleMediaSession *session, JingleInitiator who, TpChannelGroupChangeReason why);
+
+gboolean _gabble_media_session_request_streams (GabbleMediaSession *session,
+ const GArray *types,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean _gabble_media_session_request_stream_direction (GabbleMediaSession *,
+ GabbleMediaStream *,
+ TpMediaStreamDirection,
+ GError **);
+
+#ifndef _GMS_DEBUG_LEVEL
+#define _GMS_DEBUG_LEVEL 2
+#endif
+
+#if _GMS_DEBUG_LEVEL
+#ifdef ENABLE_DEBUG
+
+//#define GMS_DEBUG_INFO(s, ...) _gabble_media_session_debug (s, DEBUG_MSG_INFO, __VA_ARGS__)
+//vinod
+#define GMS_DEBUG_INFO G_GMS_DEBUG_INFO
+ static inline void G_GMS_DEBUG_INFO (const gchar *s, ...)
+ {
+ _gabble_media_session_debug (s, DEBUG_MSG_INFO, __VA_ARGS__)
+ }
+
+
+#if _GMS_DEBUG_LEVEL > 1
+//#define GMS_DEBUG_DUMP(s, ...) _gabble_media_session_debug (s, DEBUG_MSG_DUMP, __VA_ARGS__)
+//vinod
+#define GMS_DEBUG_DUMP G_GMS_DEBUG_DUMP
+ static inline void G_GMS_DEBUG_DUMP (const gchar *s, ...)
+ {
+ _gabble_media_session_debug (s, DEBUG_MSG_DUMP, __VA_ARGS__)
+ }
+
+#else
+#define GMS_DEBUG_DUMP(s, ...)
+#endif
+//#define GMS_DEBUG_WARNING(s, ...) _gabble_media_session_debug (s, DEBUG_MSG_WARNING, __VA_ARGS__)
+//vinod
+#define GMS_DEBUG_WARNING G_GMS_DEBUG_WARNING
+ static inline void G_GMS_DEBUG_WARNING (const gchar *s, ...)
+ {
+ _gabble_media_session_debug (s, DEBUG_MSG_WARNING, __VA_ARGS__)
+ }
+
+//#define GMS_DEBUG_ERROR(s, ...) _gabble_media_session_debug (s, DEBUG_MSG_ERROR, __VA_ARGS__)
+//vinod
+#define GMS_DEBUG_ERROR G_GMS_DEBUG_ERROR
+ static inline void G_GMS_DEBUG_ERROR (const gchar *s, ...)
+ {
+ _gabble_media_session_debug (s, DEBUG_MSG_ERROR, __VA_ARGS__)
+ }
+
+
+//#define GMS_DEBUG_EVENT(s, ...) _gabble_media_session_debug (s, DEBUG_MSG_EVENT, __VA_ARGS__)
+//vinod
+#define GMS_DEBUG_EVENT G_GMS_DEBUG_EVENT
+ static inline void G_GMS_DEBUG_EVENT (const gchar *s, ...)
+ {
+ _gabble_media_session_debug (s, DEBUG_MSG_EVENT, __VA_ARGS__)
+ }
+
+void _gabble_media_session_debug (GabbleMediaSession *session,
+ DebugMessageType type,
+ const gchar *format, ...)
+ G_GNUC_PRINTF (3, 4);
+
+#else
+
+void _gabble_media_session_debug (GabbleMediaSession *session,
+ DebugMessageType type,
+ const gchar *format, ...)
+ G_GNUC_PRINTF (3, 4);
+
+//#define GMS_DEBUG_INFO(s, ...)
+#define GMS_DEBUG_INFO
+//#define GMS_DEBUG_DUMP(s, ...)
+#define GMS_DEBUG_DUMP
+//#define GMS_DEBUG_WARNING(s, ...)
+#define GMS_DEBUG_WARNING
+//#define GMS_DEBUG_ERROR(s, ...)
+#define GMS_DEBUG_ERROR
+//#define GMS_DEBUG_EVENT(s, ...)
+#define GMS_DEBUG_EVENT
+
+#endif /* ENABLE_DEBUG */
+#endif /* _GMS_DEBUG_LEVEL */
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_MEDIA_SESSION_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-stream-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,389 @@
+/*
+ * gabble-media-stream-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_media_stream_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_media_stream_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:STRING,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.RGD2HT:1) */
+extern void dbus_glib_marshal_gabble_media_stream_BOOLEAN__STRING_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_stream_BOOLEAN__STRING_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.RGD2HT:2) */
+extern void dbus_glib_marshal_gabble_media_stream_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_stream_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:UINT,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.RGD2HT:3) */
+extern void dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:STRING,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.RGD2HT:4) */
+extern void dbus_glib_marshal_gabble_media_stream_BOOLEAN__STRING_BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_stream_BOOLEAN__STRING_BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:UINT,POINTER (/tmp/dbus-binding-tool-c-marshallers.RGD2HT:5) */
+extern void dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.RGD2HT:6) */
+extern void dbus_glib_marshal_gabble_media_stream_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_media_stream_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_media_stream_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_media_stream_methods[] = {
+ { (GCallback) gabble_media_stream_codec_choice, dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_POINTER, 0 },
+ { (GCallback) gabble_media_stream_error, dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_STRING_POINTER, 74 },
+ { (GCallback) gabble_media_stream_native_candidates_prepared, dbus_glib_marshal_gabble_media_stream_BOOLEAN__POINTER, 151 },
+ { (GCallback) gabble_media_stream_new_active_candidate_pair, dbus_glib_marshal_gabble_media_stream_BOOLEAN__STRING_STRING_POINTER, 225 },
+ { (GCallback) gabble_media_stream_new_native_candidate, dbus_glib_marshal_gabble_media_stream_BOOLEAN__STRING_BOXED_POINTER, 345 },
+ { (GCallback) gabble_media_stream_ready, dbus_glib_marshal_gabble_media_stream_BOOLEAN__BOXED_POINTER, 457 },
+ { (GCallback) gabble_media_stream_set_local_codecs, dbus_glib_marshal_gabble_media_stream_BOOLEAN__BOXED_POINTER, 535 },
+ { (GCallback) gabble_media_stream_stream_state, dbus_glib_marshal_gabble_media_stream_BOOLEAN__UINT_POINTER, 622 },
+ { (GCallback) gabble_media_stream_supported_codecs, dbus_glib_marshal_gabble_media_stream_BOOLEAN__BOXED_POINTER, 693 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_media_stream_object_info = {
+ 0,
+ dbus_glib_gabble_media_stream_methods,
+ 9,
+"org.freedesktop.Telepathy.Media.StreamHandler\0CodecChoice\0S\0codec_id\0I\0u\0\0org.freedesktop.Telepathy.Media.StreamHandler\0Error\0S\0errno\0I\0u\0message\0I\0s\0\0org.freedesktop.Telepathy.Media.StreamHandler\0NativeCandidatesPrepared\0S\0\0org.freedesktop.Telepathy.Media.StreamHandler\0NewActiveCandidatePair\0S\0native_candidate_id\0I\0s\0remote_candidate_id\0I\0s\0\0org.freedesktop.Telepathy.Media.StreamHandler\0NewNativeCandidate\0S\0candidate_id\0I\0s\0transports\0I\0a(usuussduss)\0\0org.freedesktop.Telepathy.Media.StreamHandler\0Ready\0S\0codecs\0I\0a(usuuua{ss})\0\0org.freedesktop.Telepathy.Media.StreamHandler\0SetLocalCodecs\0S\0codecs\0I\0a(usuuua{ss})\0\0org.freedesktop.Telepathy.Media.StreamHandler\0StreamState\0S\0state\0I\0u\0\0org.freedesktop.Telepathy.Media.StreamHandler\0SupportedCodecs\0S\0codecs\0I\0a(usuuua{ss})\0\0\0",
+"org.freedesktop.Telepathy.Media.StreamHandler\0AddRemoteCandidate\0org.freedesktop.Telepathy.Media.StreamHandler\0Close\0org.freedesktop.Telepathy.Media.StreamHandler\0RemoveRemoteCandidate\0org.freedesktop.Telepathy.Media.StreamHandler\0SetActiveCandidatePair\0org.freedesktop.Telepathy.Media.StreamHandler\0SetRemoteCandidateList\0org.freedesktop.Telepathy.Media.StreamHandler\0SetRemoteCodecs\0org.freedesktop.Telepathy.Media.StreamHandler\0SetStreamPlaying\0org.freedesktop.Telepathy.Media.StreamHandler\0SetStreamSending\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-stream-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,55 @@
+/*
+ * gabble-media-stream-signals-marshal.h
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_media_stream_marshal_MARSHAL_H__
+#define __gabble_media_stream_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:STRING,BOXED (gabble-media-stream-signals-marshal.list:1) */
+extern void gabble_media_stream_marshal_VOID__STRING_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:STRING,STRING (gabble-media-stream-signals-marshal.list:2) */
+extern void gabble_media_stream_marshal_VOID__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,STRING (gabble-media-stream-signals-marshal.list:3) */
+extern void gabble_media_stream_marshal_VOID__UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_media_stream_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-media-stream.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,178 @@
+/*
+ * gabble-media-stream.h - Header for GabbleMediaStream
+ * Copyright (C) 2006 Collabora Ltd.
+ * Portions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_MEDIA_STREAM_H__
+#define __GABBLE_MEDIA_STREAM_H__
+
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+
+#include "gabble-types.h"
+#include "telepathy-constants.h"
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ STREAM_SIG_STATE_NEW,
+ STREAM_SIG_STATE_SENT,
+ STREAM_SIG_STATE_ACKNOWLEDGED,
+ STREAM_SIG_STATE_REMOVING
+} StreamSignallingState;
+
+typedef guint32 CombinedStreamDirection;
+
+typedef struct _GabbleMediaStream GabbleMediaStream;
+typedef struct _GabbleMediaStreamClass GabbleMediaStreamClass;
+
+struct _GabbleMediaStreamClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleMediaStream {
+ GObject parent;
+
+ gchar *name;
+
+ JingleInitiator initiator;
+ TpMediaStreamState connection_state;
+ StreamSignallingState signalling_state;
+
+ CombinedStreamDirection combined_direction;
+ gboolean got_local_codecs;
+ gboolean playing;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_media_stream_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_MEDIA_STREAM \
+ (gabble_media_stream_get_type())
+#define GABBLE_MEDIA_STREAM(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MEDIA_STREAM, GabbleMediaStream))
+#define GABBLE_MEDIA_STREAM_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MEDIA_STREAM, GabbleMediaStreamClass))
+#define GABBLE_IS_MEDIA_STREAM(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MEDIA_STREAM))
+#define GABBLE_IS_MEDIA_STREAM_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MEDIA_STREAM))
+#define GABBLE_MEDIA_STREAM_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MEDIA_STREAM, GabbleMediaStreamClass))
+
+#define TP_TYPE_TRANSPORT_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_STRING, \
+ G_TYPE_DOUBLE, \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_STRING, \
+ G_TYPE_INVALID))
+#define TP_TYPE_TRANSPORT_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_TRANSPORT_STRUCT))
+#define TP_TYPE_CANDIDATE_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_STRING, \
+ TP_TYPE_TRANSPORT_LIST, \
+ G_TYPE_INVALID))
+#define TP_TYPE_CANDIDATE_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_CANDIDATE_STRUCT))
+
+#define TP_TYPE_CODEC_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ DBUS_TYPE_G_STRING_STRING_HASHTABLE, \
+ G_TYPE_INVALID))
+#define TP_TYPE_CODEC_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_CODEC_STRUCT))
+
+#define COMBINED_DIRECTION_GET_DIRECTION(d) \
+ ((TpMediaStreamDirection) ((d) & TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL))
+#define COMBINED_DIRECTION_GET_PENDING_SEND(d) \
+ ((TpMediaStreamPendingSend) ((d) >> 2))
+#define MAKE_COMBINED_DIRECTION(d, p) \
+ ((CombinedStreamDirection) ((d) | ((p) << 2)))
+
+gboolean
+gabble_media_stream_codec_choice (GabbleMediaStream *self,
+ guint codec_id,
+ GError **error);
+
+gboolean
+gabble_media_stream_error (GabbleMediaStream *self,
+ guint errno,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_media_stream_native_candidates_prepared (GabbleMediaStream *self,
+ GError **error);
+
+gboolean
+gabble_media_stream_new_active_candidate_pair (GabbleMediaStream *self,
+ const gchar *native_candidate_id,
+ const gchar *remote_candidate_id,
+ GError **error);
+
+gboolean
+gabble_media_stream_new_native_candidate (GabbleMediaStream *self,
+ const gchar *candidate_id,
+ const GPtrArray *transports,
+ GError **error);
+
+gboolean
+gabble_media_stream_ready (GabbleMediaStream *self,
+ const GPtrArray *codecs,
+ GError **error);
+
+gboolean
+gabble_media_stream_set_local_codecs (GabbleMediaStream *self,
+ const GPtrArray *codecs,
+ GError **error);
+
+gboolean
+gabble_media_stream_stream_state (GabbleMediaStream *self,
+ guint state,
+ GError **error);
+
+gboolean
+gabble_media_stream_supported_codecs (GabbleMediaStream *self,
+ const GPtrArray *codecs,
+ GError **error);
+
+
+void _gabble_media_stream_close (GabbleMediaStream *close);
+gboolean _gabble_media_stream_post_remote_codecs (GabbleMediaStream *stream, LmMessage *message, LmMessageNode *desc_node, GError **error);
+gboolean _gabble_media_stream_post_remote_candidates (GabbleMediaStream *stream, LmMessage *message, LmMessageNode *transport_node, GError **error);
+LmMessageNode *_gabble_media_stream_add_content_node (GabbleMediaStream *stream, LmMessageNode *session_node);
+void _gabble_media_stream_content_node_add_description (GabbleMediaStream *stream, LmMessageNode *content_node);
+LmMessageNode *_gabble_media_stream_content_node_add_transport (GabbleMediaStream *stream, LmMessageNode *content_node);
+void _gabble_media_stream_update_sending (GabbleMediaStream *stream, gboolean start_sending);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_MEDIA_STREAM_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-muc-channel-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,639 @@
+/*
+ * gabble-muc-channel-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_muc_channel_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_muc_channel_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:1) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:2) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:3) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:4) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* NONE:STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:5) */
+extern void dbus_glib_marshal_gabble_muc_channel_VOID__STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_VOID__STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+}
+#define dbus_glib_marshal_gabble_muc_channel_NONE__STRING_POINTER dbus_glib_marshal_gabble_muc_channel_VOID__STRING_POINTER
+
+/* BOOLEAN:UINT,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:6) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__UINT_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__UINT_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__UINT_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:7) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* NONE:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:8) */
+extern void dbus_glib_marshal_gabble_muc_channel_VOID__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_VOID__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+}
+#define dbus_glib_marshal_gabble_muc_channel_NONE__BOXED_POINTER dbus_glib_marshal_gabble_muc_channel_VOID__BOXED_POINTER
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:9) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:10) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOOLEAN,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.U374HT:11) */
+extern void dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOOLEAN_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOOLEAN_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOOLEAN_POINTER_POINTER) (gpointer data1,
+ gboolean arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOOLEAN_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOOLEAN_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boolean (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_muc_channel_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_muc_channel_methods[] = {
+ { (GCallback) gabble_muc_channel_close, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_muc_channel_get_channel_type, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 43 },
+ { (GCallback) gabble_muc_channel_get_handle, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER_POINTER, 108 },
+ { (GCallback) gabble_muc_channel_get_interfaces, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 181 },
+ { (GCallback) gabble_muc_channel_add_members, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_STRING_POINTER, 246 },
+ { (GCallback) gabble_muc_channel_get_all_members, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER, 336 },
+ { (GCallback) gabble_muc_channel_get_group_flags, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 445 },
+ { (GCallback) gabble_muc_channel_get_handle_owners, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER_POINTER, 525 },
+ { (GCallback) gabble_muc_channel_get_local_pending_members, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 621 },
+ { (GCallback) gabble_muc_channel_get_members, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 711 },
+ { (GCallback) gabble_muc_channel_get_remote_pending_members, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 789 },
+ { (GCallback) gabble_muc_channel_get_self_handle, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 880 },
+ { (GCallback) gabble_muc_channel_remove_members, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_STRING_POINTER, 960 },
+ { (GCallback) gabble_muc_channel_get_password_flags, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 1053 },
+ { (GCallback) gabble_muc_channel_provide_password, dbus_glib_marshal_gabble_muc_channel_NONE__STRING_POINTER, 1139 },
+ { (GCallback) gabble_muc_channel_acknowledge_pending_messages, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER, 1237 },
+ { (GCallback) gabble_muc_channel_get_message_types, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 1320 },
+ { (GCallback) gabble_muc_channel_list_pending_messages, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOOLEAN_POINTER_POINTER, 1397 },
+ { (GCallback) gabble_muc_channel_send, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__UINT_STRING_POINTER, 1495 },
+ { (GCallback) gabble_muc_channel_get_properties, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__BOXED_POINTER_POINTER, 1565 },
+ { (GCallback) gabble_muc_channel_list_properties, dbus_glib_marshal_gabble_muc_channel_BOOLEAN__POINTER_POINTER, 1652 },
+ { (GCallback) gabble_muc_channel_set_properties, dbus_glib_marshal_gabble_muc_channel_NONE__BOXED_POINTER, 1726 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_muc_channel_object_info = {
+ 0,
+ dbus_glib_gabble_muc_channel_methods,
+ 22,
+"org.freedesktop.Telepathy.Channel\0Close\0S\0\0org.freedesktop.Telepathy.Channel\0GetChannelType\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Channel\0GetHandle\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0AddMembers\0S\0contacts\0I\0au\0message\0I\0s\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetAllMembers\0S\0arg0\0O\0F\0N\0au\0arg1\0O\0F\0N\0au\0arg2\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetGroupFlags\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetHandleOwners\0S\0handles\0I\0au\0arg1\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetLocalPendingMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetRemotePendingMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetSelfHandle\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0RemoveMembers\0S\0contacts\0I\0au\0message\0I\0s\0\0org.freedesktop.Telepathy.Channel.Interface.Password\0GetPasswordFlags\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Password\0ProvidePassword\0A\0password\0I\0s\0arg1\0O\0F\0N\0b\0\0org.freedesktop.Telepathy.Channel.Type.Text\0AcknowledgePendingMessages\0S\0ids\0I\0au\0\0org.freedesktop.Telepathy.Channel.Type.Text\0GetMessageTypes\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Type.Text\0ListPendingMessages\0S\0clear\0I\0b\0arg1\0O\0F\0N\0a(uuuuus)\0\0org.freedesktop.Telepathy.Channel.Type.Text\0Send\0S\0type\0I\0u\0text\0I\0s\0\0org.freedesktop.Telepathy.Properties\0GetProperties\0S\0properties\0I\0au\0arg1\0O\0F\0N\0a(uv)\0\0org.freedesktop.Telepathy.Properties\0ListProperties\0S\0arg0\0O\0F\0N\0a(ussu)\0\0org.freedesktop.Telepathy.Properties\0SetProperties\0A\0properties\0I\0a(uv)\0\0\0",
+"org.freedesktop.Telepathy.Channel\0Closed\0org.freedesktop.Telepathy.Channel.Interface.Group\0GroupFlagsChanged\0org.freedesktop.Telepathy.Channel.Interface.Group\0MembersChanged\0org.freedesktop.Telepathy.Channel.Interface.Password\0PasswordFlagsChanged\0org.freedesktop.Telepathy.Channel.Type.Text\0LostMessage\0org.freedesktop.Telepathy.Channel.Type.Text\0Received\0org.freedesktop.Telepathy.Channel.Type.Text\0SendError\0org.freedesktop.Telepathy.Channel.Type.Text\0Sent\0org.freedesktop.Telepathy.Properties\0PropertiesChanged\0org.freedesktop.Telepathy.Properties\0PropertyFlagsChanged\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-muc-channel-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+ * gabble-muc-channel-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_muc_channel_marshal_MARSHAL_H__
+#define __gabble_muc_channel_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,UINT (gabble-muc-channel-signals-marshal.list:1) */
+extern void gabble_muc_channel_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_muc_channel_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-muc-channel.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,199 @@
+/*
+ * gabble-muc-channel.h - Header for GabbleMucChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_MUC_CHANNEL_H__
+#define __GABBLE_MUC_CHANNEL_H__
+
+#include <glib-object.h>
+
+#include "group-mixin.h"
+#include "properties-mixin.h"
+#include "text-mixin.h"
+#include "handles.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleMucChannel GabbleMucChannel;
+typedef struct _GabbleMucChannelClass GabbleMucChannelClass;
+
+struct _GabbleMucChannelClass {
+ GObjectClass parent_class;
+
+ GabbleGroupMixinClass group_class;
+ GabblePropertiesMixinClass properties_class;
+ GabbleTextMixinClass text_class;
+};
+
+struct _GabbleMucChannel {
+ GObject parent;
+
+ GabbleGroupMixin group;
+ GabblePropertiesMixin properties;
+ GabbleTextMixin text;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_muc_channel_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_MUC_CHANNEL \
+ (gabble_muc_channel_get_type())
+#define GABBLE_MUC_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MUC_CHANNEL, GabbleMucChannel))
+#define GABBLE_MUC_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MUC_CHANNEL, GabbleMucChannelClass))
+#define GABBLE_IS_MUC_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MUC_CHANNEL))
+#define GABBLE_IS_MUC_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MUC_CHANNEL))
+#define GABBLE_MUC_CHANNEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MUC_CHANNEL, GabbleMucChannelClass))
+
+gboolean _gabble_muc_channel_is_ready (GabbleMucChannel *chan);
+void _gabble_muc_channel_presence_error (GabbleMucChannel *chan, const gchar *jid, LmMessageNode *pres_node);
+void _gabble_muc_channel_member_presence_updated (GabbleMucChannel *chan, GabbleHandle handle, LmMessage *message, LmMessageNode *x_node);
+gboolean _gabble_muc_channel_receive (GabbleMucChannel *chan, TpChannelTextMessageType msg_type, TpHandleType handle_type, GabbleHandle sender, time_t timestamp, const gchar *text, LmMessage *msg);
+
+void _gabble_muc_channel_handle_invited (GabbleMucChannel *chan, GabbleHandle inviter, const gchar *message);
+
+gboolean
+gabble_muc_channel_acknowledge_pending_messages (GabbleMucChannel *self,
+ const GArray *ids,
+ GError **error);
+
+gboolean
+gabble_muc_channel_add_members (GabbleMucChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_muc_channel_close (GabbleMucChannel *self,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_all_members (GabbleMucChannel *self,
+ GArray **ret,
+ GArray **ret1,
+ GArray **ret2,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_channel_type (GabbleMucChannel *self,
+ gchar **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_group_flags (GabbleMucChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_handle (GabbleMucChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_handle_owners (GabbleMucChannel *self,
+ const GArray *handles,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_interfaces (GabbleMucChannel *self,
+ gchar ***ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_local_pending_members (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_members (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_message_types (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_password_flags (GabbleMucChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_properties (GabbleMucChannel *self,
+ const GArray *properties,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_remote_pending_members (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_get_self_handle (GabbleMucChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_list_pending_messages (GabbleMucChannel *self,
+ gboolean clear,
+ GPtrArray **ret,
+ GError **error);
+
+gboolean
+gabble_muc_channel_list_properties (GabbleMucChannel *self,
+ GPtrArray **ret,
+ GError **error);
+
+void
+gabble_muc_channel_provide_password (GabbleMucChannel *self,
+ const gchar *password,
+ DBusGMethodInvocation *context);
+
+gboolean
+gabble_muc_channel_remove_members (GabbleMucChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_muc_channel_send (GabbleMucChannel *self,
+ guint type,
+ const gchar *text,
+ GError **error);
+
+void
+gabble_muc_channel_set_properties (GabbleMucChannel *self,
+ const GPtrArray *properties,
+ DBusGMethodInvocation *context);
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_MUC_CHANNEL_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-presence-cache-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+ * gabble-presence-cache-signals-marshal.h - Header for GabbleRoomlistChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_presence_cache_marshal_MARSHAL_H__
+#define __gabble_presence_cache_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,UINT,UINT (gabble-presence-cache-signals-marshal.list:1) */
+extern void gabble_presence_cache_marshal_VOID__UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_presence_cache_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-presence-cache.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,85 @@
+/*
+ * gabble-presence-cache.h - Headers for Gabble's contact presence cache
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_PRESENCE_CACHE_H__
+#define __GABBLE_PRESENCE_CACHE_H__
+
+#include <glib-object.h>
+
+#include "gabble-presence.h"
+#include "handles.h"
+
+G_BEGIN_DECLS
+
+#define GABBLE_TYPE_PRESENCE_CACHE gabble_presence_cache_get_type()
+
+#define GABBLE_PRESENCE_CACHE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ GABBLE_TYPE_PRESENCE_CACHE, GabblePresenceCache))
+
+#define GABBLE_PRESENCE_CACHE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ GABBLE_TYPE_PRESENCE_CACHE, GabblePresenceCacheClass))
+
+#define GABBLE_IS_PRESENCE_CACHE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ GABBLE_TYPE_PRESENCE_CACHE))
+
+#define GABBLE_IS_PRESENCE_CACHE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ GABBLE_TYPE_PRESENCE_CACHE))
+
+#define GABBLE_PRESENCE_CACHE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ GABBLE_TYPE_PRESENCE_CACHE, GabblePresenceCacheClass))
+
+#define JABBER_PRESENCE_SHOW_AWAY "away"
+#define JABBER_PRESENCE_SHOW_CHAT "chat"
+#define JABBER_PRESENCE_SHOW_DND "dnd"
+#define JABBER_PRESENCE_SHOW_XA "xa"
+
+struct _GabblePresenceCache {
+ GObject parent;
+ gpointer priv;
+};
+
+typedef struct _GabblePresenceCacheClass GabblePresenceCacheClass;
+
+struct _GabblePresenceCacheClass {
+ GObjectClass parent_class;
+};
+
+IMPORT_C GType gabble_presence_cache_get_type (void);
+
+GabblePresenceCache *gabble_presence_cache_new (GabbleConnection *conn);
+GabblePresence *gabble_presence_cache_get (GabblePresenceCache *cache,
+ GabbleHandle handle);
+void gabble_presence_cache_update (GabblePresenceCache *cache,
+ GabbleHandle handle, const gchar *resource, GabblePresenceId presence_id,
+ const gchar *status_message, gint8 priority);
+void gabble_presence_cache_maybe_remove (GabblePresenceCache *cache,
+ GabbleHandle handle);
+void gabble_presence_cache_add_bundle_caps (GabblePresenceCache *cache,
+ const gchar *node, GabblePresenceCapabilities caps);
+
+G_END_DECLS
+
+#endif /* __GABBLE_PRESENCE_CACHE_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-presence.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,104 @@
+/*
+ * gabble-presence.h - Headers for Gabble's per-contact presence structure
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __GABBLE_PRESENCE_H__
+#define __GABBLE_PRESENCE_H__
+
+#include <glib-object.h>
+
+#include "gabble-connection.h"
+#include "gabble_enums.h"
+
+G_BEGIN_DECLS
+
+#define GABBLE_TYPE_PRESENCE gabble_presence_get_type()
+
+#define GABBLE_PRESENCE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ GABBLE_TYPE_PRESENCE, GabblePresence))
+
+#define GABBLE_PRESENCE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ GABBLE_TYPE_PRESENCE, GabblePresenceClass))
+
+#define GABBLE_IS_PRESENCE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ GABBLE_TYPE_PRESENCE))
+
+#define GABBLE_IS_PRESENCE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ GABBLE_TYPE_PRESENCE))
+
+#define GABBLE_PRESENCE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ GABBLE_TYPE_PRESENCE, GabblePresenceClass))
+/*Moved to gabble_enums.h
+typedef enum {
+ PRESENCE_CAP_NONE = 0,
+ PRESENCE_CAP_GOOGLE_TRANSPORT_P2P = 1 << 0,
+ PRESENCE_CAP_GOOGLE_VOICE = 1 << 1,
+ PRESENCE_CAP_JINGLE = 1 << 2,
+ PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO = 1 << 3,
+ PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO = 1 << 4,
+} GabblePresenceCapabilities;*/
+
+typedef struct _GabblePresence GabblePresence;
+
+struct _GabblePresence {
+ GObject parent;
+ GabblePresenceCapabilities caps;
+ GabblePresenceId status;
+ gchar *status_message;
+ gchar *nickname;
+ gchar *avatar_sha1;
+ gboolean keep_unavailable;
+ gpointer priv;
+};
+
+typedef struct _GabblePresenceClass GabblePresenceClass;
+
+struct _GabblePresenceClass {
+ GObjectClass parent_class;
+};
+
+IMPORT_C GType gabble_presence_get_type (void);
+
+GabblePresence* gabble_presence_new (void);
+
+gboolean gabble_presence_update (GabblePresence *presence, const gchar *resource, GabblePresenceId status, const gchar *status_message, gint8 priority);
+
+void gabble_presence_set_capabilities (GabblePresence *presence, const gchar *resource, GabblePresenceCapabilities caps, guint serial);
+
+const gchar *gabble_presence_pick_resource_by_caps (GabblePresence *presence, GabblePresenceCapabilities caps);
+
+gboolean
+gabble_presence_resource_has_caps (GabblePresence *presence,
+ const gchar *resource,
+ GabblePresenceCapabilities caps);
+
+LmMessage *gabble_presence_as_message (GabblePresence *presence, const gchar *resource);
+gchar *
+gabble_presence_dump (GabblePresence *presence);
+
+G_END_DECLS
+
+#endif /* __GABBLE_PRESENCE_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-register-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+ * gabble-register-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __gabble_register_marshal_MARSHAL_H__
+#define __gabble_register_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:BOOLEAN,INT,STRING (gabble-register-signals-marshal.list:1) */
+extern void gabble_register_marshal_VOID__BOOLEAN_INT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __gabble_register_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-register.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,65 @@
+/*
+ * gabble-register.h - Headers for Gabble account registration
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_REGISTER_H__
+#define __GABBLE_REGISTER_H__
+
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleRegister GabbleRegister;
+typedef struct _GabbleRegisterClass GabbleRegisterClass;
+
+IMPORT_C GType gabble_register_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_REGISTER \
+ (gabble_register_get_type())
+#define GABBLE_REGISTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_REGISTER, GabbleRegister))
+#define GABBLE_REGISTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_REGISTER, GabbleRegisterClass))
+#define GABBLE_IS_REGISTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_REGISTER))
+#define GABBLE_IS_REGISTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_REGISTER))
+#define GABBLE_REGISTER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_REGISTER, GabbleRegisterClass))
+
+struct _GabbleRegisterClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleRegister {
+ GObject parent;
+};
+
+GabbleRegister *gabble_register_new (GabbleConnection *conn);
+void gabble_register_start (GabbleRegister *reg);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_REGISTER_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-roomlist-channel-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,240 @@
+/*
+ * gabble-roomlist-channel-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_roomlist_channel_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_roomlist_channel_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.Q5SKIT:1) */
+extern void dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.Q5SKIT:2) */
+extern void dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.Q5SKIT:3) */
+extern void dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_roomlist_channel_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_roomlist_channel_methods[] = {
+ { (GCallback) gabble_roomlist_channel_close, dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_roomlist_channel_get_channel_type, dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER, 43 },
+ { (GCallback) gabble_roomlist_channel_get_handle, dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER_POINTER, 108 },
+ { (GCallback) gabble_roomlist_channel_get_interfaces, dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER, 181 },
+ { (GCallback) gabble_roomlist_channel_get_listing_rooms, dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER_POINTER, 246 },
+ { (GCallback) gabble_roomlist_channel_list_rooms, dbus_glib_marshal_gabble_roomlist_channel_BOOLEAN__POINTER, 326 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_roomlist_channel_object_info = {
+ 0,
+ dbus_glib_gabble_roomlist_channel_methods,
+ 6,
+"org.freedesktop.Telepathy.Channel\0Close\0S\0\0org.freedesktop.Telepathy.Channel\0GetChannelType\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Channel\0GetHandle\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Type.RoomList\0GetListingRooms\0S\0arg0\0O\0F\0N\0b\0\0org.freedesktop.Telepathy.Channel.Type.RoomList\0ListRooms\0S\0\0\0",
+"org.freedesktop.Telepathy.Channel\0Closed\0org.freedesktop.Telepathy.Channel.Type.RoomList\0GotRooms\0org.freedesktop.Telepathy.Channel.Type.RoomList\0ListingRooms\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-roomlist-channel-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,29 @@
+/*
+ * gabble-roomlist-channel-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __gabble_roomlist_channel_marshal_MARSHAL_H__
+#define __gabble_roomlist_channel_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif /* __gabble_roomlist_channel_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-roomlist-channel.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,93 @@
+/*
+ * gabble-roomlist-channel.h - Header for GabbleRoomlistChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_ROOMLIST_CHANNEL_H__
+#define __GABBLE_ROOMLIST_CHANNEL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleRoomlistChannel GabbleRoomlistChannel;
+typedef struct _GabbleRoomlistChannelClass GabbleRoomlistChannelClass;
+
+struct _GabbleRoomlistChannelClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleRoomlistChannel {
+ GObject parent;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_roomlist_channel_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_ROOMLIST_CHANNEL \
+ (gabble_roomlist_channel_get_type())
+#define GABBLE_ROOMLIST_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_ROOMLIST_CHANNEL, GabbleRoomlistChannel))
+#define GABBLE_ROOMLIST_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_ROOMLIST_CHANNEL, GabbleRoomlistChannelClass))
+#define GABBLE_IS_ROOMLIST_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_ROOMLIST_CHANNEL))
+#define GABBLE_IS_ROOMLIST_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_ROOMLIST_CHANNEL))
+#define GABBLE_ROOMLIST_CHANNEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_ROOMLIST_CHANNEL, GabbleRoomlistChannelClass))
+
+
+GabbleRoomlistChannel *_gabble_roomlist_channel_new (GabbleConnection *conn, const gchar *object_path, const gchar *conference_server);
+
+gboolean
+gabble_roomlist_channel_close (GabbleRoomlistChannel *self,
+ GError **error);
+
+gboolean
+gabble_roomlist_channel_get_channel_type (GabbleRoomlistChannel *self,
+ gchar **ret,
+ GError **error);
+
+gboolean
+gabble_roomlist_channel_get_handle (GabbleRoomlistChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error);
+
+gboolean
+gabble_roomlist_channel_get_interfaces (GabbleRoomlistChannel *self,
+ gchar ***ret,
+ GError **error);
+
+gboolean
+gabble_roomlist_channel_get_listing_rooms (GabbleRoomlistChannel *self,
+ gboolean *ret,
+ GError **error);
+
+gboolean
+gabble_roomlist_channel_list_rooms (GabbleRoomlistChannel *self,
+ GError **error);
+
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_ROOMLIST_CHANNEL_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-roster-channel-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,396 @@
+/*
+ * gabble-roster-channel-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_roster_channel_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_roster_channel_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.KKEKIT:1) */
+extern void dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.KKEKIT:2) */
+extern void dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.KKEKIT:3) */
+extern void dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.KKEKIT:4) */
+extern void dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.KKEKIT:5) */
+extern void dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.KKEKIT:6) */
+extern void dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ g_marshal_value_peek_pointer (param_values + 4),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_roster_channel_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_roster_channel_methods[] = {
+ { (GCallback) gabble_roster_channel_close, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_roster_channel_get_channel_type, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 43 },
+ { (GCallback) gabble_roster_channel_get_handle, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER_POINTER, 108 },
+ { (GCallback) gabble_roster_channel_get_interfaces, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 181 },
+ { (GCallback) gabble_roster_channel_add_members, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_STRING_POINTER, 246 },
+ { (GCallback) gabble_roster_channel_get_all_members, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER_POINTER_POINTER, 336 },
+ { (GCallback) gabble_roster_channel_get_group_flags, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 445 },
+ { (GCallback) gabble_roster_channel_get_handle_owners, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_POINTER_POINTER, 525 },
+ { (GCallback) gabble_roster_channel_get_local_pending_members, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 621 },
+ { (GCallback) gabble_roster_channel_get_members, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 711 },
+ { (GCallback) gabble_roster_channel_get_remote_pending_members, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 789 },
+ { (GCallback) gabble_roster_channel_get_self_handle, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__POINTER_POINTER, 880 },
+ { (GCallback) gabble_roster_channel_remove_members, dbus_glib_marshal_gabble_roster_channel_BOOLEAN__BOXED_STRING_POINTER, 960 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_roster_channel_object_info = {
+ 0,
+ dbus_glib_gabble_roster_channel_methods,
+ 13,
+"org.freedesktop.Telepathy.Channel\0Close\0S\0\0org.freedesktop.Telepathy.Channel\0GetChannelType\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Channel\0GetHandle\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0AddMembers\0S\0contacts\0I\0au\0message\0I\0s\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetAllMembers\0S\0arg0\0O\0F\0N\0au\0arg1\0O\0F\0N\0au\0arg2\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetGroupFlags\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetHandleOwners\0S\0handles\0I\0au\0arg1\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetLocalPendingMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetRemotePendingMembers\0S\0arg0\0O\0F\0N\0au\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0GetSelfHandle\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Interface.Group\0RemoveMembers\0S\0contacts\0I\0au\0message\0I\0s\0\0\0",
+"org.freedesktop.Telepathy.Channel\0Closed\0org.freedesktop.Telepathy.Channel.Interface.Group\0GroupFlagsChanged\0org.freedesktop.Telepathy.Channel.Interface.Group\0MembersChanged\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-roster-channel-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,29 @@
+/*
+ * gabble-roster-channel-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __gabble_roster_channel_marshal_MARSHAL_H__
+#define __gabble_roster_channel_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif /* __gabble_roster_channel_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-roster-channel.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,139 @@
+/*
+ * gabble-roster-channel.h - Header for GabbleRosterChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_ROSTER_CHANNEL_H__
+#define __GABBLE_ROSTER_CHANNEL_H__
+
+#include <glib-object.h>
+#include "gintset.h"
+
+#include "gabble-types.h"
+#include "group-mixin.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleRosterChannelClass GabbleRosterChannelClass;
+
+struct _GabbleRosterChannelClass {
+ GObjectClass parent_class;
+
+ GabbleGroupMixinClass group_class;
+};
+
+struct _GabbleRosterChannel {
+ GObject parent;
+
+ GabbleGroupMixin group;
+
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_roster_channel_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_ROSTER_CHANNEL \
+ (gabble_roster_channel_get_type())
+#define GABBLE_ROSTER_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_ROSTER_CHANNEL, GabbleRosterChannel))
+#define GABBLE_ROSTER_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_ROSTER_CHANNEL, GabbleRosterChannelClass))
+#define GABBLE_IS_ROSTER_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_ROSTER_CHANNEL))
+#define GABBLE_IS_ROSTER_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_ROSTER_CHANNEL))
+#define GABBLE_ROSTER_CHANNEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_ROSTER_CHANNEL, GabbleRosterChannelClass))
+
+
+gboolean
+gabble_roster_channel_add_members (GabbleRosterChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error);
+
+gboolean
+gabble_roster_channel_close (GabbleRosterChannel *self,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_all_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GArray **ret1,
+ GArray **ret2,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_channel_type (GabbleRosterChannel *self,
+ gchar **ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_group_flags (GabbleRosterChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_handle (GabbleRosterChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_handle_owners (GabbleRosterChannel *self,
+ const GArray *handles,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_interfaces (GabbleRosterChannel *self,
+ gchar ***ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_local_pending_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_remote_pending_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_get_self_handle (GabbleRosterChannel *self,
+ guint *ret,
+ GError **error);
+
+gboolean
+gabble_roster_channel_remove_members (GabbleRosterChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error);
+
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_ROSTER_CHANNEL_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-search-channel-glue.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,289 @@
+/*
+ * gabble-search-channel-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_gabble_search_channel_MARSHAL_H__
+#define __dbus_glib_marshal_gabble_search_channel_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.69O99T:1) */
+extern void dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER,POINTER,POINTER (/tmp/dbus-binding-tool-c-marshallers.69O99T:2) */
+extern void dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ g_marshal_value_peek_pointer (param_values + 3),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.69O99T:3) */
+extern void dbus_glib_marshal_gabble_search_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_search_channel_BOOLEAN__BOXED_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__BOXED_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_boxed (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:POINTER (/tmp/dbus-binding-tool-c-marshallers.69O99T:4) */
+extern void dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 2);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_pointer (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_gabble_search_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_gabble_search_channel_methods[] = {
+ { (GCallback) gabble_search_channel_close, dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER, 0 },
+ { (GCallback) gabble_search_channel_get_channel_type, dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER, 43 },
+ { (GCallback) gabble_search_channel_get_handle, dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER_POINTER, 108 },
+ { (GCallback) gabble_search_channel_get_interfaces, dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER, 181 },
+ { (GCallback) gabble_search_channel_get_search_keys, dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER_POINTER, 246 },
+ { (GCallback) gabble_search_channel_get_search_state, dbus_glib_marshal_gabble_search_channel_BOOLEAN__POINTER_POINTER, 343 },
+ { (GCallback) gabble_search_channel_search, dbus_glib_marshal_gabble_search_channel_BOOLEAN__BOXED_POINTER, 427 },
+};
+
+const DBusGObjectInfo dbus_glib_gabble_search_channel_object_info = {
+ 0,
+ dbus_glib_gabble_search_channel_methods,
+ 7,
+"org.freedesktop.Telepathy.Channel\0Close\0S\0\0org.freedesktop.Telepathy.Channel\0GetChannelType\0S\0arg0\0O\0F\0N\0s\0\0org.freedesktop.Telepathy.Channel\0GetHandle\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel\0GetInterfaces\0S\0arg0\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Type.ContactSearch\0GetSearchKeys\0S\0arg0\0O\0F\0N\0s\0arg1\0O\0F\0N\0as\0\0org.freedesktop.Telepathy.Channel.Type.ContactSearch\0GetSearchState\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.Telepathy.Channel.Type.ContactSearch\0Search\0S\0terms\0I\0a{sv}\0\0\0",
+"org.freedesktop.Telepathy.Channel\0Closed\0org.freedesktop.Telepathy.Channel.Type.ContactSearch\0SearchResultReceived\0org.freedesktop.Telepathy.Channel.Type.ContactSearch\0SearchStateChanged\0\0",
+"\0"
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-search-channel.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,127 @@
+/*
+ * gabble-im-channel.h - Header for GabbleSearchChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_SEARCH_CHANNEL_H__
+#define __GABBLE_SEARCH_CHANNEL_H__
+
+#include <glib-object.h>
+#include <time.h>
+
+#include "loudmouth/loudmouth.h"
+
+
+#include "handles.h"
+#include "telepathy-constants.h"
+#include "search-mixin.h"
+
+G_BEGIN_DECLS
+
+
+
+extern LmHandlerResult
+search_channel_iq_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data);
+
+typedef struct _GabbleSearchChannel GabbleSearchChannel;
+typedef struct _GabbleSearchChannelClass GabbleSearchChannelClass;
+
+struct _GabbleSearchChannelClass {
+ GObjectClass parent_class;
+
+ GabbleSearchMixinClass mixin_class;
+};
+
+struct _GabbleSearchChannel {
+ GObject parent;
+ LmMessageHandler *iq_cb;
+ GabbleSearchMixin search_mixin;
+ //todo: channel_index used for closing/removing the channel..
+ //can this be done without index?
+ guint channel_index;
+ gpointer priv;
+};
+
+IMPORT_C GType gabble_search_channel_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_SEARCH_CHANNEL \
+ (gabble_search_channel_get_type())
+#define GABBLE_SEARCH_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_SEARCH_CHANNEL, GabbleSearchChannel))
+#define GABBLE_SEARCH_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_SEARCH_CHANNEL, GabbleSearchChannelClass))
+#define GABBLE_IS_SEARCH_CHANNEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_SEARCH_CHANNEL))
+#define GABBLE_IS_SEARCH_CHANNEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_SEARCH_CHANNEL))
+#define GABBLE_SEARCH_CHANNEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_SEARCH_CHANNEL, GabbleSearchChannelClass))
+
+
+
+gboolean
+gabble_search_channel_close (GabbleSearchChannel *self,
+ GError **error);
+
+gboolean
+gabble_search_channel_get_channel_type (GabbleSearchChannel *self,
+ gchar **ret,
+ GError **error);
+
+
+gboolean
+gabble_search_channel_get_interfaces (GabbleSearchChannel *self,
+ gchar ***ret,
+ GError **error);
+
+
+gboolean
+gabble_search_channel_get_search_keys ( GabbleSearchChannel *self,
+ gchar **instruction,
+ gchar ***key_names,
+ GError **error
+ );
+
+gboolean
+gabble_search_channel_get_search_state ( GabbleSearchChannel *self,
+ guint *ret,
+ GError **error
+ );
+
+gboolean
+gabble_search_channel_search ( GabbleSearchChannel *self,
+ GHashTable *params,
+ GError **error
+ );
+
+
+gboolean
+gabble_search_channel_get_handle (GabbleSearchChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error);
+
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_SEARCH_CHANNEL_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble-types.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,44 @@
+/*
+ * gabble-types.h - Header for Gabble type definitions
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_TYPES_H__
+#define __GABBLE_TYPES_H__
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleConnection GabbleConnection;
+typedef struct _GabbleDisco GabbleDisco;
+typedef struct _GabbleHandleRepo GabbleHandleRepo;
+typedef struct _GabblePresenceCache GabblePresenceCache;
+typedef struct _GabbleRoster GabbleRoster;
+typedef struct _GabbleRosterChannel GabbleRosterChannel;
+typedef struct _GabbleVCardManager GabbleVCardManager;
+typedef guint32 GabbleHandle;
+
+typedef enum {
+ INITIATOR_INVALID = -1,
+ INITIATOR_LOCAL = 0,
+ INITIATOR_REMOTE,
+} JingleInitiator;
+
+G_END_DECLS
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,31 @@
+/*
+ * gabble.h - entry point and utility functions for telepathy-gabble
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_H__
+#define __GABBLE_H__
+
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_H__*/
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gabble_enums.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,76 @@
+/*
+ * gabble_enums.h - Header for GabbleConnection
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef enum_gabble
+#define enum_gabble
+
+/* signal enum */
+#define LAST_SIGNAL_CON_MGR 2
+#define LAST_SIGNAL_CON 6
+#define LAST_SIGNAL_IM 1
+#define LAST_SIGNAL_MUC 4
+#define LAST_SIGNAL_MED_CHANNEL 7
+#define LAST_SIGNAL_MED_SESSION 3
+#define LAST_SIGNAL_MED_STREAM 13
+#define MAX_STREAM_NAME_LEN 8
+#define LAST_SIGNAL_PRE_CACHE 3
+#define LAST_SIGNAL_REGISTER 2
+#define LAST_SIGNAL_ROS_CHNL 3
+#define LAST_SIGNAL_ROOM_CHNL 3
+#define LAST_SIGNAL_ROSTER 1
+#define LAST_SIGNAL_VCARD_MGR 1
+
+//todo: what it should be
+#define LAST_SIGNAL_SEARCH 1
+typedef struct _GabbleAllocator GabbleAllocator;
+struct _GabbleAllocator
+{
+ gulong size;
+ guint limit;
+ guint count;
+};
+
+typedef enum
+{
+ GABBLE_DEBUG_PRESENCE = 1 << 0,
+ GABBLE_DEBUG_GROUPS = 1 << 1,
+ GABBLE_DEBUG_ROSTER = 1 << 2,
+ GABBLE_DEBUG_DISCO = 1 << 3,
+ GABBLE_DEBUG_PROPERTIES = 1 << 4,
+ GABBLE_DEBUG_ROOMLIST = 1 << 5,
+ GABBLE_DEBUG_MEDIA = 1 << 6,
+ GABBLE_DEBUG_MUC = 1 << 7,
+ GABBLE_DEBUG_CONNECTION = 1 << 8,
+ GABBLE_DEBUG_IM = 1 << 9,
+ GABBLE_DEBUG_PERSIST = 1 << 10,
+ GABBLE_DEBUG_VCARD = 1 << 11,
+ GABBLE_DEBUG_SEARCH = 1 << 12,
+} GabbleDebugFlags;
+
+
+typedef enum {
+ PRESENCE_CAP_NONE = 0,
+ PRESENCE_CAP_GOOGLE_TRANSPORT_P2P = 1 << 0,
+ PRESENCE_CAP_GOOGLE_VOICE = 1 << 1,
+ PRESENCE_CAP_JINGLE = 1 << 2,
+ PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO = 1 << 3,
+ PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO = 1 << 4,
+} GabblePresenceCapabilities;
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gheap.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,40 @@
+/*
+ * Header file for GHeap
+ *
+ *
+ * Copyright (C) 2006 Nokia Corporation.
+ * Contact: Olli Salli (Nokia-M/Helsinki) <olli.salli@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __G_HEAP_H__
+#define __G_HEAP_H__
+
+#include <glib.h>
+
+typedef struct _GHeap GHeap;
+
+GHeap *g_heap_new (GCompareFunc comparator);
+void g_heap_destroy (GHeap *);
+void g_heap_clear (GHeap *);
+
+void g_heap_add (GHeap *heap, gpointer element);
+gpointer g_heap_peek_first (GHeap *heap);
+gpointer g_heap_extract_first (GHeap *heap);
+
+guint g_heap_size (GHeap *heap);
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/gintset.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,53 @@
+/* gintset.h - Headers for a Glib-link set of integers
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __G_INTSET_H__
+#define __G_INTSET_H__
+
+#include <glib-object.h>
+
+typedef struct _GIntSet GIntSet;
+typedef void (*GIntFunc) (guint i, gpointer userdata);
+
+GIntSet *g_intset_new ();
+void g_intset_destroy (GIntSet *);
+void g_intset_clear (GIntSet *);
+
+void g_intset_add (GIntSet *set, guint element);
+gboolean g_intset_remove (GIntSet *set, guint element);
+gboolean g_intset_is_member (const GIntSet *set, guint element);
+
+void g_intset_foreach (const GIntSet *set, GIntFunc func, gpointer userdata);
+GArray *g_intset_to_array (GIntSet *set);
+GIntSet *g_intset_from_array (GArray *array);
+
+guint g_intset_size (const GIntSet *set);
+
+gboolean g_intset_is_equal (const GIntSet *left, const GIntSet *right);
+
+GIntSet *g_intset_copy (const GIntSet *orig);
+GIntSet *g_intset_intersection (const GIntSet *left, const GIntSet *right);
+GIntSet *g_intset_union (const GIntSet *left, const GIntSet *right);
+GIntSet *g_intset_difference (const GIntSet *left, const GIntSet *right);
+GIntSet *g_intset_symmetric_difference (const GIntSet *left, const GIntSet *right);
+
+gchar *g_intset_dump (const GIntSet *set);
+
+#endif /*__G_INTSET_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/group-mixin-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ * group-mixin-signals-marshal.h
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __group_mixin_marshal_MARSHAL_H__
+#define __group_mixin_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,UINT (group-mixin-signals-marshal.list:1) */
+extern void group_mixin_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT (group-mixin-signals-marshal.list:2) */
+extern void group_mixin_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __group_mixin_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/group-mixin.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,99 @@
+/*
+ * group-mixin.h - Header for GabbleGroupMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ * Portions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_GROUP_MIXIN_H__
+#define __GABBLE_GROUP_MIXIN_H__
+
+#include "handles.h"
+#include "handle-set.h"
+#include "util.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleGroupMixinClass GabbleGroupMixinClass;
+typedef struct _GabbleGroupMixin GabbleGroupMixin;
+typedef struct _GabbleGroupMixinPrivate GabbleGroupMixinPrivate;
+
+typedef gboolean (*GabbleGroupMixinAddMemberFunc) (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+typedef gboolean (*GabbleGroupMixinRemMemberFunc) (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+
+struct _GabbleGroupMixinClass {
+ GabbleGroupMixinAddMemberFunc add_member;
+ GabbleGroupMixinRemMemberFunc remove_member;
+
+ guint group_flags_changed_signal_id;
+ guint members_changed_signal_id;
+};
+
+struct _GabbleGroupMixin {
+ GabbleHandleRepo *handle_repo;
+ GabbleHandle self_handle;
+
+ TpChannelGroupFlags group_flags;
+
+ GabbleHandleSet *members;
+ GabbleHandleSet *local_pending;
+ GabbleHandleSet *remote_pending;
+
+ GabbleGroupMixinPrivate *priv;
+};
+
+/* TYPE MACROS */
+#define GABBLE_GROUP_MIXIN_CLASS_OFFSET_QUARK (gabble_group_mixin_class_get_offset_quark())
+#define GABBLE_GROUP_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), GABBLE_GROUP_MIXIN_CLASS_OFFSET_QUARK)))
+#define GABBLE_GROUP_MIXIN_CLASS(o) ((GabbleGroupMixinClass *) gabble_mixin_offset_cast (o, GABBLE_GROUP_MIXIN_CLASS_OFFSET (o)))
+
+#define GABBLE_GROUP_MIXIN_OFFSET_QUARK (gabble_group_mixin_get_offset_quark())
+#define GABBLE_GROUP_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), GABBLE_GROUP_MIXIN_OFFSET_QUARK)))
+#define GABBLE_GROUP_MIXIN(o) ((GabbleGroupMixin *) gabble_mixin_offset_cast (o, GABBLE_GROUP_MIXIN_OFFSET(o)))
+
+GQuark gabble_group_mixin_class_get_offset_quark (void);
+GQuark gabble_group_mixin_get_offset_quark (void);
+
+void gabble_group_mixin_class_init (GObjectClass *obj_cls, glong offset, GabbleGroupMixinAddMemberFunc add_func, GabbleGroupMixinRemMemberFunc rem_func);
+
+void gabble_group_mixin_init (GObject *obj, glong offset, GabbleHandleRepo *handle_repo, GabbleHandle self_handle);
+void gabble_group_mixin_finalize (GObject *obj);
+
+gboolean gabble_group_mixin_get_self_handle (GObject *obj, guint *ret, GError **error);
+gboolean gabble_group_mixin_get_group_flags (GObject *obj, guint *ret, GError **error);
+
+gboolean gabble_group_mixin_add_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error);
+gboolean gabble_group_mixin_remove_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error);
+
+gboolean gabble_group_mixin_get_members (GObject *obj, GArray **ret, GError **error);
+gboolean gabble_group_mixin_get_local_pending_members (GObject *obj, GArray **ret, GError **error);
+gboolean gabble_group_mixin_get_remote_pending_members (GObject *obj, GArray **ret, GError **error);
+gboolean gabble_group_mixin_get_all_members (GObject *obj, GArray **ret, GArray **ret1, GArray **ret2, GError **error);
+
+gboolean gabble_group_mixin_get_handle_owners (GObject *obj, const GArray *handles, GArray **ret, GError **error);
+
+void gabble_group_mixin_change_flags (GObject *obj, TpChannelGroupFlags add, TpChannelGroupFlags remove);
+gboolean gabble_group_mixin_change_members (GObject *obj, const gchar *message, GIntSet *add, GIntSet *remove, GIntSet *local_pending, GIntSet *remote_pending, GabbleHandle actor, guint reason);
+
+void gabble_group_mixin_add_handle_owner (GObject *obj, GabbleHandle local_handle, GabbleHandle owner_handle);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_GROUP_MIXIN_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/handle-set.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,53 @@
+/*
+ * handle-set.h - a set which refs a handle when inserted
+ *
+ * Copyright (C) 2005,2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __HANDLE_SET_H__
+#define __HANDLE_SET_H__
+
+#include "gintset.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleHandleSet GabbleHandleSet;
+typedef void (*GabbleHandleFunc)(GabbleHandleSet *set, GabbleHandle handle, gpointer userdata);
+
+GabbleHandleSet * handle_set_new (GabbleHandleRepo *, TpHandleType type);
+void handle_set_destroy (GabbleHandleSet *);
+
+GIntSet *handle_set_peek (GabbleHandleSet *set);
+
+void handle_set_add (GabbleHandleSet *set, GabbleHandle handle);
+gboolean handle_set_remove (GabbleHandleSet *set, GabbleHandle handle);
+gboolean handle_set_is_member (GabbleHandleSet *set, GabbleHandle handle);
+
+void handle_set_foreach (GabbleHandleSet *set, GabbleHandleFunc func, gpointer userdata);
+
+int handle_set_size (GabbleHandleSet *set);
+GArray *handle_set_to_array (GabbleHandleSet *set);
+
+GIntSet *handle_set_update (GabbleHandleSet *set, const GIntSet *add);
+GIntSet *handle_set_difference_update (GabbleHandleSet *set, const GIntSet *remove);
+
+G_END_DECLS
+
+#endif /*__HANDLE_SET_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/handles.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,70 @@
+/*
+ * handles.h - mechanism to store and retrieve handles on a connection
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __HANDLES_H__
+#define __HANDLES_H__
+
+#include <glib.h>
+
+
+#include "gabble-types.h"
+#include "telepathy-constants.h"
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ GABBLE_LIST_HANDLE_PUBLISH = 1,
+ GABBLE_LIST_HANDLE_SUBSCRIBE,
+ GABBLE_LIST_HANDLE_KNOWN,
+ GABBLE_LIST_HANDLE_DENY
+} GabbleListHandle;
+
+gboolean gabble_handle_jid_is_valid (TpHandleType type, const gchar *jid, GError **error);
+gboolean gabble_handle_type_is_valid (TpHandleType type, GError **error);
+
+GabbleHandleRepo *gabble_handle_repo_new ();
+void gabble_handle_repo_destroy (GabbleHandleRepo *repo);
+
+gboolean gabble_handle_is_valid (GabbleHandleRepo *repo, TpHandleType type, GabbleHandle handle, GError **error);
+gboolean gabble_handles_are_valid (GabbleHandleRepo *repo, TpHandleType type, const GArray *array, gboolean allow_zero, GError **error);
+
+gboolean gabble_handle_ref (GabbleHandleRepo *repo, TpHandleType type, GabbleHandle handle);
+gboolean gabble_handle_unref (GabbleHandleRepo *repo, TpHandleType type, GabbleHandle handle);
+const char *gabble_handle_inspect (GabbleHandleRepo *repo, TpHandleType type, GabbleHandle handle);
+
+GabbleHandle gabble_handle_for_contact (GabbleHandleRepo *repo, const char *jid, gboolean with_resource);
+gboolean gabble_handle_for_room_exists (GabbleHandleRepo *repo, const gchar *jid, gboolean ignore_nick);
+GabbleHandle gabble_handle_for_room (GabbleHandleRepo *repo, const gchar *jid);
+GabbleHandle gabble_handle_for_list (GabbleHandleRepo *repo, const gchar *list);
+
+gboolean gabble_handle_set_qdata (GabbleHandleRepo *repo, TpHandleType type,
+ GabbleHandle handle, GQuark key_id, gpointer data, GDestroyNotify destroy);
+
+gpointer gabble_handle_get_qdata (GabbleHandleRepo *repo, TpHandleType type,
+ GabbleHandle handle, GQuark key_id);
+
+gboolean gabble_handle_client_hold (GabbleHandleRepo *repo, const gchar *client_name, GabbleHandle handle, TpHandleType type, GError **error);
+
+gboolean gabble_handle_client_release (GabbleHandleRepo *repo, const gchar *client_name, GabbleHandle handle, TpHandleType type, GError **error);
+
+G_END_DECLS
+
+#endif /* #ifndef __HANDLES_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/im-factory.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,60 @@
+/*
+ * im-factory.h - Header for GabbleImFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __IM_FACTORY_H__
+#define __IM_FACTORY_H__
+
+#include <glib-object.h>
+
+#include "gabble-im-channel.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleImFactory GabbleImFactory;
+typedef struct _GabbleImFactoryClass GabbleImFactoryClass;
+
+struct _GabbleImFactoryClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleImFactory {
+ GObject parent;
+};
+
+IMPORT_C GType gabble_im_factory_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_IM_FACTORY \
+ (gabble_im_factory_get_type())
+#define GABBLE_IM_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_IM_FACTORY, GabbleImFactory))
+#define GABBLE_IM_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_IM_FACTORY, GabbleImFactoryClass))
+#define GABBLE_IS_IM_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_IM_FACTORY))
+#define GABBLE_IS_IM_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_IM_FACTORY))
+#define GABBLE_IM_FACTORY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_IM_FACTORY, GabbleImFactoryClass))
+
+
+G_END_DECLS
+
+#endif /* #ifndef __IM_FACTORY_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/jingle-info.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,34 @@
+/*
+ * jingle-info.h - Header for Jingle info discovery
+ * Copyright (C) 2006 Collabora Ltd.
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __JINGLE_INFO_H__
+#define __JINGLE_INFO_H__
+
+#include "gabble-connection.h"
+
+G_BEGIN_DECLS
+
+void jingle_info_discover_servers (GabbleConnection *conn);
+LmHandlerResult jingle_info_iq_callback (LmMessageHandler *handler, LmConnection *lmconn, LmMessage *message, gpointer user_data);
+
+G_END_DECLS
+
+#endif /* __JINGLE_INFO_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/libgabble_wsd_macros.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,69 @@
+/*
+ * libgabble_wsd_macros.h - Header
+ * Copyright (C) 2006 Collabora Ltd.
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _LIBGABBLEMACROS_WSD_DEFS_H_
+#define _LIBGABBLEMACROS_WSD_DEFS_H_
+
+#if (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
+#if EMULATOR
+#undef EMULATOR
+#endif
+#ifdef GET_WSD_VAR_NAME
+#undef GET_WSD_VAR_NAME
+#endif
+
+#define EMULATOR (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
+#define GET_WSD_VAR_NAME(var,filename,prefix) _##prefix##_##filename##_##var
+
+#define RETURN_WSD_VAR(var,filename,prefix) (libgabble_ImpurePtr()->GET_WSD_VAR_NAME(var,filename,prefix))
+
+#define GET_WSD_VAR_FROM_TLS(var,filename,type,prefix)\
+type *_##prefix##_##filename##_##var()\
+{\
+ return (&RETURN_WSD_VAR(var,filename,prefix));\
+}
+
+#define GET_WSD_ARRAY_FROM_TLS(var,filename,type,prefix)\
+type *_##prefix##_##filename##_##var()\
+{\
+ return (RETURN_WSD_VAR(var,filename,prefix));\
+}
+
+#define VARIABLE_DECL(var,varprefix,filename,datatype)\
+datatype GET_WSD_VAR_NAME(var,filename,varprefix);
+
+#define VARIABLE_DECL_ARRAY(var,prefix,filename,datatype,size) \
+datatype GET_WSD_VAR_NAME(var,filename,prefix)[size];
+
+#define VARIABLE_DECL_2DARRAY(var,prefix,filename,datatype,size,size1) \
+datatype GET_WSD_VAR_NAME(var,filename,prefix)[size][size1];
+
+
+#define GET_STATIC_VAR_FROM_TLS(var,filename,type) GET_WSD_VAR_FROM_TLS(var,filename,type,s)
+
+#define GET_GLOBAL_VAR_FROM_TLS(var,filename,type) GET_WSD_VAR_FROM_TLS(var,filename,type,g)
+
+#define GET_STATIC_ARRAY_FROM_TLS(var,filename,type) GET_WSD_ARRAY_FROM_TLS(var,filename,type,s)
+
+#define GET_GLOBAL_ARRAY_FROM_TLS(var,filename,type) GET_WSD_ARRAY_FROM_TLS(var,filename,type,g)
+
+#endif
+#endif //_LIBGABBLEMACROS_WSD_DEFS_H_
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/libgabble_wsd_solution.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,236 @@
+/*
+ * libgabble_wsd_solution.h - Header
+ * Copyright (C) 2006 Collabora Ltd.
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _LIBGABBLE_WSD_H
+#define _LIBGABBLE_WSD_H
+#include "libgabble_wsd_macros.h"
+//#include "debug.h"
+#include "telepathy-errors.h"
+#include "disco.h"
+#include "gabble_enums.h"
+#include "ghash.h"
+#include "gabble-presence.h"
+#include "gabble-media-session.h"
+
+#define MAX_GABBLE_UTILS_GCHAR_ARRAY_LEN 5
+
+
+#if EMULATOR
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef gboolean (*StreamHandlerFunc)(GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error);
+
+
+
+
+typedef struct _Handler Handler;
+
+struct _Handler {
+ gchar actions[3][50];
+ JingleSessionState min_allowed_state;
+ JingleSessionState max_allowed_state;
+ StreamHandlerFunc stream_handlers[4];
+ JingleSessionState new_state;
+};
+
+struct libgabble_global_struct
+{
+
+ VARIABLE_DECL(flags,s,gabble_debug,GabbleDebugFlags)
+ VARIABLE_DECL(log_handler,s,gabble_debug,guint)
+ VARIABLE_DECL(etype,s,gabble_enum_types,GType)
+
+ VARIABLE_DECL(etype,s,gabble_media_session_enum_types,GType)
+ VARIABLE_DECL(etype1,s,gabble_media_session_enum_types,GType)
+ VARIABLE_DECL(etype2,s,gabble_media_session_enum_types,GType)
+
+ VARIABLE_DECL(quark,s,gabble_disco,GQuark)
+ VARIABLE_DECL(quark,s,gabble_error,GQuark)
+
+
+ VARIABLE_DECL(ssl,s,gabble_conmgr,gboolean)
+ VARIABLE_DECL(httpport,s,gabble_conmgr,guint)
+ VARIABLE_DECL(httpproxyport,s,gabble_conmgr,guint)
+ VARIABLE_DECL_ARRAY(signals,s,gabble_conmgr,guint,LAST_SIGNAL_CON_MGR)
+ VARIABLE_DECL_ARRAY(signals,s,gabble_con,guint,LAST_SIGNAL_CON)
+ VARIABLE_DECL(arguments,s,gabble_con,GHashTable*)
+ VARIABLE_DECL_ARRAY(signals,s,gabble_im,guint,LAST_SIGNAL_IM)
+
+ //todo: later ..see what it should be in search
+ VARIABLE_DECL_ARRAY(signals,s,gabble_search,guint,LAST_SIGNAL_SEARCH)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_muc,guint,LAST_SIGNAL_MUC)
+ VARIABLE_DECL_ARRAY(signals,s,gabble_med_chnl,guint,LAST_SIGNAL_MED_CHANNEL)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_med_sess,guint,LAST_SIGNAL_MED_SESSION)
+
+
+
+
+ VARIABLE_DECL(google_audio_caps,s,gabble_med_sess,GabblePresenceCapabilities)
+ VARIABLE_DECL(jingle_audio_caps,s,gabble_med_sess,GabblePresenceCapabilities)
+ VARIABLE_DECL(jingle_video_caps,s,gabble_med_sess,GabblePresenceCapabilities)
+
+ VARIABLE_DECL_ARRAY(ret_sess,s,gabble_med_sess,gchar,MAX_STREAM_NAME_LEN)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_med_stream,guint,LAST_SIGNAL_MED_STREAM)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_pre_cache,guint,LAST_SIGNAL_PRE_CACHE)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_register,guint,LAST_SIGNAL_REGISTER)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_ros_chnl,guint,LAST_SIGNAL_ROS_CHNL)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_room_chnl,guint,LAST_SIGNAL_ROOM_CHNL)
+
+ VARIABLE_DECL(offset_quark1,s,gabble_mixin,GQuark)
+ VARIABLE_DECL(offset_quark,s,gabble_mixin,GQuark)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_roster,guint,LAST_SIGNAL_ROSTER)
+
+ VARIABLE_DECL(quark,s,gabble_errors,GQuark)
+
+ VARIABLE_DECL(busCon,s,gabble_helpers,DBusGConnection*)
+ VARIABLE_DECL(bus_proxy,s,gabble_helpers,DBusGProxy*)
+
+ VARIABLE_DECL(offset_quark1,s,gabble_txt_mixin,GQuark)
+ VARIABLE_DECL(offset_quark,s,gabble_txt_mixin,GQuark)
+ VARIABLE_DECL(alloc1,s,gabble_txt_mixin,GabbleAllocator)
+
+ VARIABLE_DECL(offset_quark1,s,gabble_search_mixin,GQuark)
+ VARIABLE_DECL(offset_quark,s,gabble_search_mixin,GQuark)
+ //todo: check if this required for search
+ VARIABLE_DECL(alloc1,s,gabble_search_mixin,GabbleAllocator)
+
+ VARIABLE_DECL(type,s,gabble_chnl_iface,GType)
+ VARIABLE_DECL(initialized,s,gabble_chnl_iface,gboolean)
+
+ VARIABLE_DECL(type,s,gabble_fac_iface,GType)
+ VARIABLE_DECL(initialized,s,gabble_fac_iface,gboolean)
+
+ VARIABLE_DECL_ARRAY(signals,s,gabble_vcard_mgr,guint,LAST_SIGNAL_VCARD_MGR)
+ VARIABLE_DECL(quark1,s,gabble_vcard_mgr,GQuark)
+ VARIABLE_DECL(quark2,s,gabble_vcard_mgr,GQuark)
+
+
+ VARIABLE_DECL(offset_quark1,s,gabble_grp_mixin,GQuark)
+ VARIABLE_DECL(offset_quark,s,gabble_grp_mixin,GQuark)
+
+
+ VARIABLE_DECL(gabble_disco_parent_class,s,gabble_disco,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_disco,GType)
+
+ VARIABLE_DECL(gabble_connection_manager_parent_class,s,gabble_conmgr,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_conmgr,GType)
+
+ VARIABLE_DECL(gabble_connection_parent_class,s,gabble_con,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_con,GType)
+
+ VARIABLE_DECL(gabble_im_channel_parent_class,s,gabble_im,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_im,GType)
+
+ VARIABLE_DECL(gabble_search_channel_parent_class,s,gabble_search,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_search,GType)
+
+ VARIABLE_DECL(gabble_muc_channel_parent_class,s,gabble_muc,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_muc,GType)
+
+ VARIABLE_DECL(gabble_media_channel_parent_class,s,gabble_med_chnl,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_med_chnl,GType)
+
+ VARIABLE_DECL(gabble_media_stream_parent_class,s,gabble_med_stream,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_med_stream,GType)
+
+ VARIABLE_DECL(gabble_presence_parent_class,s,gabble_presence,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_presence,GType)
+
+ VARIABLE_DECL(gabble_presence_cache_parent_class,s,gabble_pre_cache,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_pre_cache,GType)
+
+ VARIABLE_DECL(gabble_register_parent_class,s,gabble_register,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_register,GType)
+
+ VARIABLE_DECL(gabble_roster_channel_parent_class,s,gabble_ros_chnl,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_ros_chnl,GType)
+
+ VARIABLE_DECL(gabble_roomlist_channel_parent_class,s,gabble_room_chnl,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_room_chnl,GType)
+
+ VARIABLE_DECL(gabble_im_factory_parent_class ,s,im_factory,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,im_factory,GType)
+
+ VARIABLE_DECL(gabble_search_factory_parent_class ,s,search_factory,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,search_factory,GType)
+
+ VARIABLE_DECL(gabble_media_factory_parent_class ,s,media_factory,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,media_factory,GType)
+
+ VARIABLE_DECL(gabble_muc_factory_parent_class ,s,muc_factory,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,muc_factory,GType)
+
+ VARIABLE_DECL(gabble_vcard_manager_parent_class ,s,gabble_vcard_mgr,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_vcard_mgr,GType)
+
+ VARIABLE_DECL_ARRAY(keys,s,gabble_debug,GDebugKey,12)
+
+ VARIABLE_DECL_ARRAY(NO_ALIAS,s,gabble_vcard_mgr,gchar,MAX_GABBLE_UTILS_GCHAR_ARRAY_LEN)
+
+
+ VARIABLE_DECL_2DARRAY(assumed_caps,s,gabble_con,gchar,3,150)
+
+ VARIABLE_DECL_2DARRAY(muc_roles,s,gabble_muc,gchar,4,20)
+ VARIABLE_DECL_2DARRAY(muc_affiliations,s,gabble_muc,gchar,4,20)
+
+ VARIABLE_DECL_2DARRAY(video_codec_params,s,gabble_med_stream,gchar,6,20)
+
+ VARIABLE_DECL_2DARRAY(list_handle_strings,s,handles,char,4,20)
+
+ VARIABLE_DECL_ARRAY(handlers,s,gabble_med_sess,Handler,10)
+
+ VARIABLE_DECL(gabble_media_session_parent_class ,s,gabble_med_sess,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_med_sess,GType)
+
+ VARIABLE_DECL(gabble_roster_parent_class ,s,gabble_roster,gpointer)
+ VARIABLE_DECL(g_define_type_id,s,gabble_roster,GType)
+
+
+ /*END-global vars*/
+
+ };
+
+struct libgabble_global_struct * libgabble_ImpurePtr();
+int libgabble_Init(struct libgabble_global_struct *);
+#ifdef __cplusplus
+}
+#endif
+#endif //EMULATOR
+#endif //header guard ifdef _LIBGABBLE_WSD_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/media-factory.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,63 @@
+/*
+ * media-factory.h - Header for GabbleMediaFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __MEDIA_FACTORY_H__
+#define __MEDIA_FACTORY_H__
+
+#include <glib-object.h>
+
+#include "gabble-media-channel.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleMediaFactory GabbleMediaFactory;
+typedef struct _GabbleMediaFactoryClass GabbleMediaFactoryClass;
+
+struct _GabbleMediaFactoryClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleMediaFactory {
+ GObject parent;
+};
+
+IMPORT_C GType gabble_media_factory_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_MEDIA_FACTORY \
+ (gabble_media_factory_get_type())
+#define GABBLE_MEDIA_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MEDIA_FACTORY, GabbleMediaFactory))
+#define GABBLE_MEDIA_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MEDIA_FACTORY, GabbleMediaFactoryClass))
+#define GABBLE_IS_MEDIA_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MEDIA_FACTORY))
+#define GABBLE_IS_MEDIA_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MEDIA_FACTORY))
+#define GABBLE_MEDIA_FACTORY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MEDIA_FACTORY, GabbleMediaFactoryClass))
+
+const gchar * _gabble_media_factory_allocate_sid (GabbleMediaFactory *fac, GabbleMediaChannel *chan);
+const gchar * _gabble_media_factory_register_sid (GabbleMediaFactory *fac, const gchar *sid, GabbleMediaChannel *chan);
+void _gabble_media_factory_free_sid (GabbleMediaFactory *fac, const gchar *sid);
+
+G_END_DECLS
+
+#endif /* #ifndef __MEDIA_FACTORY_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/muc-factory.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,56 @@
+/*
+ * muc-factory.h - Header for GabbleMucFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __MUC_FACTORY_H__
+#define __MUC_FACTORY_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleMucFactory GabbleMucFactory;
+typedef struct _GabbleMucFactoryClass GabbleMucFactoryClass;
+
+struct _GabbleMucFactoryClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleMucFactory {
+ GObject parent;
+};
+
+IMPORT_C GType gabble_muc_factory_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_MUC_FACTORY \
+ (gabble_muc_factory_get_type())
+#define GABBLE_MUC_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MUC_FACTORY, GabbleMucFactory))
+#define GABBLE_MUC_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MUC_FACTORY, GabbleMucFactoryClass))
+#define GABBLE_IS_MUC_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MUC_FACTORY))
+#define GABBLE_IS_MUC_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MUC_FACTORY))
+#define GABBLE_MUC_FACTORY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MUC_FACTORY, GabbleMucFactoryClass))
+
+G_END_DECLS
+
+#endif /* #ifndef __MUC_FACTORY_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/namespaces.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,59 @@
+/*
+ * namespaces.h - XMPP namespace constants
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_NAMESPACES__H__
+#define __GABBLE_NAMESPACES__H__
+
+#define NS_CAPS "http://jabber.org/protocol/caps"
+#define NS_DISCO_INFO "http://jabber.org/protocol/disco#info"
+#define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items"
+#define NS_GABBLE_CAPS "http://telepathy.freedesktop.org/caps"
+#define NS_GOOGLE_CAPS "http://www.google.com/xmpp/client/caps"
+#define NS_GOOGLE_FEAT_SESSION "http://www.google.com/xmpp/protocol/session"
+#define NS_GOOGLE_FEAT_VOICE "http://www.google.com/xmpp/protocol/voice/v1"
+#define NS_GOOGLE_JINGLE_INFO "google:jingleinfo"
+#define NS_GOOGLE_ROSTER "google:roster"
+#define NS_GOOGLE_SESSION "http://www.google.com/session"
+#define NS_GOOGLE_SESSION_PHONE "http://www.google.com/session/phone"
+#define NS_GOOGLE_TRANSPORT_P2P "http://www.google.com/transport/p2p"
+#define NS_JINGLE "http://jabber.org/protocol/jingle"
+#define NS_JINGLE_DESCRIPTION_AUDIO "http://jabber.org/protocol/jingle/description/audio"
+#define NS_JINGLE_DESCRIPTION_VIDEO "http://jabber.org/protocol/jingle/description/video"
+#define NS_JINGLE_ERRORS "http://jabber.org/protocol/jingle#errors"
+#define NS_JINGLE_TRANSPORT_ICE "http://jabber.org/protocol/jingle/transport/ice"
+#define NS_MUC "http://jabber.org/protocol/muc"
+#define NS_MUC_USER "http://jabber.org/protocol/muc#user"
+#define NS_MUC_ADMIN "http://jabber.org/protocol/muc#admin"
+#define NS_MUC_OWNER "http://jabber.org/protocol/muc#owner"
+#define NS_NICK "http://jabber.org/protocol/nick"
+#define NS_PRESENCE_INVISIBLE "presence-invisible"
+#define NS_PRIVACY "jabber:iq:privacy"
+#define NS_REGISTER "jabber:iq:register"
+#define NS_ROSTER "jabber:iq:roster"
+#define NS_VCARD_TEMP "vcard-temp"
+#define NS_X_DATA "jabber:x:data"
+#define NS_X_DELAY "jabber:x:delay"
+#define NS_X_CONFERENCE "jabber:x:conference"
+#define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas"
+#define NS_SEARCH "jabber:iq:search"
+#define NS_VCARD_TEMP "vcard-temp"
+#define NS_VCARD_TEMP_UPDATE "vcard-temp:x:update"
+
+#endif /* __GABBLE_NAMESPACES__H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/properties-mixin-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,30 @@
+/*
+ * properties-mixin-signals-marshal.h - Headers for Gabble roster helper
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __properties_mixin_marshal_MARSHAL_H__
+#define __properties_mixin_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif /* __properties_mixin_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/properties-mixin.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,135 @@
+/*
+ * properties-mixin.h - Header for GabblePropertiesMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_PROPERTIES_MIXIN_H__
+#define __GABBLE_PROPERTIES_MIXIN_H__
+
+#include "handles.h"
+#include "handle-set.h"
+#include "util.h"
+
+G_BEGIN_DECLS
+
+struct _GabblePropertySignature {
+ gchar *name;
+ GType type;
+};
+
+typedef struct _GabblePropertySignature GabblePropertySignature;
+
+struct _GabbleProperty {
+ GValue *value;
+ guint flags;
+};
+
+typedef struct _GabbleProperty GabbleProperty;
+
+typedef struct _GabblePropertiesContext GabblePropertiesContext;
+typedef gboolean (*GabblePropertiesSetFunc) (GObject *obj, GabblePropertiesContext *ctx, GError **error);
+
+struct _GabblePropertiesMixinClass {
+ const GabblePropertySignature *signatures;
+ guint num_props;
+
+ GabblePropertiesSetFunc set_properties;
+
+ guint property_flags_changed_signal_id;
+ guint properties_changed_signal_id;
+};
+
+typedef struct _GabblePropertiesMixinClass GabblePropertiesMixinClass;
+
+typedef struct _GabblePropertiesMixinPrivate GabblePropertiesMixinPrivate;
+
+struct _GabblePropertiesMixin {
+ GabbleProperty *properties;
+
+ GabblePropertiesMixinPrivate *priv;
+};
+
+typedef struct _GabblePropertiesMixin GabblePropertiesMixin;
+
+/* TYPE MACROS */
+#define GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK (gabble_properties_mixin_class_get_offset_quark())
+#define GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK)))
+#define GABBLE_PROPERTIES_MIXIN_CLASS(o) ((GabblePropertiesMixinClass *) gabble_mixin_offset_cast (o, GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET (o)))
+
+#define GABBLE_PROPERTIES_MIXIN_OFFSET_QUARK (gabble_properties_mixin_get_offset_quark())
+#define GABBLE_PROPERTIES_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), GABBLE_PROPERTIES_MIXIN_OFFSET_QUARK)))
+#define GABBLE_PROPERTIES_MIXIN(o) ((GabblePropertiesMixin *) gabble_mixin_offset_cast (o, GABBLE_PROPERTIES_MIXIN_OFFSET (o)))
+
+#define TP_TYPE_PROPERTY_INFO_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_STRING, \
+ G_TYPE_UINT, \
+ G_TYPE_INVALID))
+#define TP_TYPE_PROPERTY_INFO_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_PROPERTY_INFO_STRUCT))
+
+#define TP_TYPE_PROPERTY_VALUE_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_VALUE, \
+ G_TYPE_INVALID))
+#define TP_TYPE_PROPERTY_VALUE_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_PROPERTY_VALUE_STRUCT))
+
+#define TP_TYPE_PROPERTY_FLAGS_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_INVALID))
+#define TP_TYPE_PROPERTY_FLAGS_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_PROPERTY_FLAGS_STRUCT))
+
+GQuark gabble_properties_mixin_class_get_offset_quark (void);
+GQuark gabble_properties_mixin_get_offset_quark (void);
+
+void gabble_properties_mixin_class_init (GObjectClass *obj_cls, glong offset, const GabblePropertySignature *signatures, guint num_properties, GabblePropertiesSetFunc set_func);
+
+void gabble_properties_mixin_init (GObject *obj, glong offset);
+void gabble_properties_mixin_finalize (GObject *obj);
+
+gboolean gabble_properties_mixin_list_properties (GObject *obj, GPtrArray **ret, GError **error);
+gboolean gabble_properties_mixin_get_properties (GObject *obj, const GArray *properties, GPtrArray **ret, GError **error);
+void gabble_properties_mixin_set_properties (GObject *obj, const GPtrArray *properties, DBusGMethodInvocation *context);
+
+gboolean gabble_properties_mixin_has_property (GObject *obj, const gchar *name, guint *property);
+
+gboolean gabble_properties_context_has (GabblePropertiesContext *ctx, guint property);
+gboolean gabble_properties_context_has_other_than (GabblePropertiesContext *ctx, guint property);
+const GValue *gabble_properties_context_get (GabblePropertiesContext *ctx, guint property);
+guint gabble_properties_context_get_value_count (GabblePropertiesContext *ctx);
+void gabble_properties_context_remove (GabblePropertiesContext *ctx, guint property);
+void gabble_properties_context_return (GabblePropertiesContext *ctx, GError *error);
+gboolean gabble_properties_context_return_if_done (GabblePropertiesContext *ctx);
+
+void gabble_properties_mixin_change_value (GObject *obj, guint prop_id, const GValue *new_value, GArray **props);
+void gabble_properties_mixin_change_flags (GObject *obj, guint prop_id, TpPropertyFlags add, TpPropertyFlags remove, GArray **props);
+void gabble_properties_mixin_emit_changed (GObject *obj, GArray **props);
+void gabble_properties_mixin_emit_flags (GObject *obj, GArray **props);
+
+gboolean gabble_properties_mixin_is_readable (GObject *obj, guint prop_id);
+gboolean gabble_properties_mixin_is_writable (GObject *obj, guint prop_id);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_PROPERTIES_MIXIN_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/roster.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,80 @@
+/*
+ * roster.h - Headers for Gabble roster helper
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __ROSTER_H__
+#define __ROSTER_H__
+
+#include <glib-object.h>
+
+#include "gabble-types.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleRosterClass GabbleRosterClass;
+
+IMPORT_C GType gabble_roster_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_ROSTER \
+ (gabble_roster_get_type())
+#define GABBLE_ROSTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_ROSTER, GabbleRoster))
+#define GABBLE_ROSTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_ROSTER, GabbleRosterClass))
+#define GABBLE_IS_ROSTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_ROSTER))
+#define GABBLE_IS_ROSTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_ROSTER))
+#define GABBLE_ROSTER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_ROSTER, GabbleRosterClass))
+
+struct _GabbleRosterClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleRoster {
+ GObject parent;
+ gpointer priv;
+};
+
+typedef enum
+{
+ GABBLE_ROSTER_SUBSCRIPTION_NONE = 0,
+ GABBLE_ROSTER_SUBSCRIPTION_FROM = 1 << 0,
+ GABBLE_ROSTER_SUBSCRIPTION_TO = 1 << 1,
+ GABBLE_ROSTER_SUBSCRIPTION_BOTH = GABBLE_ROSTER_SUBSCRIPTION_FROM |
+ GABBLE_ROSTER_SUBSCRIPTION_TO,
+ GABBLE_ROSTER_SUBSCRIPTION_REMOVE = 1 << 2,
+} GabbleRosterSubscription;
+
+GabbleRoster *gabble_roster_new (GabbleConnection *);
+
+GabbleRosterSubscription gabble_roster_handle_get_subscription (GabbleRoster *, GabbleHandle);
+gboolean gabble_roster_handle_set_blocked (GabbleRoster *, GabbleHandle, gboolean, GError **);
+const gchar *gabble_roster_handle_get_name (GabbleRoster *, GabbleHandle);
+gboolean gabble_roster_handle_set_name (GabbleRoster *, GabbleHandle, const gchar *, GError **);
+gboolean gabble_roster_handle_remove (GabbleRoster *, GabbleHandle, GError **);
+gboolean gabble_roster_handle_add (GabbleRoster *, GabbleHandle, GError **);
+gboolean gabble_roster_handle_has_entry (GabbleRoster *, GabbleHandle);
+
+G_END_DECLS
+
+#endif /* __ROSTER_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/search-factory.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,60 @@
+/*
+ * search-factory.h - Header for GabbleSearchFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SEARCH_FACTORY_H__
+#define __SEARCH_FACTORY_H__
+
+#include <glib-object.h>
+
+#include "gabble-search-channel.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleSearchFactory GabbleSearchFactory;
+typedef struct _GabbleSearchFactoryClass GabbleSearchFactoryClass;
+
+struct _GabbleSearchFactoryClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleSearchFactory {
+ GObject parent;
+};
+
+IMPORT_C GType gabble_search_factory_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_SEARCH_FACTORY \
+ (gabble_search_factory_get_type())
+#define GABBLE_SEARCH_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_SEARCH_FACTORY, GabbleSearchFactory))
+#define GABBLE_SEARCH_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_SEARCH_FACTORY, GabbleSearchFactoryClass))
+#define GABBLE_IS_SEARCH_FACTORY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_SEARCH_FACTORY))
+#define GABBLE_IS_SEARCH_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_SEARCH_FACTORY))
+#define GABBLE_SEARCH_FACTORY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_SEARCH_FACTORY, GabbleSearchFactoryClass))
+
+
+G_END_DECLS
+
+#endif /* #ifndef __IM_FACTORY_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/search-keys-info.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,36 @@
+/*
+ * search-keys-info.h - Header for Search Keys and reported fields
+ * Copyright (C) 2008 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SEARCH_KEYS_INFO_H__
+#define __SEARCH_KEYS_INFO_H__
+
+#include "gabble-connection.h"
+
+G_BEGIN_DECLS
+
+void search_keys_info_discover (GabbleConnection *conn);
+gboolean _gabble_submit_search_form (GabbleConnection *conn);
+LmHandlerResult search_keys_iq_cb (LmMessageHandler *handler, LmConnection *lmconn, LmMessage *message, gpointer user_data);
+void
+get_search_keys_info (GabbleConnection *conn, const gchar *jid );
+
+G_END_DECLS
+
+#endif /* __SEARCH_KEYS_INFO_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/search-mixin-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * search-mixin-signals-marshal.h - Headers for Telepathy Channel Factory interface
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __search_mixin_marshal_MARSHAL_H__
+#define __search_mixin_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,UINT,UINT,UINT,UINT,STRING (search-mixin-signals-marshal.list:1) */
+extern void search_mixin_marshal_VOID__UINT_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+
+
+
+G_END_DECLS
+
+#endif /* __search_mixin_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/search-mixin.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,98 @@
+/*
+ * text-mixin.h - Header for GabbleSearchMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_SEARCH_MIXIN_H__
+#define __GABBLE_SEARCH_MIXIN_H__
+
+#include "handles.h"
+#include "handle-set.h"
+#include "util.h"
+
+
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleSearchMixinClass GabbleSearchMixinClass;
+typedef struct _GabbleSearchMixin GabbleSearchMixin;
+
+struct _GabbleSearchMixinClass {
+ guint search_result_received_signal_id;
+ guint search_state_changed_signal_id;
+};
+
+struct _GabbleSearchMixin {
+
+ //todo: any data if required
+ guint search_state;
+
+};
+
+GType gabble_search_mixin_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_SEARCH_MIXIN_CLASS_OFFSET_QUARK (gabble_search_mixin_class_get_offset_quark())
+#define GABBLE_SEARCH_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), GABBLE_SEARCH_MIXIN_CLASS_OFFSET_QUARK)))
+#define GABBLE_SEARCH_MIXIN_CLASS(o) ((GabbleSearchMixinClass *) gabble_mixin_offset_cast (o, GABBLE_SEARCH_MIXIN_CLASS_OFFSET (o)))
+
+#define GABBLE_SEARCH_MIXIN_OFFSET_QUARK (gabble_search_mixin_get_offset_quark())
+#define GABBLE_SEARCH_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), GABBLE_SEARCH_MIXIN_OFFSET_QUARK)))
+#define GABBLE_SEARCH_MIXIN(o) ((GabbleSearchMixin *) gabble_mixin_offset_cast (o, GABBLE_SEARCH_MIXIN_OFFSET (o)))
+
+GQuark gabble_search_mixin_class_get_offset_quark (void);
+GQuark gabble_search_mixin_get_offset_quark (void);
+
+void gabble_search_mixin_class_init (GObjectClass *obj_cls, glong offset);
+void gabble_search_mixin_init (GObject *obj, glong offset );
+
+void gabble_search_mixin_finalize (GObject *obj);
+
+gboolean gabble_search_mixin_search (GObject *obj,GHashTable *params,
+ GabbleConnection *conn,
+ GError **error);
+
+gboolean gabble_search_mixin_get_search_state ( GObject *obj, guint *ret,
+ GError **error );
+
+void
+_gabble_search_mixin_emit_search_result_received (GObject *obj,
+ guint contact_handle,
+ GHashTable *values );
+
+void
+_gabble_search_mixin_emit_search_state_changed (GObject *obj,
+ guint search_state );
+
+
+void
+_gabble_search_mixin_set_search_state (GObject *obj, guint state );
+
+gboolean
+gabble_search_mixin_get_search_keys ( GObject *obj,
+ gchar **ret_instruction,
+ gchar ***ret_searchkeys,
+ GabbleConnection *conn,
+ GError **error
+ );
+
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_SEARCH_MIXIN_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/sha1.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: sha1.h 347 2003-02-23 22:11:49Z asaddi $
+ */
+
+#ifndef _SHA1_H
+#define _SHA1_H
+
+# include <inttypes.h>
+
+#define SHA1_HASH_SIZE 20
+
+/* Hash size in 32-bit words */
+#define SHA1_HASH_WORDS 5
+
+struct _SHA1Context {
+ uint64_t totalLength;
+ uint32_t hash[SHA1_HASH_WORDS];
+ uint32_t bufferLength;
+ union {
+ uint32_t words[16];
+ uint8_t bytes[64];
+ } buffer;
+#ifdef RUNTIME_ENDIAN
+ int littleEndian;
+#endif /* RUNTIME_ENDIAN */
+};
+
+typedef struct _SHA1Context SHA1Context;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void SHA1Init (SHA1Context *sc);
+void SHA1Update (SHA1Context *sc, const void *data, uint32_t len);
+void SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SHA1_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/telepathy-constants.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,189 @@
+/*
+ * telepathy-constants.h - constants used in telepathy
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_CONSTANTS_H__
+#define __TELEPATHY_CONSTANTS_H__
+
+#include <glib.h>
+G_BEGIN_DECLS
+
+typedef enum {
+TP_CHANNEL_GROUP_CHANGE_REASON_NONE = 0,
+TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE = 1,
+TP_CHANNEL_GROUP_CHANGE_REASON_KICKED = 2,
+TP_CHANNEL_GROUP_CHANGE_REASON_BUSY = 3,
+TP_CHANNEL_GROUP_CHANGE_REASON_INVITED = 4,
+TP_CHANNEL_GROUP_CHANGE_REASON_BANNED = 5,
+TP_CHANNEL_GROUP_CHANGE_REASON_ERROR = 6,
+} TpChannelGroupChangeReason;
+
+typedef enum {
+TP_CHANNEL_MEDIA_CAPABILITY_AUDIO = 1,
+TP_CHANNEL_MEDIA_CAPABILITY_VIDEO = 2
+} TpChannelMediaCapabilities;
+
+typedef enum {
+TP_CONN_ALIAS_FLAG_USER_SET = 1
+} TpConnAliasFlags;
+
+typedef enum {
+TP_CONN_CAPABILITY_FLAG_CREATE = 1,
+TP_CONN_CAPABILITY_FLAG_INVITE = 2
+} TpConnectionCapabilityFlags;
+
+typedef enum {
+TP_HANDLE_TYPE_NONE = 0,
+TP_HANDLE_TYPE_CONTACT = 1,
+TP_HANDLE_TYPE_ROOM = 2,
+TP_HANDLE_TYPE_LIST = 3
+} TpHandleType;
+
+typedef enum {
+TP_CONN_MGR_PARAM_FLAG_REQUIRED = 1,
+TP_CONN_MGR_PARAM_FLAG_REGISTER = 2,
+TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT = 4
+} TpConnectionManagerParamFlags;
+
+typedef enum {
+TP_CONN_PRESENCE_TYPE_UNSET = 0,
+TP_CONN_PRESENCE_TYPE_OFFLINE = 1,
+TP_CONN_PRESENCE_TYPE_AVAILABLE = 2,
+TP_CONN_PRESENCE_TYPE_AWAY = 3,
+TP_CONN_PRESENCE_TYPE_EXTENDED_AWAY = 4,
+TP_CONN_PRESENCE_TYPE_HIDDEN = 5
+} TpConnectionPresenceType;
+
+typedef enum {
+TP_CONN_STATUS_CONNECTED = 0,
+TP_CONN_STATUS_CONNECTING = 1,
+TP_CONN_STATUS_DISCONNECTED = 2,
+TP_CONN_STATUS_NEW = 10000
+} TpConnectionStatus;
+
+typedef enum {
+TP_CONN_STATUS_REASON_NONE_SPECIFIED = 0,
+TP_CONN_STATUS_REASON_REQUESTED = 1,
+TP_CONN_STATUS_REASON_NETWORK_ERROR = 2,
+TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED = 3,
+TP_CONN_STATUS_REASON_ENCRYPTION_ERROR = 4,
+TP_CONN_STATUS_REASON_NAME_IN_USE = 5,
+TP_CONN_STATUS_REASON_CERT_NOT_PROVIDED = 6,
+TP_CONN_STATUS_REASON_CERT_UNTRUSTED = 7,
+TP_CONN_STATUS_REASON_CERT_EXPIRED = 8,
+TP_CONN_STATUS_REASON_CERT_NOT_ACTIVATED = 9,
+TP_CONN_STATUS_REASON_CERT_HOSTNAME_MISMATCH = 10,
+TP_CONN_STATUS_REASON_CERT_FINGERPRINT_MISMATCH = 11,
+TP_CONN_STATUS_REASON_CERT_SELF_SIGNED = 12,
+TP_CONN_STATUS_REASON_CERT_OTHER_ERROR = 13
+} TpConnectionStatusReason;
+
+typedef enum {
+TP_CHANNEL_CONTACT_SEARCH_STATE_BEFORE = 0,
+TP_CHANNEL_CONTACT_SEARCH_STATE_DURING = 1,
+TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER = 2
+} TpChannelContactSearchState;
+
+typedef enum {
+TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL = 0,
+TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION = 1,
+TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE = 2
+} TpChannelTextMessageType;
+
+typedef enum {
+TP_CHANNEL_GROUP_FLAG_CAN_ADD = 1,
+TP_CHANNEL_GROUP_FLAG_CAN_REMOVE = 2,
+TP_CHANNEL_GROUP_FLAG_CAN_RESCIND = 4,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD = 8,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE = 16,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_ACCEPT = 32,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_REJECT = 64,
+TP_CHANNEL_GROUP_FLAG_MESSAGE_RESCIND = 128,
+TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES = 256,
+} TpChannelGroupFlags;
+
+typedef enum {
+TP_CHANNEL_HOLD_STATE_NONE = 0,
+TP_CHANNEL_HOLD_STATE_SEND_ONLY = 1,
+TP_CHANNEL_HOLD_STATE_RECV_ONLY = 2,
+TP_CHANNEL_HOLD_STATE_BOTH = 3
+} TpChannelHoldState;
+
+typedef enum {
+TP_CHANNEL_PASSWORD_FLAG_PROVIDE = 8
+} TpChannelPasswordFlags;
+
+typedef enum {
+TP_CHANNEL_TEXT_MESSAGE_FLAG_TRUNCATED = 1
+} TpChannelTextMessageFlags;
+
+typedef enum {
+TP_MEDIA_STREAM_TYPE_AUDIO = 0,
+TP_MEDIA_STREAM_TYPE_VIDEO = 1
+} TpMediaStreamType;
+
+typedef enum {
+TP_MEDIA_STREAM_DIRECTION_NONE = 0,
+TP_MEDIA_STREAM_DIRECTION_SEND = 1,
+TP_MEDIA_STREAM_DIRECTION_RECEIVE = 2,
+TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3
+} TpMediaStreamDirection;
+
+typedef enum {
+TP_MEDIA_STREAM_PENDING_NONE = 0,
+TP_MEDIA_STREAM_PENDING_LOCAL_SEND = 1,
+TP_MEDIA_STREAM_PENDING_REMOTE_SEND = 2
+} TpMediaStreamPendingSend;
+
+typedef enum {
+TP_MEDIA_STREAM_ERROR_UNKNOWN = 0,
+TP_MEDIA_STREAM_ERROR_EOS = 1
+} TpMediaStreamError;
+
+typedef enum {
+TP_MEDIA_STREAM_PROTO_UDP = 0,
+TP_MEDIA_STREAM_PROTO_TCP = 1
+} TpMediaStreamProto;
+
+typedef enum {
+TP_MEDIA_STREAM_TRANSPORT_TYPE_LOCAL = 0,
+TP_MEDIA_STREAM_TRANSPORT_TYPE_DERIVED = 1,
+TP_MEDIA_STREAM_TRANSPORT_TYPE_RELAY = 2
+} TpMediaStreamTransportType;
+
+typedef enum {
+TP_CODEC_MEDIA_TYPE_AUDIO = 0,
+TP_CODEC_MEDIA_TYPE_VIDEO = 1,
+} TpCodecMediaType;
+
+typedef enum {
+TP_MEDIA_STREAM_STATE_DISCONNECTED = 0,
+TP_MEDIA_STREAM_STATE_CONNECTING = 1,
+TP_MEDIA_STREAM_STATE_CONNECTED = 2
+} TpMediaStreamState;
+
+typedef enum {
+TP_PROPERTY_FLAG_READ = 1,
+TP_PROPERTY_FLAG_WRITE = 2
+} TpPropertyFlags;
+
+G_END_DECLS
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/telepathy-errors-enumtypes.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,42 @@
+/*
+ * telepathy-errors-enumtypes.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+
+ */
+/* Generated data (by glib-mkenums) */
+
+#ifndef __TELEPATHY_ERRORS_ENUM_TYPES_H__
+#define __TELEPATHY_ERRORS_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/* enumerations from "telepathy-errors.h" */
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GType telepathy_errors_get_type (void);
+#define TELEPATHY_TYPE_ERRORS (telepathy_errors_get_type())
+G_END_DECLS
+
+#endif /* __TELEPATHY_ERRORS_ENUM_TYPES_H__ */
+
+/* Generated data ends here */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/telepathy-errors.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,68 @@
+/*
+ * telepathy-errors.h - Header for Telepathy error types
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_ERRORS_H__
+#define __TELEPATHY_ERRORS_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ ChannelBanned, /** You are banned from the channel.
+ */
+ ChannelFull, /** The channel is full.
+ */
+ ChannelInviteOnly, /** The requested channel is invite only.
+ */
+ Disconnected, /** The connection is not currently connected and cannot
+ * be used.
+ */
+ InvalidArgument, /** Raised when one of the provided arguments is invalid.
+ */
+ InvalidHandle, /** The contact name specified is unknown on this channel
+ * or connection.
+ */
+ NetworkError, /** Raised when there is an error reading from or writing
+ * to the network.
+ */
+ NotAvailable, /** Raised when the requested functionality is temporarily
+ * unavailable.
+ */
+ NotImplemented, /** Raised when the requested method, channel, etc is not
+ * available on this connection.
+ */
+ PermissionDenied, /** The user is not permitted to perform the requested
+ * operation.
+ */
+ MemoryFull /** Not able to allocate more memory
+ */
+} TelepathyErrors;
+
+#ifdef SYMBIAN
+IMPORT_C
+#endif
+GQuark telepathy_errors_quark (void);
+#define TELEPATHY_ERRORS telepathy_errors_quark ()
+
+G_END_DECLS
+
+#endif /* #ifndef __TELEPATHY_ERRORS_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/telepathy-helpers.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * telepathy-helpers.h - Header for various helper functions
+ * for telepathy implementation
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_HELPERS_H__
+#define __TELEPATHY_HELPERS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+ gpointer key;
+ gpointer value;
+} TpKeyValue;
+
+DBusGConnection * tp_get_bus ();
+DBusGProxy * tp_get_bus_proxy ();
+GSList *tp_hash_to_key_value_list (GHashTable *hash);
+void tp_key_value_list_free (GSList *list);
+
+G_END_DECLS
+
+#endif /* __TELEPATHY_HELPERS_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/telepathy-interfaces.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,81 @@
+/*
+ * telepathy-interfaces.h - Header for Telepathy interface names
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TELEPATHY_INTERFACES_H__
+#define __TELEPATHY_INTERFACES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TP_IFACE_CHANNEL_INTERFACE \
+ "org.freedesktop.Telepathy.Channel"
+#define TP_IFACE_CHANNEL_INTERFACE_DTMF \
+ "org.freedesktop.Telepathy.Channel.Interface.DTMF"
+#define TP_IFACE_CHANNEL_INTERFACE_GROUP \
+ "org.freedesktop.Telepathy.Channel.Interface.Group"
+#define TP_IFACE_CHANNEL_INTERFACE_HOLD \
+ "org.freedesktop.Telepathy.Channel.Interface.Hold"
+#define TP_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING \
+ "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling"
+#define TP_IFACE_CHANNEL_INTERFACE_PASSWORD \
+ "org.freedesktop.Telepathy.Channel.Interface.Password"
+#define TP_IFACE_CHANNEL_INTERFACE_TRANSFER \
+ "org.freedesktop.Telepathy.Channel.Interface.Transfer"
+#define TP_IFACE_CHANNEL_TYPE_CONTACT_LIST \
+ "org.freedesktop.Telepathy.Channel.Type.ContactList"
+#define TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH \
+ "org.freedesktop.Telepathy.Channel.Type.ContactSearch"
+#define TP_IFACE_CHANNEL_TYPE_ROOM_LIST \
+ "org.freedesktop.Telepathy.Channel.Type.RoomList"
+#define TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA \
+ "org.freedesktop.Telepathy.Channel.Type.StreamedMedia"
+#define TP_IFACE_CHANNEL_TYPE_TEXT \
+ "org.freedesktop.Telepathy.Channel.Type.Text"
+#define TP_IFACE_CONN_INTERFACE \
+ "org.freedesktop.Telepathy.Connection"
+#define TP_IFACE_CONN_INTERFACE_ALIASING \
+ "org.freedesktop.Telepathy.Connection.Interface.Aliasing"
+#define TP_IFACE_CONN_INTERFACE_CAPABILITIES \
+ "org.freedesktop.Telepathy.Connection.Interface.Capabilities"
+#define TP_IFACE_CONN_INTERFACE_CONTACT_INFO \
+ "org.freedesktop.Telepathy.Connection.Interface.ContactInfo"
+#define TP_IFACE_CONN_INTERFACE_FORWARDING \
+ "org.freedesktop.Telepathy.Connection.Interface.Forwarding"
+#define TP_IFACE_CONN_INTERFACE_PRESENCE \
+ "org.freedesktop.Telepathy.Connection.Interface.Presence"
+#define TP_IFACE_CONN_INTERFACE_PRIVACY \
+ "org.freedesktop.Telepathy.Connection.Interface.Privacy"
+#define TP_IFACE_CONN_INTERFACE_RENAMING \
+ "org.freedesktop.Telepathy.Connection.Interface.Renaming"
+#define TP_IFACE_CONN_MGR_INTERFACE \
+ "org.freedesktop.Telepathy.ConnectionManager"
+#define TP_IFACE_MEDIA_SESSION_HANDLER \
+ "org.freedesktop.Telepathy.Media.SessionHandler"
+#define TP_IFACE_MEDIA_STREAM_HANDLER \
+ "org.freedesktop.Telepathy.Media.StreamHandler"
+#define TP_IFACE_PROPERTIES \
+ "org.freedesktop.Telepathy.Properties"
+#define TP_IFACE_CONN_INTERFACE_AVATAR \
+ "org.freedesktop.Telepathy.Connection.Interface.Avatars"
+
+G_END_DECLS
+
+#endif /* #ifndef __TELEPATHY_INTERFACES_H__*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/text-mixin-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,55 @@
+/*
+ * text-mixin-signals-marshal.h - Headers for Telepathy Channel Factory interface
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __text_mixin_marshal_MARSHAL_H__
+#define __text_mixin_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:UINT,UINT,UINT,UINT,UINT,STRING (text-mixin-signals-marshal.list:1) */
+extern void text_mixin_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT,UINT,STRING (text-mixin-signals-marshal.list:2) */
+extern void text_mixin_marshal_VOID__UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT,STRING (text-mixin-signals-marshal.list:3) */
+extern void text_mixin_marshal_VOID__UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __text_mixin_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/text-mixin.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,96 @@
+/*
+ * text-mixin.h - Header for GabbleTextMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_TEXT_MIXIN_H__
+#define __GABBLE_TEXT_MIXIN_H__
+
+#include "handles.h"
+#include "handle-set.h"
+#include "util.h"
+
+typedef enum {
+ CHANNEL_TEXT_SEND_ERROR_UNKNOWN = 0,
+ CHANNEL_TEXT_SEND_ERROR_OFFLINE,
+ CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT,
+ CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED,
+ CHANNEL_TEXT_SEND_ERROR_TOO_LONG,
+ CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED,
+
+ CHANNEL_TEXT_SEND_NO_ERROR = -1
+} GabbleTextMixinSendError;
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleTextMixinClass GabbleTextMixinClass;
+typedef struct _GabbleTextMixin GabbleTextMixin;
+
+struct _GabbleTextMixinClass {
+ guint lost_message_signal_id;
+ guint received_signal_id;
+ guint send_error_signal_id;
+ guint sent_signal_id;
+};
+
+struct _GabbleTextMixin {
+ GabbleHandleRepo *handle_repo;
+ guint recv_id;
+ gboolean send_nick;
+ gboolean message_lost;
+
+ GQueue *pending;
+
+ GArray *msg_types;
+};
+
+GType gabble_text_mixin_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TEXT_MIXIN_CLASS_OFFSET_QUARK (gabble_text_mixin_class_get_offset_quark())
+#define GABBLE_TEXT_MIXIN_CLASS_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_CLASS_TYPE (o), GABBLE_TEXT_MIXIN_CLASS_OFFSET_QUARK)))
+#define GABBLE_TEXT_MIXIN_CLASS(o) ((GabbleTextMixinClass *) gabble_mixin_offset_cast (o, GABBLE_TEXT_MIXIN_CLASS_OFFSET (o)))
+
+#define GABBLE_TEXT_MIXIN_OFFSET_QUARK (gabble_text_mixin_get_offset_quark())
+#define GABBLE_TEXT_MIXIN_OFFSET(o) (GPOINTER_TO_UINT (g_type_get_qdata (G_OBJECT_TYPE (o), GABBLE_TEXT_MIXIN_OFFSET_QUARK)))
+#define GABBLE_TEXT_MIXIN(o) ((GabbleTextMixin *) gabble_mixin_offset_cast (o, GABBLE_TEXT_MIXIN_OFFSET (o)))
+
+GQuark gabble_text_mixin_class_get_offset_quark (void);
+GQuark gabble_text_mixin_get_offset_quark (void);
+
+void gabble_text_mixin_class_init (GObjectClass *obj_cls, glong offset);
+void gabble_text_mixin_init (GObject *obj, glong offset, GabbleHandleRepo *handle_repo, gboolean send_nick);
+void gabble_text_mixin_set_message_types (GObject *obj, ...);
+void gabble_text_mixin_finalize (GObject *obj);
+
+gboolean gabble_text_mixin_receive (GObject *obj, TpChannelTextMessageType type, GabbleHandle sender, time_t timestamp, const char *text);
+gboolean gabble_text_mixin_acknowledge_pending_messages (GObject *obj, const GArray * ids, GError **error);
+gboolean gabble_text_mixin_list_pending_messages (GObject *obj, gboolean clear, GPtrArray ** ret, GError **error);
+gboolean gabble_text_mixin_send (GObject *obj, guint type, guint subtype, const char * recipient, const gchar * text, GabbleConnection *conn, gboolean emit_signal, GError **error);
+void gabble_text_mixin_emit_sent (GObject *obj, time_t timestamp, guint type, const char *text);
+gboolean gabble_text_mixin_get_message_types (GObject *obj, GArray **ret, GError **error);
+void gabble_text_mixin_clear (GObject *obj);
+
+gboolean gabble_text_mixin_parse_incoming_message (LmMessage *message, const gchar **from, time_t *stamp, TpChannelTextMessageType *msgtype, const gchar **body, const gchar **body_offset, GabbleTextMixinSendError *send_error);
+
+void _gabble_text_mixin_send_error_signal (GObject *obj, GabbleTextMixinSendError error, time_t timestamp, TpChannelTextMessageType type, const gchar *text);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_TEXT_MIXIN_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/tp-channel-factory-iface-signals-marshal.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,38 @@
+/*
+ * tp_channel_factory_iface_signals_marshal.h - Header for GabbleConnection
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __tp_channel_factory_iface_marshal_MARSHAL_H__
+#define __tp_channel_factory_iface_marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:OBJECT,POINTER (tp-channel-factory-iface-signals-marshal.list:1) */
+extern void tp_channel_factory_iface_marshal_VOID__OBJECT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+G_END_DECLS
+
+#endif /* __tp_channel_factory_iface_marshal_MARSHAL_H__ */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/tp-channel-factory-iface.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,88 @@
+/*
+ * tp-channel-factory-iface.h - Headers for Telepathy Channel Factory interface
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TP_CHANNEL_FACTORY_IFACE_H__
+#define __TP_CHANNEL_FACTORY_IFACE_H__
+
+#include <glib-object.h>
+
+#include "telepathy-constants.h"
+#include "tp-channel-iface.h"
+
+G_BEGIN_DECLS
+
+#define TP_TYPE_CHANNEL_FACTORY_IFACE tp_channel_factory_iface_get_type()
+
+#define TP_CHANNEL_FACTORY_IFACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ TP_TYPE_CHANNEL_FACTORY_IFACE, TpChannelFactoryIface))
+
+#define TP_CHANNEL_FACTORY_IFACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ TP_TYPE_CHANNEL_FACTORY_IFACE, TpChannelFactoryIfaceClass))
+
+#define TP_IS_CHANNEL_FACTORY_IFACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ TP_TYPE_CHANNEL_FACTORY_IFACE))
+
+#define TP_IS_CHANNEL_FACTORY_IFACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ TP_TYPE_CHANNEL_FACTORY_IFACE))
+
+#define TP_CHANNEL_FACTORY_IFACE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+ TP_TYPE_CHANNEL_FACTORY_IFACE, TpChannelFactoryIfaceClass))
+
+typedef struct _TpChannelFactoryIface TpChannelFactoryIface;
+typedef struct _TpChannelFactoryIfaceClass TpChannelFactoryIfaceClass;
+
+typedef enum {
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED = 0,
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE,
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE,
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_ERROR,
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE,
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED
+} TpChannelFactoryRequestStatus;
+
+struct _TpChannelFactoryIfaceClass {
+ GTypeInterface parent_class;
+
+ void (*close_all) (TpChannelFactoryIface *);
+ void (*connecting) (TpChannelFactoryIface *);
+ void (*connected) (TpChannelFactoryIface *);
+ void (*disconnected) (TpChannelFactoryIface *);
+ void (*foreach) (TpChannelFactoryIface *, TpChannelFunc func, gpointer data);
+ TpChannelFactoryRequestStatus (*request) (TpChannelFactoryIface *, const gchar *chan_type, TpHandleType handle_type, guint handle, TpChannelIface **ret, GError **error);
+};
+
+GType tp_channel_factory_iface_get_type (void);
+
+void tp_channel_factory_iface_close_all (TpChannelFactoryIface *);
+void tp_channel_factory_iface_connecting (TpChannelFactoryIface *);
+void tp_channel_factory_iface_connected (TpChannelFactoryIface *);
+void tp_channel_factory_iface_disconnected (TpChannelFactoryIface *);
+void tp_channel_factory_iface_foreach (TpChannelFactoryIface *, TpChannelFunc func, gpointer data);
+TpChannelFactoryRequestStatus tp_channel_factory_iface_request (TpChannelFactoryIface *, const gchar *chan_type, TpHandleType handle_type, guint handle, TpChannelIface **ret, GError **error);
+
+G_END_DECLS
+
+#endif /* __TP_CHANNEL_FACTORY_IFACE_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/tp-channel-iface.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,63 @@
+/*
+ * tp-channel-iface.h - Headers for Telepathy Channel interface
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TP_CHANNEL_IFACE_H__
+#define __TP_CHANNEL_IFACE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TP_TYPE_CHANNEL_IFACE tp_channel_iface_get_type()
+
+#define TP_CHANNEL_IFACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ TP_TYPE_CHANNEL_IFACE, TpChannelIface))
+
+#define TP_CHANNEL_IFACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ TP_TYPE_CHANNEL_IFACE, TpChannelIfaceClass))
+
+#define TP_IS_CHANNEL_IFACE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ TP_TYPE_CHANNEL_IFACE))
+
+#define TP_IS_CHANNEL_IFACE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ TP_TYPE_CHANNEL_IFACE))
+
+#define TP_CHANNEL_IFACE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+ TP_TYPE_CHANNEL_IFACE, TpChannelIfaceClass))
+
+typedef struct _TpChannelIface TpChannelIface;
+typedef struct _TpChannelIfaceClass TpChannelIfaceClass;
+typedef void (* TpChannelFunc) (TpChannelIface *, gpointer);
+
+struct _TpChannelIfaceClass {
+ GTypeInterface parent_class;
+};
+
+GType tp_channel_iface_get_type (void);
+
+G_END_DECLS
+
+#endif /* __TP_CHANNEL_IFACE_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/util.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,43 @@
+/*
+ * util.h - Headers for Gabble utility functions
+ * Copyright (C) 2006 Collabora Ltd.
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib.h>
+#include "loudmouth/loudmouth.h"
+
+#include "gabble-types.h"
+
+#ifndef __GABBLE_UTIL_H__
+#define __GABBLE_UTIL_H__
+
+gchar *
+sha1_hex (const gchar *bytes, guint len);
+gboolean g_strdiff (const gchar *left, const gchar *right);
+void lm_message_node_add_own_nick (LmMessageNode *node, GabbleConnection *conn);
+void lm_message_node_steal_children (LmMessageNode *snatcher, LmMessageNode *mum);
+gboolean lm_message_node_has_namespace (LmMessageNode *node, const gchar *ns, const gchar *tag);
+LmMessageNode *lm_message_node_get_child_with_namespace (LmMessageNode *node, const gchar *name, const gchar *ns);
+
+/* format: a@b/c */
+void gabble_decode_jid (const gchar *jid, gchar **a, gchar **b, gchar **c);
+
+gpointer gabble_mixin_offset_cast (gpointer instance, guint offset);
+
+#endif /* __GABBLE_UTIL_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/inc/vcard-manager.h Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,122 @@
+/*
+ * vcard-manager.h - vCard lookup helper for Gabble connections
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GABBLE_VCARD_MANAGER_H__
+#define __GABBLE_VCARD_MANAGER_H__
+
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+
+#include "gabble-types.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleVCardManagerClass GabbleVCardManagerClass;
+typedef struct _GabbleVCardManagerRequest GabbleVCardManagerRequest;
+
+/**
+ * GabbleVCardManagerError:
+ * @GABBLE_VCARD_MANAGER_ERROR_CANCELLED: The vCard request was cancelled
+ * @GABBLE_VCARD_MANAGER_ERROR_TIMEOUT: The vCard request timed out
+ * @GABBLE_VCARD_MANAGER_ERROR_UNKNOWN: An unknown error occured
+ */
+typedef enum
+{
+ GABBLE_VCARD_MANAGER_ERROR_CANCELLED,
+ GABBLE_VCARD_MANAGER_ERROR_TIMEOUT,
+ GABBLE_VCARD_MANAGER_ERROR_UNKNOWN
+} GabbleVCardManagerError;
+
+GQuark gabble_vcard_manager_error_quark (void);
+#define GABBLE_VCARD_MANAGER_ERROR gabble_vcard_manager_error_quark ()
+
+IMPORT_C GType gabble_vcard_manager_get_type(void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_VCARD_MANAGER \
+ (gabble_vcard_manager_get_type())
+#define GABBLE_VCARD_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManager))
+#define GABBLE_VCARD_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManagerClass))
+#define GABBLE_IS_VCARD_MANAGER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_VCARD_MANAGER))
+#define GABBLE_IS_VCARD_MANAGER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_VCARD_MANAGER))
+#define GABBLE_VCARD_MANAGER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManagerClass))
+
+struct _GabbleVCardManagerClass {
+ GObjectClass parent_class;
+};
+
+struct _GabbleVCardManager {
+ GObject parent;
+ gpointer priv;
+};
+
+typedef void (*GabbleVCardManagerCb)(GabbleVCardManager *self,
+ GabbleVCardManagerRequest *request,
+ GabbleHandle handle,
+ LmMessageNode *vcard,
+ GError *error,
+ gpointer user_data);
+
+GabbleVCardManager *gabble_vcard_manager_new (GabbleConnection *);
+
+GQuark gabble_vcard_manager_cache_quark (void);
+
+GabbleVCardManagerRequest *gabble_vcard_manager_request (GabbleVCardManager *,
+ GabbleHandle,
+ guint timeout,
+ GabbleVCardManagerCb,
+ gpointer user_data,
+ GObject *object,
+ GError **error);
+
+GabbleVCardManagerRequest *gabble_vcard_manager_replace (GabbleVCardManager *,
+ LmMessageNode *,
+ guint timeout,
+ GabbleVCardManagerCb,
+ gpointer user_data,
+ GObject *object,
+ GError **error);
+
+GabbleVCardManagerRequest *gabble_vcard_manager_edit (GabbleVCardManager *,
+ guint timeout,
+ GabbleVCardManagerCb,
+ gpointer user_data,
+ GObject *object,
+ GError **error,
+ ...)
+ G_GNUC_NULL_TERMINATED;
+
+void gabble_vcard_manager_cancel_request (GabbleVCardManager *manager,
+ GabbleVCardManagerRequest *request);
+
+const gchar *gabble_vcard_manager_get_cached_alias (GabbleVCardManager *,
+ GabbleHandle);
+gboolean gabble_vcard_manager_has_cached_alias (GabbleVCardManager *manager,
+ GabbleHandle handle);
+
+G_END_DECLS
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/rom/telepathygabble.iby Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,35 @@
+/*
+ * telepathygabble.iby - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#ifndef __GABBLE_IBY__
+#define __GABBLE_IBY__
+
+
+//Telepathy-gabble DLLs
+file=ABI_DIR\BUILD_DIR\libgabble-convenience.dll SHARED_LIB_DIR\libgabble-convenience.dll
+file=ABI_DIR\BUILD_DIR\tg.exe PROGRAMS_DIR\tg.exe
+
+data=\epoc32\winscw\c\data\dbus\dbus1\services\jabber.service_hw data\dbus\dbus1\services\jabber.service
+
+
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/Makefile.am Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,197 @@
+BUILT_SOURCES = \
+ gabble-connection-manager-glue.h \
+ gabble-connection-manager-signals-marshal.h \
+ gabble-connection-manager-signals-marshal.c \
+ gabble-connection-glue.h \
+ gabble-connection-signals-marshal.h \
+ gabble-connection-signals-marshal.c \
+ gabble-register-signals-marshal.h \
+ gabble-register-signals-marshal.c \
+ gabble-im-channel-glue.h \
+ gabble-im-channel-signals-marshal.h \
+ gabble-im-channel-signals-marshal.c \
+ gabble-muc-channel-glue.h \
+ gabble-muc-channel-signals-marshal.h \
+ gabble-muc-channel-signals-marshal.c \
+ gabble-media-channel-glue.h \
+ gabble-media-channel-signals-marshal.h \
+ gabble-media-channel-signals-marshal.c \
+ gabble-media-session-glue.h \
+ gabble-media-session-signals-marshal.h \
+ gabble-media-session-signals-marshal.c \
+ gabble-media-session-enumtypes.h \
+ gabble-media-session-enumtypes.c \
+ gabble-media-stream-glue.h \
+ gabble-media-stream-signals-marshal.h \
+ gabble-media-stream-signals-marshal.c \
+ gabble-presence-cache-signals-marshal.h \
+ gabble-presence-cache-signals-marshal.c \
+ gabble-roster-channel-glue.h \
+ gabble-roster-channel-signals-marshal.h \
+ gabble-roster-channel-signals-marshal.c \
+ gabble-roomlist-channel-glue.h \
+ gabble-roomlist-channel-signals-marshal.h \
+ gabble-roomlist-channel-signals-marshal.c \
+ group-mixin-signals-marshal.h \
+ group-mixin-signals-marshal.c \
+ properties-mixin-signals-marshal.h \
+ properties-mixin-signals-marshal.c \
+ telepathy-errors-enumtypes.h \
+ telepathy-errors-enumtypes.c \
+ text-mixin-signals-marshal.h \
+ text-mixin-signals-marshal.c \
+ tp-channel-factory-iface-signals-marshal.h \
+ tp-channel-factory-iface-signals-marshal.c
+
+# correctly clean the generated source files
+CLEANFILES = $(BUILT_SOURCES)
+
+bin_PROGRAMS=telepathy-gabble
+noinst_PROGRAMS = write-mgr-file
+
+CORE_SOURCES = \
+ ansi.h \
+ capabilities.h \
+ capabilities.c \
+ debug.h \
+ debug.c \
+ disco.h \
+ disco.c \
+ gabble-error.c \
+ gabble-error.h \
+ gabble-connection-manager.h \
+ gabble-connection-manager.c \
+ gabble-connection.h \
+ gabble-connection.c \
+ gabble-im-channel.h \
+ gabble-im-channel.c \
+ gabble-muc-channel.h \
+ gabble-muc-channel.c \
+ gabble-media-channel.h \
+ gabble-media-channel.c \
+ gabble-media-session.h \
+ gabble-media-session.c \
+ gabble-media-stream.h \
+ gabble-media-stream.c \
+ gabble-presence.h \
+ gabble-presence.c \
+ gabble-presence-cache.h \
+ gabble-presence-cache.c \
+ gabble-register.c \
+ gabble-register.h \
+ gabble-roster-channel.h \
+ gabble-roster-channel.c \
+ gabble-roomlist-channel.h \
+ gabble-roomlist-channel.c \
+ gabble-types.h \
+ gheap.h \
+ gheap.c \
+ gintset.h \
+ gintset.c \
+ group-mixin.h \
+ group-mixin.c \
+ handles.h \
+ handles.c \
+ handle-set.h \
+ handle-set.c \
+ jingle-info.c \
+ jingle-info.h \
+ im-factory.h \
+ im-factory.c \
+ media-factory.h \
+ media-factory.c \
+ muc-factory.h \
+ muc-factory.c \
+ namespaces.h \
+ properties-mixin.h \
+ properties-mixin.c \
+ roster.h \
+ roster.c \
+ telepathy-constants.h \
+ telepathy-interfaces.h \
+ telepathy-errors.h \
+ telepathy-errors.c \
+ telepathy-helpers.h \
+ telepathy-helpers.c \
+ text-mixin.h \
+ text-mixin.c \
+ tp-channel-iface.h \
+ tp-channel-iface.c \
+ tp-channel-factory-iface.h \
+ tp-channel-factory-iface.c \
+ util.h \
+ util.c \
+ vcard-manager.h \
+ vcard-manager.c \
+ $(BUILT_SOURCES)
+
+EXTRA_DIST = \
+ gabble-connection-manager-signals-marshal.list \
+ gabble-connection-signals-marshal.list \
+ gabble-im-channel-signals-marshal.list \
+ gabble-media-channel-signals-marshal.list \
+ gabble-media-session-signals-marshal.list \
+ gabble-media-stream-signals-marshal.list \
+ gabble-muc-channel-signals-marshal.list \
+ gabble-presence-cache-signals-marshal.list \
+ gabble-register-signals-marshal.list \
+ gabble-roomlist-channel-signals-marshal.list \
+ gabble-roster-channel-signals-marshal.list \
+ group-mixin-signals-marshal.list \
+ properties-mixin-signals-marshal.list \
+ text-mixin-signals-marshal.list \
+ tp-channel-factory-iface-signals-marshal.list
+
+libgabble_convenience_la_SOURCES = \
+ $(CORE_SOURCES)
+
+write_mgr_file_SOURCES = write-mgr-file.c
+
+write_mgr_file_LDADD = libgabble-convenience.la
+
+telepathy_gabble_SOURCES = \
+ gabble.h \
+ gabble.c
+
+telepathy_gabble_LDADD = libgabble-convenience.la
+
+noinst_LTLIBRARIES = libgabble-convenience.la
+
+AM_CFLAGS = $(ERROR_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@ @LOUDMOUTH_CFLAGS@ @HANDLE_LEAK_DEBUG_CFLAGS@
+AM_LDFLAGS = @DBUS_LIBS@ @GLIB_LIBS@ @LOUDMOUTH_LIBS@
+
+
+# rule to generate the binding headers
+%-glue.h: ../generate/xml-modified/%.xml
+ dbus-binding-tool --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $<
+
+%-signals-marshal.h: %-signals-marshal.list
+ glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-signals-marshal.h
+
+%-signals-marshal.c: %-signals-marshal.list
+ glib-genmarshal --body --prefix=$(subst -,_,$*)_marshal $< > $*-signals-marshal.c
+
+%-marshal.h: %-marshal.list
+ glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
+
+%-marshal.c: %-marshal.list
+ glib-genmarshal --body --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.c
+
+
+# rules for making the glib enum objects
+%-enumtypes.h: %.h Makefile.in
+ glib-mkenums \
+ --fhead "#ifndef __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n#define __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fprod "/* enumerations from \"@filename@\" */\n" \
+ --vhead "GType @enum_name@_get_type (void);\n#define $(shell echo $* | tr [:lower:]- [:upper:]_ | sed 's/_.*//')_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
+ --ftail "G_END_DECLS\n\n#endif /* __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__ */" \
+ $< > $@
+
+%-enumtypes.c: %.h Makefile.in
+ glib-mkenums \
+ --fhead "#include <$*.h>" \
+ --fprod "\n/* enumerations from \"@filename@\" */" \
+ --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@VALUENAME@\" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
+ $< > $@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/Makefile.in Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,774 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = telepathy-gabble$(EXEEXT)
+noinst_PROGRAMS = write-mgr-file$(EXEEXT)
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
+ $(top_srcdir)/m4/as-compiler-flag.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libgabble_convenience_la_LIBADD =
+am__objects_1 = gabble-connection-manager-signals-marshal.lo \
+ gabble-connection-signals-marshal.lo \
+ gabble-register-signals-marshal.lo \
+ gabble-im-channel-signals-marshal.lo \
+ gabble-muc-channel-signals-marshal.lo \
+ gabble-media-channel-signals-marshal.lo \
+ gabble-media-session-signals-marshal.lo \
+ gabble-media-session-enumtypes.lo \
+ gabble-media-stream-signals-marshal.lo \
+ gabble-presence-cache-signals-marshal.lo \
+ gabble-roster-channel-signals-marshal.lo \
+ gabble-roomlist-channel-signals-marshal.lo \
+ group-mixin-signals-marshal.lo \
+ properties-mixin-signals-marshal.lo \
+ telepathy-errors-enumtypes.lo text-mixin-signals-marshal.lo \
+ tp-channel-factory-iface-signals-marshal.lo
+am__objects_2 = capabilities.lo debug.lo disco.lo gabble-error.lo \
+ gabble-connection-manager.lo gabble-connection.lo \
+ gabble-im-channel.lo gabble-muc-channel.lo \
+ gabble-media-channel.lo gabble-media-session.lo \
+ gabble-media-stream.lo gabble-presence.lo \
+ gabble-presence-cache.lo gabble-register.lo \
+ gabble-roster-channel.lo gabble-roomlist-channel.lo gheap.lo \
+ gintset.lo group-mixin.lo handles.lo handle-set.lo \
+ jingle-info.lo im-factory.lo media-factory.lo muc-factory.lo \
+ properties-mixin.lo roster.lo telepathy-errors.lo \
+ telepathy-helpers.lo text-mixin.lo tp-channel-iface.lo \
+ tp-channel-factory-iface.lo util.lo vcard-manager.lo \
+ $(am__objects_1)
+am_libgabble_convenience_la_OBJECTS = $(am__objects_2)
+libgabble_convenience_la_OBJECTS = \
+ $(am_libgabble_convenience_la_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+am_telepathy_gabble_OBJECTS = gabble.$(OBJEXT)
+telepathy_gabble_OBJECTS = $(am_telepathy_gabble_OBJECTS)
+telepathy_gabble_DEPENDENCIES = libgabble-convenience.la
+am_write_mgr_file_OBJECTS = write-mgr-file.$(OBJEXT)
+write_mgr_file_OBJECTS = $(am_write_mgr_file_OBJECTS)
+write_mgr_file_DEPENDENCIES = libgabble-convenience.la
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libgabble_convenience_la_SOURCES) \
+ $(telepathy_gabble_SOURCES) $(write_mgr_file_SOURCES)
+DIST_SOURCES = $(libgabble_convenience_la_SOURCES) \
+ $(telepathy_gabble_SOURCES) $(write_mgr_file_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_GTK_DOC_FALSE = @ENABLE_GTK_DOC_FALSE@
+ENABLE_GTK_DOC_TRUE = @ENABLE_GTK_DOC_TRUE@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GREP = @GREP@
+GTK_DOC_USE_LIBTOOL_FALSE = @GTK_DOC_USE_LIBTOOL_FALSE@
+GTK_DOC_USE_LIBTOOL_TRUE = @GTK_DOC_USE_LIBTOOL_TRUE@
+HANDLE_LEAK_DEBUG_CFLAGS = @HANDLE_LEAK_DEBUG_CFLAGS@
+HTML_DIR = @HTML_DIR@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LOUDMOUTH_CFLAGS = @LOUDMOUTH_CFLAGS@
+LOUDMOUTH_LIBS = @LOUDMOUTH_LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+BUILT_SOURCES = \
+ gabble-connection-manager-glue.h \
+ gabble-connection-manager-signals-marshal.h \
+ gabble-connection-manager-signals-marshal.c \
+ gabble-connection-glue.h \
+ gabble-connection-signals-marshal.h \
+ gabble-connection-signals-marshal.c \
+ gabble-register-signals-marshal.h \
+ gabble-register-signals-marshal.c \
+ gabble-im-channel-glue.h \
+ gabble-im-channel-signals-marshal.h \
+ gabble-im-channel-signals-marshal.c \
+ gabble-muc-channel-glue.h \
+ gabble-muc-channel-signals-marshal.h \
+ gabble-muc-channel-signals-marshal.c \
+ gabble-media-channel-glue.h \
+ gabble-media-channel-signals-marshal.h \
+ gabble-media-channel-signals-marshal.c \
+ gabble-media-session-glue.h \
+ gabble-media-session-signals-marshal.h \
+ gabble-media-session-signals-marshal.c \
+ gabble-media-session-enumtypes.h \
+ gabble-media-session-enumtypes.c \
+ gabble-media-stream-glue.h \
+ gabble-media-stream-signals-marshal.h \
+ gabble-media-stream-signals-marshal.c \
+ gabble-presence-cache-signals-marshal.h \
+ gabble-presence-cache-signals-marshal.c \
+ gabble-roster-channel-glue.h \
+ gabble-roster-channel-signals-marshal.h \
+ gabble-roster-channel-signals-marshal.c \
+ gabble-roomlist-channel-glue.h \
+ gabble-roomlist-channel-signals-marshal.h \
+ gabble-roomlist-channel-signals-marshal.c \
+ group-mixin-signals-marshal.h \
+ group-mixin-signals-marshal.c \
+ properties-mixin-signals-marshal.h \
+ properties-mixin-signals-marshal.c \
+ telepathy-errors-enumtypes.h \
+ telepathy-errors-enumtypes.c \
+ text-mixin-signals-marshal.h \
+ text-mixin-signals-marshal.c \
+ tp-channel-factory-iface-signals-marshal.h \
+ tp-channel-factory-iface-signals-marshal.c
+
+
+# correctly clean the generated source files
+CLEANFILES = $(BUILT_SOURCES)
+CORE_SOURCES = \
+ ansi.h \
+ capabilities.h \
+ capabilities.c \
+ debug.h \
+ debug.c \
+ disco.h \
+ disco.c \
+ gabble-error.c \
+ gabble-error.h \
+ gabble-connection-manager.h \
+ gabble-connection-manager.c \
+ gabble-connection.h \
+ gabble-connection.c \
+ gabble-im-channel.h \
+ gabble-im-channel.c \
+ gabble-muc-channel.h \
+ gabble-muc-channel.c \
+ gabble-media-channel.h \
+ gabble-media-channel.c \
+ gabble-media-session.h \
+ gabble-media-session.c \
+ gabble-media-stream.h \
+ gabble-media-stream.c \
+ gabble-presence.h \
+ gabble-presence.c \
+ gabble-presence-cache.h \
+ gabble-presence-cache.c \
+ gabble-register.c \
+ gabble-register.h \
+ gabble-roster-channel.h \
+ gabble-roster-channel.c \
+ gabble-roomlist-channel.h \
+ gabble-roomlist-channel.c \
+ gabble-types.h \
+ gheap.h \
+ gheap.c \
+ gintset.h \
+ gintset.c \
+ group-mixin.h \
+ group-mixin.c \
+ handles.h \
+ handles.c \
+ handle-set.h \
+ handle-set.c \
+ jingle-info.c \
+ jingle-info.h \
+ im-factory.h \
+ im-factory.c \
+ media-factory.h \
+ media-factory.c \
+ muc-factory.h \
+ muc-factory.c \
+ namespaces.h \
+ properties-mixin.h \
+ properties-mixin.c \
+ roster.h \
+ roster.c \
+ telepathy-constants.h \
+ telepathy-interfaces.h \
+ telepathy-errors.h \
+ telepathy-errors.c \
+ telepathy-helpers.h \
+ telepathy-helpers.c \
+ text-mixin.h \
+ text-mixin.c \
+ tp-channel-iface.h \
+ tp-channel-iface.c \
+ tp-channel-factory-iface.h \
+ tp-channel-factory-iface.c \
+ util.h \
+ util.c \
+ vcard-manager.h \
+ vcard-manager.c \
+ $(BUILT_SOURCES)
+
+EXTRA_DIST = \
+ gabble-connection-manager-signals-marshal.list \
+ gabble-connection-signals-marshal.list \
+ gabble-im-channel-signals-marshal.list \
+ gabble-media-channel-signals-marshal.list \
+ gabble-media-session-signals-marshal.list \
+ gabble-media-stream-signals-marshal.list \
+ gabble-muc-channel-signals-marshal.list \
+ gabble-presence-cache-signals-marshal.list \
+ gabble-register-signals-marshal.list \
+ gabble-roomlist-channel-signals-marshal.list \
+ gabble-roster-channel-signals-marshal.list \
+ group-mixin-signals-marshal.list \
+ properties-mixin-signals-marshal.list \
+ text-mixin-signals-marshal.list \
+ tp-channel-factory-iface-signals-marshal.list
+
+libgabble_convenience_la_SOURCES = \
+ $(CORE_SOURCES)
+
+write_mgr_file_SOURCES = write-mgr-file.c
+write_mgr_file_LDADD = libgabble-convenience.la
+telepathy_gabble_SOURCES = \
+ gabble.h \
+ gabble.c
+
+telepathy_gabble_LDADD = libgabble-convenience.la
+noinst_LTLIBRARIES = libgabble-convenience.la
+AM_CFLAGS = $(ERROR_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@ @LOUDMOUTH_CFLAGS@ @HANDLE_LEAK_DEBUG_CFLAGS@
+AM_LDFLAGS = @DBUS_LIBS@ @GLIB_LIBS@ @LOUDMOUTH_LIBS@
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgabble-convenience.la: $(libgabble_convenience_la_OBJECTS) $(libgabble_convenience_la_DEPENDENCIES)
+ $(LINK) $(libgabble_convenience_la_LDFLAGS) $(libgabble_convenience_la_OBJECTS) $(libgabble_convenience_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+telepathy-gabble$(EXEEXT): $(telepathy_gabble_OBJECTS) $(telepathy_gabble_DEPENDENCIES)
+ @rm -f telepathy-gabble$(EXEEXT)
+ $(LINK) $(telepathy_gabble_LDFLAGS) $(telepathy_gabble_OBJECTS) $(telepathy_gabble_LDADD) $(LIBS)
+write-mgr-file$(EXEEXT): $(write_mgr_file_OBJECTS) $(write_mgr_file_DEPENDENCIES)
+ @rm -f write-mgr-file$(EXEEXT)
+ $(LINK) $(write_mgr_file_LDFLAGS) $(write_mgr_file_OBJECTS) $(write_mgr_file_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/capabilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/disco.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-connection-manager-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-connection-manager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-connection-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-connection.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-error.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-im-channel-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-im-channel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-channel-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-channel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-session-enumtypes.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-session-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-session.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-stream-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-media-stream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-muc-channel-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-muc-channel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-presence-cache-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-presence-cache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-presence.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-register-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-register.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-roomlist-channel-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-roomlist-channel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-roster-channel-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble-roster-channel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gabble.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gheap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gintset.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/group-mixin-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/group-mixin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handle-set.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handles.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/im-factory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jingle-info.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/media-factory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muc-factory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/properties-mixin-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/properties-mixin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/roster.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/telepathy-errors-enumtypes.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/telepathy-errors.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/telepathy-helpers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text-mixin-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text-mixin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tp-channel-factory-iface-signals-marshal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tp-channel-factory-iface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tp-channel-iface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcard-manager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write-mgr-file.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-info-am
+
+
+# rule to generate the binding headers
+%-glue.h: ../generate/xml-modified/%.xml
+ dbus-binding-tool --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $<
+
+%-signals-marshal.h: %-signals-marshal.list
+ glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-signals-marshal.h
+
+%-signals-marshal.c: %-signals-marshal.list
+ glib-genmarshal --body --prefix=$(subst -,_,$*)_marshal $< > $*-signals-marshal.c
+
+%-marshal.h: %-marshal.list
+ glib-genmarshal --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h
+
+%-marshal.c: %-marshal.list
+ glib-genmarshal --body --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.c
+
+# rules for making the glib enum objects
+%-enumtypes.h: %.h Makefile.in
+ glib-mkenums \
+ --fhead "#ifndef __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n#define __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fprod "/* enumerations from \"@filename@\" */\n" \
+ --vhead "GType @enum_name@_get_type (void);\n#define $(shell echo $* | tr [:lower:]- [:upper:]_ | sed 's/_.*//')_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
+ --ftail "G_END_DECLS\n\n#endif /* __$(shell echo $* | tr [:lower:]- [:upper:]_)_ENUM_TYPES_H__ */" \
+ $< > $@
+
+%-enumtypes.c: %.h Makefile.in
+ glib-mkenums \
+ --fhead "#include <$*.h>" \
+ --fprod "\n/* enumerations from \"@filename@\" */" \
+ --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@VALUENAME@\" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
+ $< > $@
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/base64.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,196 @@
+/*
+ * base64.c - Base 64 encoding/decoding implementation
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "base64.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_VCARD
+#include "debug.h"
+
+#include <ctype.h>
+#include <string.h>
+
+#include <glib.h>
+
+/*
+|AAAA AABB|BBBB CCCC|CCDD DDDD|
+
+0xFC = 1111 1100
+0x03 = 0000 0011
+0xF0 = 1111 0000
+0x0F = 0000 1111
+0xC0 = 1100 0000
+0x3F = 0011 1111
+
+3 input bytes = 4 output bytes;
+2 input bytes = 2 output bytes;
+1 input byte = 1 output byte.
+*/
+
+static const gchar *encoding =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static const guint decoding[256] =
+{
+ /* ... */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0,
+ /* + */
+ 62,
+ /* ... */
+ 0, 0, 0,
+ /* / , 0-9 */
+ 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+ /* ... */
+ 0, 0, 0, 0, 0, 0, 0,
+ /* A */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+ /* ... */
+ 0, 0, 0, 0, 0, 0,
+ /* a */
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+};
+
+#define GET_6_BITS_0(s) (((s)[0] & 0xFC) >> 2)
+#define GET_6_BITS_1(s) (((s)[0] & 0x03) << 4) | \
+ (((s)[1] & 0xF0) >> 4)
+#define GET_6_BITS_2(s) (((s)[1] & 0x0F) << 2) | \
+ (((s)[2] & 0xC0) >> 6)
+#define GET_6_BITS_3(s) (((s)[2] & 0x3F) << 0)
+
+#define GET_BYTE_0(s) (((decoding[(guchar)(s)[0]] & 0x3F) << 2) | \
+ ((decoding[(guchar)(s)[1]] & 0x30) >> 4))
+#define GET_BYTE_1(s) (((decoding[(guchar)(s)[1]] & 0x0F) << 4) | \
+ ((decoding[(guchar)(s)[2]] & 0x3C) >> 2))
+#define GET_BYTE_2(s) (((decoding[(guchar)(s)[2]] & 0x03) << 6) | \
+ ((decoding[(guchar)(s)[3]] & 0xFF) << 0))
+
+gchar *base64_encode (guint len, const gchar *str)
+{
+ guint i;
+ GString *tmp;
+
+ /* TODO: calculate requisite output string length and allocate that big a
+ * GString */
+ tmp = g_string_new ("");
+
+ for (i = 0; i < len; i += 3)
+ {
+ guint c1, c2, c3, c4;
+
+ if (i > 0 && (i * 4) % 76 == 0)
+ g_string_append_c (tmp, '\n');
+
+ switch (i + 3 - len)
+ {
+ case 1:
+ c1 = encoding[GET_6_BITS_0 (str + i)];
+ c2 = encoding[GET_6_BITS_1 (str + i)];
+ /* can't use GET_6_BITS_2 because str[i+2] is out of range */
+ c3 = encoding[(str[i + 1] & 0x0f) << 2];
+ c4 = '=';
+ break;
+ case 2:
+ c1 = encoding[GET_6_BITS_0 (str + i)];
+ /* can't use GET_6_BITS_1 because str[i+1] is out of range */
+ c2 = encoding[(str[i] & 0x03) << 4];
+ c3 = '=';
+ c4 = '=';
+ break;
+ default:
+ c1 = encoding[GET_6_BITS_0 (str + i)];
+ c2 = encoding[GET_6_BITS_1 (str + i)];
+ c3 = encoding[GET_6_BITS_2 (str + i)];
+ c4 = encoding[GET_6_BITS_3 (str + i)];
+ }
+
+ g_string_append_printf (tmp, "%c%c%c%c", c1, c2, c3, c4);
+ }
+
+ return g_string_free (tmp, FALSE);
+}
+
+GString *base64_decode (const gchar *str)
+{
+ guint i;
+ GString *tmp;
+ char group[4];
+ guint filled = 0;
+
+ for (i = 0; str[i]; i++)
+ {
+ if (str[i] != 'A' &&
+ str[i] != '=' &&
+ !isspace (str[i]) &&
+ decoding[(guchar) str[i]] == 0)
+ {
+ gabble_debug (DEBUG_FLAG, "bad character %x at byte %u", (guchar)str[i], i);
+ return NULL;
+ }
+ }
+
+ tmp = g_string_new ("");
+
+ for (i = 0; str[i]; i++)
+ {
+ if (isspace (str[i]))
+ continue;
+
+ group[filled++] = str[i];
+
+ if (filled == 4)
+ {
+ if (group[3] == '=')
+ {
+ if (group[2] == '=')
+ {
+ g_string_append_c (tmp, GET_BYTE_0(group));
+ }
+ else
+ {
+ g_string_append_c (tmp, GET_BYTE_0(group));
+ g_string_append_c (tmp, GET_BYTE_1(group));
+ }
+ }
+ else
+ {
+ g_string_append_c (tmp, GET_BYTE_0(group));
+ g_string_append_c (tmp, GET_BYTE_1(group));
+ g_string_append_c (tmp, GET_BYTE_2(group));
+ }
+ filled = 0;
+ }
+ }
+
+ if (filled)
+ {
+ gabble_debug (DEBUG_FLAG, "insufficient padding at end of base64 string:\n%s", str);
+ g_string_free (tmp, TRUE);
+ return NULL;
+ }
+
+ return tmp;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/capabilities.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,97 @@
+/*
+ * capabilities.c - Connection.Interface.Capabilities constants and utilities
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "capabilities.h"
+
+#include "namespaces.h"
+#include "config.h"
+#include "gabble-presence-cache.h"
+#include "telepathy-interfaces.h"
+#include "gabble-media-channel.h"
+
+static const Feature self_advertised_features[] =
+{
+ { VERSION, NS_GOOGLE_FEAT_SESSION, 0},
+ { VERSION, NS_GOOGLE_TRANSPORT_P2P, PRESENCE_CAP_GOOGLE_TRANSPORT_P2P},
+ { VERSION, NS_JINGLE, PRESENCE_CAP_JINGLE},
+
+ { BUNDLE_VOICE_V1, NS_GOOGLE_FEAT_VOICE, PRESENCE_CAP_GOOGLE_VOICE},
+ { BUNDLE_JINGLE_AUDIO, NS_JINGLE_DESCRIPTION_AUDIO, PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO},
+ { BUNDLE_JINGLE_VIDEO, NS_JINGLE_DESCRIPTION_VIDEO, PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO},
+ { NULL, NULL, 0}
+};
+
+
+
+
+GSList *
+capabilities_get_features (GabblePresenceCapabilities caps)
+{
+ GSList *features = NULL;
+ const Feature *i;
+
+ for (i = self_advertised_features; NULL != i->ns; i++)
+ if ((i->caps & caps) == i->caps)
+ features = g_slist_append (features, (gpointer) i);
+
+ return features;
+}
+
+void
+capabilities_fill_cache (GabblePresenceCache *cache)
+{
+ const Feature *feat;
+ for (feat = self_advertised_features; NULL != feat->ns; feat++)
+ {
+ gchar *node = g_strconcat (NS_GABBLE_CAPS "#", feat->bundle, NULL);
+ gabble_presence_cache_add_bundle_caps (cache,
+ node, feat->caps);
+ g_free (node);
+ }
+
+ gabble_presence_cache_add_bundle_caps (cache,
+ "http://www.google.com/xmpp/client/caps#voice-v1",
+ PRESENCE_CAP_GOOGLE_VOICE);
+}
+
+GabblePresenceCapabilities
+capabilities_get_initial_caps ()
+{
+ GabblePresenceCapabilities ret = 0;
+ const Feature *feat;
+
+ for (feat = self_advertised_features; NULL != feat->ns; feat++)
+ {
+ if (g_str_equal (feat->bundle, VERSION))
+ /* VERSION == bundle means a fixed feature, which we always advertise */
+ ret |= feat->caps;
+ }
+
+ return ret;
+}
+
+const CapabilityConversionData capabilities_conversions[] =
+{
+ { TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+ _gabble_media_channel_typeflags_to_caps_tmp, /*_gabble_media_channel_typeflags_to_caps,*/
+ _gabble_media_channel_caps_to_typeflags_tmp /*_gabble_media_channel_caps_to_typeflags*/ },
+ { NULL, NULL, NULL}
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/debug.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,130 @@
+/*
+ * debug.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <stdarg.h>
+#include <stdio.h> // bsr
+#include <glib.h>
+
+#include "debug.h"
+
+/*#ifdef ENABLE_DEBUG*/
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(flags,gabble_debug,GabbleDebugFlags)
+ #define flags (*GET_WSD_VAR_NAME(flags,gabble_debug,s)())
+
+ GET_STATIC_VAR_FROM_TLS(log_handler,gabble_debug,guint)
+ #define log_handler (*GET_WSD_VAR_NAME(log_handler,gabble_debug,s)())
+
+ GET_STATIC_ARRAY_FROM_TLS(keys,gabble_debug,GDebugKey)
+ #define keys (GET_WSD_VAR_NAME(keys,gabble_debug, s)())
+
+
+#else
+ static GabbleDebugFlags flags = 0;
+ static guint log_handler; // bsr
+ GDebugKey keys[] = {
+ { "presence", GABBLE_DEBUG_PRESENCE },
+ { "groups", GABBLE_DEBUG_GROUPS },
+ { "roster", GABBLE_DEBUG_ROSTER },
+ { "disco", GABBLE_DEBUG_DISCO },
+ { "properties", GABBLE_DEBUG_PROPERTIES },
+ { "roomlist", GABBLE_DEBUG_ROOMLIST },
+ { "media-channel", GABBLE_DEBUG_MEDIA },
+ { "muc", GABBLE_DEBUG_MUC },
+ { "connection", GABBLE_DEBUG_CONNECTION },
+ { "persist", GABBLE_DEBUG_PERSIST },
+ { "vcard", GABBLE_DEBUG_VCARD },
+ { 0, },
+};
+
+
+#endif
+
+/* bsr added new */
+static void
+debug_log_handler1 (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ #ifdef _DEBUG
+
+ FILE* fp;
+
+ fp = fopen("c:\\gabblelogs.txt","a");
+ if(fp)
+ {
+ fprintf(fp,message);
+ fprintf(fp,"\n");
+ fclose(fp);
+ }
+ #endif //_DEBUG
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+void gabble_debug_set_flags_from_env ()
+{
+ guint nkeys;
+ const gchar *flags_string;
+
+ for (nkeys = 0; keys[nkeys].value; nkeys++);
+
+ flags_string = g_getenv ("GABBLE_DEBUG");
+
+ if (flags_string)
+ gabble_debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
+
+ // bsr
+ log_handler = g_log_set_handler (NULL, 0xFF,
+ debug_log_handler1, NULL);
+}
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+void gabble_debug_set_flags (GabbleDebugFlags new_flags)
+{
+ flags |= new_flags;
+}
+
+
+gboolean gabble_debug_flag_is_set (GabbleDebugFlags flag)
+{
+ return flag & flags;
+}
+
+void gabble_debug (GabbleDebugFlags flag,
+ const gchar *format,
+ ...)
+{
+ if (flag & flags)
+ {
+ va_list args;
+ va_start (args, format);
+ g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
+ va_end (args);
+ }
+}
+
+/*#endif /* ENABLE_DEBUG */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/disco.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,981 @@
+/*
+ * gabble-media-stream-glue.h
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+
+ */
+
+
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <stdlib.h>
+#include <string.h>
+#include "loudmouth/loudmouth.h"
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "gabble-error.h"
+#include "namespaces.h"
+#include "telepathy-helpers.h"
+#include "util.h"
+#include "search-keys-info.h"
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(quark,gabble_disco,GQuark)
+ #define quark (*GET_WSD_VAR_NAME(quark,gabble_disco,s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_disco_parent_class,gabble_disco,gpointer)
+ #define gabble_disco_parent_class (*GET_WSD_VAR_NAME(gabble_disco_parent_class,gabble_disco,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_disco,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_disco,s)())
+
+
+
+static void gabble_disco_init (GabbleDisco *self);
+static void gabble_disco_class_init (GabbleDiscoClass *klass);
+static void gabble_disco_class_intern_init (gpointer klass)
+{
+gabble_disco_parent_class = g_type_class_peek_parent (klass);
+gabble_disco_class_init ((GabbleDiscoClass*) klass);
+}
+EXPORT_C GType gabble_disco_get_type (void)
+{
+
+if ((g_define_type_id == 0))
+{
+static const GTypeInfo g_define_type_info =
+ { sizeof (GabbleDiscoClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_disco_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleDisco), 0, (GInstanceInitFunc) gabble_disco_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleDisco"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ } ;
+
+
+#endif
+
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_DISCO
+#define DEFAULT_REQUEST_TIMEOUT 20000
+#define DISCO_PIPELINE_SIZE 10
+
+
+/* Properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleDisco, gabble_disco, G_TYPE_OBJECT);
+#endif
+
+typedef struct _GabbleDiscoPrivate GabbleDiscoPrivate;
+struct _GabbleDiscoPrivate
+{
+ GabbleConnection *connection;
+ GSList *service_cache;
+ GList *requests;
+ gboolean dispose_has_run;
+};
+
+struct _GabbleDiscoRequest
+{
+ GabbleDisco *disco;
+ guint timer_id;
+
+ GabbleDiscoType type;
+ gchar *jid;
+ gchar *node;
+ GabbleDiscoCb callback;
+ gpointer user_data;
+ GObject *bound_object;
+};
+
+GQuark
+gabble_disco_error_quark (void)
+{
+
+#ifndef EMULATOR
+ static GQuark quark = 0;
+#endif
+
+ if (!quark)
+ quark = g_quark_from_static_string ("gabble-disco-error");
+ return quark;
+}
+
+#define GABBLE_DISCO_GET_PRIVATE(o) ((GabbleDiscoPrivate*)((o)->priv));
+
+
+
+
+
+
+static void
+gabble_disco_init (GabbleDisco *obj)
+{
+ GabbleDiscoPrivate *priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (obj, GABBLE_TYPE_DISCO, GabbleDiscoPrivate);
+ obj->priv = priv;
+}
+
+
+
+
+static GObject *gabble_disco_constructor (GType type, guint n_props,
+ GObjectConstructParam *props);
+static void gabble_disco_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec);
+static void gabble_disco_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec);
+static void gabble_disco_dispose (GObject *object);
+static void gabble_disco_finalize (GObject *object);
+
+static void
+gabble_disco_class_init (GabbleDiscoClass *gabble_disco_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_disco_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_disco_class, sizeof (GabbleDiscoPrivate));
+
+ object_class->constructor = gabble_disco_constructor;
+
+ object_class->get_property = gabble_disco_get_property;
+ object_class->set_property = gabble_disco_set_property;
+
+ object_class->dispose = gabble_disco_dispose;
+ object_class->finalize = gabble_disco_finalize;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "XMPP Discovery object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+}
+
+static void
+gabble_disco_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleDisco *chan = GABBLE_DISCO (object);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->connection);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_disco_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleDisco *chan = GABBLE_DISCO (object);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->connection = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_disco_conn_status_changed_cb (GabbleConnection *conn,
+ TpConnectionStatus status, TpConnectionStatusReason reason, gpointer data);
+
+static GObject *
+gabble_disco_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleDisco *disco;
+ GabbleDiscoPrivate *priv;
+
+ obj = G_OBJECT_CLASS (gabble_disco_parent_class)-> constructor (type,
+ n_props, props);
+ disco = GABBLE_DISCO (obj);
+ priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ g_signal_connect (priv->connection, "status-changed",
+ G_CALLBACK (gabble_disco_conn_status_changed_cb), disco);
+
+ return obj;
+}
+
+static void cancel_request (GabbleDiscoRequest *request);
+
+void
+gabble_disco_dispose (GObject *object)
+{
+ GSList *l;
+ DBusGProxy *bus_proxy;
+
+ GabbleDisco *self = GABBLE_DISCO (object);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (self);
+ bus_proxy = tp_get_bus_proxy ();
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+
+ /* cancel request removes the element from the list after cancelling */
+ while (priv->requests)
+ cancel_request (priv->requests->data);
+
+ for (l = priv->service_cache; l; l = g_slist_next (l))
+ {
+ GabbleDiscoItem *item = (GabbleDiscoItem *) l->data;
+ g_free ((char *) item->jid);
+ g_free ((char *) item->name);
+ g_free ((char *) item->type);
+ g_free ((char *) item->category);
+ g_hash_table_destroy (item->features);
+ g_free (item);
+ }
+
+ g_slist_free (priv->service_cache);
+ priv->service_cache = NULL;
+
+ if (G_OBJECT_CLASS (gabble_disco_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_disco_parent_class)->dispose (object);
+}
+
+void
+gabble_disco_finalize (GObject *object)
+{
+ gabble_debug (DEBUG_FLAG, "called with %p", object);
+
+ G_OBJECT_CLASS (gabble_disco_parent_class)->finalize (object);
+}
+
+/**
+ * gabble_disco_new:
+ * @conn: The #GabbleConnection to use for service discovery
+ *
+ * Creates an object to use for Jabber service discovery (DISCO)
+ * There should be one of these per connection
+ */
+GabbleDisco *
+gabble_disco_new (GabbleConnection *conn)
+{
+ GabbleDisco *disco;
+
+ g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), NULL);
+
+ disco = GABBLE_DISCO (g_object_new (GABBLE_TYPE_DISCO,
+ "connection", conn,
+ NULL));
+
+ return disco;
+}
+
+
+static void notify_delete_request (gpointer data, GObject *obj);
+
+static void
+delete_request (GabbleDiscoRequest *request)
+{
+ GabbleDisco *disco = request->disco;
+ GabbleDiscoPrivate *priv;
+
+ g_assert (NULL != request);
+ /* fix: Application Crashed: Main */
+ if ( disco == NULL )
+ {
+ g_debug ("%s: accesing after dereferenced connection", G_STRFUNC);
+ return;
+ }
+ g_assert (GABBLE_IS_DISCO (disco));
+
+ priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ g_assert (NULL != g_list_find (priv->requests, request));
+
+ priv->requests = g_list_remove (priv->requests, request);
+
+ if (NULL != request->bound_object)
+ {
+ g_object_weak_unref (request->bound_object, notify_delete_request, request);
+ }
+
+ if (0 != request->timer_id)
+ {
+ g_source_remove (request->timer_id);
+ }
+
+ g_free (request->jid);
+ g_free (request);
+}
+
+static gboolean
+timeout_request (gpointer data)
+{
+ GabbleDiscoRequest *request = (GabbleDiscoRequest*) data;
+ GError *err;
+ g_return_val_if_fail (data != NULL, FALSE);
+
+ err = g_error_new (GABBLE_DISCO_ERROR, GABBLE_DISCO_ERROR_TIMEOUT,
+ "Request for %s on %s timed out",
+ (request->type == GABBLE_DISCO_TYPE_INFO)?"info":"items",
+ request->jid);
+ (request->callback)(request->disco, request, request->jid, request->node,
+ NULL, err, request->user_data);
+ g_error_free (err);
+
+ request->timer_id = 0;
+ delete_request (request);
+ return FALSE;
+}
+
+static void
+cancel_request (GabbleDiscoRequest *request)
+{
+ GError *err;
+
+ g_assert (request != NULL);
+
+ err = g_error_new (GABBLE_DISCO_ERROR, GABBLE_DISCO_ERROR_CANCELLED,
+ "Request for %s on %s cancelled",
+ (request->type == GABBLE_DISCO_TYPE_INFO)?"info":"items",
+ request->jid);
+ (request->callback)(request->disco, request, request->jid, request->node,
+ NULL, err, request->user_data);
+ g_error_free (err);
+
+ delete_request (request);
+}
+
+static LmHandlerResult
+request_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object, gpointer user_data)
+{
+ LmMessageNode *query_node;
+ GError *err = NULL;
+
+ GabbleDiscoRequest *request = (GabbleDiscoRequest*) user_data;
+ GabbleDisco *disco = GABBLE_DISCO (object);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ g_assert (request);
+
+ if (!g_list_find (priv->requests, request))
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ query_node = lm_message_node_get_child (reply_msg->node, "query");
+
+ if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ LmMessageNode *error_node;
+
+ error_node = lm_message_node_get_child (reply_msg->node, "error");
+ if (error_node)
+ {
+ err = gabble_xmpp_error_to_g_error (
+ gabble_xmpp_error_from_node (error_node));
+ }
+
+ if (err == NULL)
+ {
+ err = g_error_new (GABBLE_DISCO_ERROR,
+ GABBLE_DISCO_ERROR_UNKNOWN,
+ "an unknown error occurred");
+ }
+ }
+ else if (NULL == query_node)
+ {
+ err = g_error_new (GABBLE_DISCO_ERROR, GABBLE_DISCO_ERROR_UNKNOWN,
+ "disco response contained no <query> node");
+ }
+
+ request->callback (request->disco, request, request->jid, request->node,
+ query_node, err, request->user_data);
+ delete_request (request);
+
+ if (err)
+ g_error_free (err);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+notify_delete_request (gpointer data, GObject *obj)
+{
+ GabbleDiscoRequest *request = (GabbleDiscoRequest *) data;
+ request->bound_object = NULL;
+ delete_request (request);
+}
+
+/**
+ * gabble_disco_request:
+ * @self: #GabbleDisco object to use for request
+ * @type: type of request
+ * @jid: Jabber ID to request on
+ * @node: node to request on @jid, or NULL
+ * @callback: #GabbleDiscoCb to call on request fullfilment
+ * @object: GObject to bind request to. the callback will not be
+ * called if this object has been unrefed. NULL if not needed
+ * @error: #GError to return a telepathy error in if unable to make
+ * request, NULL if unneeded.
+ *
+ * Make a disco request on the given jid with the default timeout.
+ */
+GabbleDiscoRequest *
+gabble_disco_request (GabbleDisco *self, GabbleDiscoType type,
+ const gchar *jid, const char *node,
+ GabbleDiscoCb callback, gpointer user_data,
+ GObject *object, GError **error)
+{
+ return gabble_disco_request_with_timeout (self, type, jid, node,
+ DEFAULT_REQUEST_TIMEOUT,
+ callback, user_data,
+ object, error);
+}
+
+/**
+ * gabble_disco_request_with_timeout:
+ * @self: #GabbleDisco object to use for request
+ * @type: type of request
+ * @jid: Jabber ID to request on
+ * @node: node to request on @jid, or NULL
+ * @timeout: the time until the request fails, in milliseconds (1/1000ths of a second)
+ * @callback: #GabbleDiscoCb to call on request fullfilment
+ * @object: GObject to bind request to. the callback will not be
+ * called if this object has been unrefed. NULL if not needed
+ * @error: #GError to return a telepathy error in if unable to make
+ * request, NULL if unneeded.
+ *
+ * Make a disco request on the given jid, which will fail unless a reply
+ * is received within the given timeout interval.
+ */
+GabbleDiscoRequest *
+gabble_disco_request_with_timeout (GabbleDisco *self, GabbleDiscoType type,
+ const gchar *jid, const char *node,
+ guint timeout, GabbleDiscoCb callback,
+ gpointer user_data, GObject *object,
+ GError **error)
+{
+ const gchar *xmlns;
+
+ LmMessage *msg;
+ LmMessageNode *lm_node;
+ GabbleDiscoRequest *request;
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (self);
+
+
+ request = g_new0 (GabbleDiscoRequest, 1);
+ request->disco = self;
+ request->type = type;
+ request->jid = g_strdup (jid);
+ if (node)
+ request->node = g_strdup (node);
+ request->callback = callback;
+ request->user_data = user_data;
+ request->bound_object = object;
+
+ if (NULL != object)
+ g_object_weak_ref (object, notify_delete_request, request);
+
+ gabble_debug (DEBUG_FLAG, "Creating disco request %p for %s",
+ request, request->jid);
+
+ priv->requests = g_list_prepend (priv->requests, request);
+ msg = lm_message_new_with_sub_type (jid, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ lm_node = lm_message_node_add_child (msg->node, "query", NULL);
+
+ switch (type) {
+ case GABBLE_DISCO_TYPE_INFO:
+ xmlns = NS_DISCO_INFO;
+ break;
+ case GABBLE_DISCO_TYPE_ITEMS:
+ xmlns = NS_DISCO_ITEMS;
+ break;
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+
+ lm_message_node_set_attribute (lm_node, "xmlns", xmlns);
+
+ if (node)
+ {
+ lm_message_node_set_attribute (lm_node, "node", node);
+ }
+
+ if (! _gabble_connection_send_with_reply (priv->connection, msg,
+ request_reply_cb, G_OBJECT(self), request, error))
+ {
+ delete_request (request);
+ lm_message_unref (msg);
+ return NULL;
+ }
+ else
+ {
+ request->timer_id =
+ g_timeout_add (timeout, timeout_request, request);
+ lm_message_unref (msg);
+ return request;
+ }
+}
+
+void
+gabble_disco_cancel_request (GabbleDisco *disco, GabbleDiscoRequest *request)
+{
+ GabbleDiscoPrivate *priv;
+
+ g_return_if_fail (GABBLE_IS_DISCO (disco));
+ g_return_if_fail (NULL != request);
+
+ priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ g_return_if_fail (NULL != g_list_find (priv->requests, request));
+
+ cancel_request (request);
+}
+
+/* Disco pipeline */
+
+
+typedef struct _GabbleDiscoPipeline GabbleDiscoPipeline;
+struct _GabbleDiscoPipeline {
+ GabbleDisco *disco;
+ gpointer user_data;
+ GabbleDiscoPipelineCb callback;
+ GabbleDiscoEndCb end_callback;
+ GPtrArray *disco_pipeline;
+ GHashTable *remaining_items;
+ GabbleDiscoRequest *list_request;
+ gboolean running;
+};
+
+static void
+gabble_disco_fill_pipeline (GabbleDisco *disco, GabbleDiscoPipeline *pipeline);
+
+static void
+item_info_cb (GabbleDisco *disco,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *result,
+ GError *error,
+ gpointer user_data)
+{
+ LmMessageNode *identity, *feature, *field, *value_node;
+ const char *category, *type, *var, *name, *value;
+ GHashTable *keys;
+ GabbleDiscoItem item;
+
+ GabbleDiscoPipeline *pipeline = (GabbleDiscoPipeline *) user_data;
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ g_ptr_array_remove_fast (pipeline->disco_pipeline, request);
+
+ if (error)
+ {
+ gabble_debug (DEBUG_FLAG, "got error %s", error->message);
+ goto done;
+ }
+
+ identity = lm_message_node_get_child (result, "identity");
+ if (NULL == identity)
+ goto done;
+
+ name = lm_message_node_get_attribute (identity, "name");
+ if (NULL == name)
+ goto done;
+
+ category = lm_message_node_get_attribute (identity, "category");
+ if (NULL == category)
+ goto done;
+
+ type = lm_message_node_get_attribute (identity, "type");
+ if (NULL == type)
+ goto done;
+
+ gabble_debug (DEBUG_FLAG, "got item identity, jid=%s, name=%s, category=%s, type=%s",
+ jid, name, category, type);
+
+ keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ for (feature = result->children; feature; feature = feature->next)
+ {
+ if (0 == strcmp (feature->name, "feature"))
+ {
+ var = lm_message_node_get_attribute (feature, "var");
+ if (0 == strcmp (var, NS_SEARCH))
+ {
+ priv->connection->features |= GABBLE_CONNECTION_FEATURES_SEARCH;
+ get_search_keys_info(priv->connection,jid);
+ }
+ if (var)
+ g_hash_table_insert (keys, g_strdup (var), NULL);
+ }
+ else if (0 == strcmp (feature->name, "x"))
+ {
+ if (lm_message_node_has_namespace (feature, NS_X_DATA, NULL))
+ {
+ for (field = feature->children;
+ field; field = field->next)
+ {
+ if (0 != strcmp (field->name, "field"))
+ continue;
+
+ var = lm_message_node_get_attribute (field, "var");
+ if (NULL == var)
+ continue;
+
+ value_node = lm_message_node_get_child (field, "value");
+ if (NULL == value_node)
+ continue;
+
+ value = lm_message_node_get_value (value_node);
+ if (NULL == value)
+ continue;
+
+ g_hash_table_insert (keys, g_strdup (var), g_strdup (value));
+ }
+ }
+ }
+ }
+
+ item.jid = jid;
+ item.name = name;
+ item.category = category;
+ item.type = type;
+ item.features = keys;
+
+ pipeline->callback (pipeline, &item, pipeline->user_data);
+ g_hash_table_destroy (keys);
+
+done:
+ gabble_disco_fill_pipeline (disco, pipeline);
+
+ return;
+}
+
+
+static gboolean
+return_true (gpointer key, gpointer value, gpointer data)
+{
+ return TRUE;
+}
+
+static void
+gabble_disco_fill_pipeline (GabbleDisco *disco, GabbleDiscoPipeline *pipeline)
+{
+ if (!pipeline->running)
+ {
+ gabble_debug (DEBUG_FLAG, "pipeline not running, not refilling");
+ }
+ else
+ {
+ /* send disco requests for the JIDs in the remaining_items hash table
+ * until there are DISCO_PIPELINE_SIZE requests in progress */
+ while (pipeline->disco_pipeline->len < DISCO_PIPELINE_SIZE)
+ {
+ gchar *jid;
+ GabbleDiscoRequest *request;
+
+ jid = (gchar *) g_hash_table_find (pipeline->remaining_items,
+ return_true, NULL);
+ if (NULL == jid)
+ break;
+
+ request = gabble_disco_request (disco,
+ GABBLE_DISCO_TYPE_INFO, jid, NULL, item_info_cb, pipeline,
+ G_OBJECT(disco), NULL);
+
+ g_ptr_array_add (pipeline->disco_pipeline, request);
+
+ /* frees jid */
+ g_hash_table_remove (pipeline->remaining_items, jid);
+ }
+
+ if (0 == pipeline->disco_pipeline->len)
+ {
+ /* signal that the pipeline has finished */
+ pipeline->running = FALSE;
+ pipeline->end_callback (pipeline, pipeline->user_data);
+ }
+ }
+}
+
+
+static void
+disco_items_cb (GabbleDisco *disco,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *result,
+ GError *error,
+ gpointer user_data)
+{
+ LmMessageNode *iter;
+ const char *item_jid;
+ gpointer key, value;
+ GabbleDiscoPipeline *pipeline = (GabbleDiscoPipeline *) user_data;
+
+ pipeline->list_request = NULL;
+
+ if (error)
+ {
+ gabble_debug (DEBUG_FLAG, "Got error on items request: %s", error->message);
+ goto out;
+ }
+
+ iter = result->children;
+
+ for (; iter; iter = iter->next)
+ {
+ if (0 != strcmp (iter->name, "item"))
+ continue;
+
+ item_jid = lm_message_node_get_attribute (iter, "jid");
+
+ if (NULL != item_jid &&
+ !g_hash_table_lookup_extended (pipeline->remaining_items, item_jid, &key, &value))
+ {
+ gchar *tmp = g_strdup (item_jid);
+ gabble_debug (DEBUG_FLAG, "discovered service item: %s", tmp);
+ g_hash_table_insert (pipeline->remaining_items, tmp, tmp);
+ }
+ }
+
+out:
+ gabble_disco_fill_pipeline (disco, pipeline);
+}
+
+/**
+ * gabble_disco_pipeline_init:
+ * @disco: disco object to use in the pipeline
+ * @callback: GFunc to call on request fullfilment
+ * @user_data: the usual
+ *
+ * Prepares the pipeline for making the ITEM request on the server and
+ * subsequent INFO elements on returned items.
+ *
+ * GabbleDiscoPipeline is opaque structure for the user.
+ */
+gpointer gabble_disco_pipeline_init (GabbleDisco *disco,
+ GabbleDiscoPipelineCb callback,
+ GabbleDiscoEndCb end_callback,
+ gpointer user_data)
+{
+ GabbleDiscoPipeline *pipeline = g_new (GabbleDiscoPipeline, 1);
+ pipeline->user_data = user_data;
+ pipeline->callback = callback;
+ pipeline->end_callback = end_callback;
+ pipeline->disco_pipeline = g_ptr_array_sized_new (DISCO_PIPELINE_SIZE);
+ pipeline->remaining_items = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+ pipeline->running = TRUE;
+ pipeline->disco = disco;
+
+ return pipeline;
+}
+
+/**
+ * gabble_disco_pipeline_run:
+ * @self: reference to the pipeline structure
+ * @server: server to query
+ *
+ * Makes ITEMS request on the server, and afterwards queries for INFO
+ * on each item. INFO queries are pipelined. The item properties are stored
+ * in hash table parameter to the callback function. The user is responsible
+ * for destroying the hash table after it's done with.
+ *
+ * Upon returning all the results, the end_callback is called with
+ * reference to the pipeline.
+ */
+void
+gabble_disco_pipeline_run (gpointer self, const char *server)
+{
+ GabbleDiscoPipeline *pipeline = (GabbleDiscoPipeline *) self;
+
+ pipeline->running = TRUE;
+
+ pipeline->list_request = gabble_disco_request (pipeline->disco,
+ GABBLE_DISCO_TYPE_ITEMS, server, NULL, disco_items_cb, pipeline,
+ G_OBJECT (pipeline->disco), NULL);
+}
+
+
+/**
+ * gabble_disco_pipeline_cancel:
+ * @pipeline: pipeline to cancel
+ *
+ * Flushes the pipeline (cancels all pending disco requests) and
+ * destroys it.
+ */
+void
+gabble_disco_pipeline_destroy (gpointer self)
+{
+ GabbleDiscoPipeline *pipeline = (GabbleDiscoPipeline *) self;
+
+ pipeline->running = FALSE;
+
+ if (pipeline->list_request != NULL)
+ {
+ gabble_disco_cancel_request (pipeline->disco, pipeline->list_request);
+ pipeline->list_request = NULL;
+ }
+
+ /* iterate using a while loop otherwise we're modifying
+ * the array as we iterate it, and miss things! */
+ while (pipeline->disco_pipeline->len > 0)
+ {
+ GabbleDiscoRequest *request =
+ g_ptr_array_index (pipeline->disco_pipeline, 0);
+ gabble_disco_cancel_request (pipeline->disco, request);
+ }
+
+ g_hash_table_destroy (pipeline->remaining_items);
+ g_ptr_array_free (pipeline->disco_pipeline, TRUE);
+ g_free (pipeline);
+}
+
+
+static void
+service_feature_copy_one (gpointer k, gpointer v, gpointer user_data)
+{
+ char *key = (char *) k;
+ char *value = (char *) v;
+
+ GHashTable *target = (GHashTable *) user_data;
+ g_hash_table_insert (target, g_strdup (key), g_strdup (value));
+}
+
+/* Service discovery */
+static void
+services_cb (gpointer pipeline, GabbleDiscoItem *item, gpointer user_data)
+{
+ GabbleDiscoItem *my_item = g_new0 (GabbleDiscoItem, 1);
+
+ GabbleDisco *disco = GABBLE_DISCO (user_data);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ my_item->jid = g_strdup (item->jid);
+ my_item->name = g_strdup (item->name);
+ my_item->type = g_strdup (item->type);
+ my_item->category = g_strdup (item->category);
+
+ my_item->features = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ g_hash_table_foreach (item->features, service_feature_copy_one, my_item->features);
+
+ priv->service_cache = g_slist_prepend (priv->service_cache, my_item);
+}
+
+static void
+end_cb (gpointer pipeline, gpointer user_data)
+{
+ GabbleDisco *disco = GABBLE_DISCO (user_data);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ gabble_disco_pipeline_destroy (pipeline);
+ priv->service_cache = g_slist_reverse (priv->service_cache);
+
+ /* FIXME - service discovery done - signal that somehow */
+}
+
+static void
+gabble_disco_conn_status_changed_cb (GabbleConnection *conn,
+ TpConnectionStatus status,
+ TpConnectionStatusReason reason,
+ gpointer data)
+{
+ GabbleDisco *disco = GABBLE_DISCO (data);
+ GabbleDiscoPrivate *priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ if (status == TP_CONN_STATUS_CONNECTED)
+ {
+ char *server;
+ gpointer pipeline = gabble_disco_pipeline_init (disco, services_cb,
+ end_cb, disco);
+
+ g_object_get (priv->connection, "stream-server", &server, NULL);
+
+ g_assert (server != NULL);
+
+ gabble_debug (DEBUG_FLAG, "connected, initiating service discovery on %s", server);
+ gabble_disco_pipeline_run (pipeline, server);
+
+ g_free (server);
+ }
+}
+
+const GabbleDiscoItem *
+gabble_disco_service_find (GabbleDisco *disco,
+ const char *type,
+ const char *category,
+ const char *feature)
+{
+ GabbleDiscoPrivate *priv;
+ GSList *l;
+
+ g_assert (GABBLE_IS_DISCO (disco));
+ priv = GABBLE_DISCO_GET_PRIVATE (disco);
+
+ for (l = priv->service_cache; l; l = g_slist_next (l))
+ {
+ GabbleDiscoItem *item = (GabbleDiscoItem *) l->data;
+ gboolean selected = TRUE;
+
+ if (type != NULL && g_strdiff (type, item->type))
+ selected = FALSE;
+
+ if (category != NULL && g_strdiff (category, item->category))
+ selected = FALSE;
+
+ if (feature != NULL)
+ {
+ gpointer k, v;
+ if (!g_hash_table_lookup_extended (item->features, feature, &k, &v))
+ selected = FALSE;
+ }
+
+ if (selected)
+ return item;
+ }
+
+ return NULL;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/exegabble.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,210 @@
+/*
+ * gabble.h - entry point and utility functions for telepathy-gabble
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <dbus/dbus-glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif /* HAVE_EXECINFO_H */
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif /* HAVE_SIGNAL_H */
+
+#include "debug.h"
+#include "gabble-connection-manager.h"
+#include "telepathy-errors.h"
+#include "telepathy-errors-enumtypes.h"
+
+GSource *timeout = NULL;
+GMainLoop *mainloop = NULL;
+GabbleConnectionManager *manager = NULL;
+gboolean connections_exist = FALSE;
+guint timeout_id;
+
+#define DIE_TIME 5000
+
+static gboolean
+kill_connection_manager (gpointer data)
+{
+#ifdef ENABLE_DEBUG
+ if (!gabble_debug_flag_is_set (GABBLE_DEBUG_PERSIST) && !connections_exist)
+#else
+ if (!connections_exist)
+#endif
+ {
+ g_debug ("no connections, and timed out");
+ g_object_unref (manager);
+ g_main_loop_quit (mainloop);
+ }
+
+ timeout_id = 0;
+ return FALSE;
+}
+
+static void
+new_connection (GabbleConnectionManager *conn,
+ gchar *bus_name,
+ gchar *object_path,
+ gchar *proto)
+{
+ connections_exist = TRUE;
+
+ if (0 != timeout_id)
+ {
+ g_source_remove (timeout_id);
+ }
+}
+
+static void
+no_more_connections (GabbleConnectionManager *conn)
+{
+ connections_exist = FALSE;
+
+ if (0 != timeout_id)
+ {
+ g_source_remove (timeout_id);
+ }
+
+ timeout_id = g_timeout_add (DIE_TIME, kill_connection_manager, NULL);
+}
+
+#ifdef ENABLE_BACKTRACE
+static void
+print_backtrace (void)
+{
+#if defined (HAVE_BACKTRACE) && defined (HAVE_BACKTRACE_SYMBOLS_FD)
+ void *array[20];
+ size_t size;
+
+#define MSG "\n########## Backtrace (version " VERSION ") ##########\n"
+ write (STDERR_FILENO, MSG, strlen (MSG));
+#undef MSG
+
+ size = backtrace (array, 20);
+ backtrace_symbols_fd (array, size, STDERR_FILENO);
+#endif /* HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS_FD */
+}
+
+static void
+critical_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ g_log_default_handler (log_domain, log_level, message, user_data);
+ print_backtrace ();
+}
+
+#ifdef HAVE_SIGNAL
+static void
+segv_handler (int sig)
+{
+#define MSG "caught SIGSEGV\n"
+ write (STDERR_FILENO, MSG, strlen (MSG));
+#undef MSG
+
+ print_backtrace ();
+ abort ();
+}
+#endif /* HAVE_SIGNAL */
+
+#endif /* ENABLE_BACKTRACE */
+
+static void
+add_signal_handlers (void)
+{
+#if defined(HAVE_SIGNAL) && defined(ENABLE_BACKTRACE)
+ signal (SIGSEGV, segv_handler);
+#endif /* HAVE_SIGNAL && ENABLE_BACKTRACE */
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ add_signal_handlers ();
+
+ g_type_init();
+
+ g_set_prgname("telepathy-gabble");
+
+/* bsr #ifdef ENABLE_DEBUG*/
+ gabble_debug_set_flags_from_env ();
+
+ if (g_getenv ("GABBLE_PERSIST"))
+ gabble_debug_set_flags (0xffff);
+/*#endif bsr */
+
+ {
+ GLogLevelFlags fatal_mask;
+
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
+
+#ifdef ENABLE_BACKTRACE
+ g_log_set_handler ("GLib-GObject",
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR |
+ G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ critical_handler, NULL);
+ g_log_set_handler ("GLib",
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR |
+ G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ critical_handler, NULL);
+ g_log_set_handler (NULL,
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR |
+ G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ critical_handler, NULL);
+#endif /* ENABLE_BACKTRACE */
+ }
+
+ g_message("before gabble mainloop new \n");
+ getchar();
+ exit(1);
+ mainloop = g_main_loop_new (NULL, FALSE);
+
+ dbus_g_error_domain_register (TELEPATHY_ERRORS,
+ "org.freedesktop.Telepathy.Error", TELEPATHY_TYPE_ERRORS);
+
+ manager = g_object_new (GABBLE_TYPE_CONNECTION_MANAGER, NULL);
+
+ g_signal_connect (manager, "new-connection",
+ (GCallback) new_connection, NULL);
+
+ g_signal_connect (manager, "no-more-connections",
+ (GCallback) no_more_connections, NULL);
+
+ g_message("calling gabble_connection_manager_register \n");
+ _gabble_connection_manager_register (manager);
+
+ g_message("started version " VERSION);
+
+ //timeout_id = g_timeout_add (DIE_TIME, kill_connection_manager, NULL);
+
+ g_main_loop_run (mainloop);
+
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-connection-manager-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,107 @@
+/*
+ * gabble-connection-manager-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:STRING,STRING,STRING (gabble-connection-manager-signals-marshal.list:1) */
+void
+gabble_connection_manager_marshal_VOID__STRING_STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer data2);
+
+ register GMarshalFunc_VOID__STRING_STRING_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-connection-manager.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,705 @@
+/*
+ * gabble-connection-manager.c - Source for GabbleConnectionManager
+ * Copyright (C) 2005 Collabora Ltd.
+ * and/or its subsidiary/subsidiaries. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-protocol.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gabble-connection.h"
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+
+#include "gabble-connection-manager.h"
+#include "gabble-connection-manager-glue.h"
+#include "gabble-connection-manager-signals-marshal.h"
+
+#include "gabble_enums.h"
+
+#define TP_TYPE_PARAM (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_STRING, \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_VALUE, \
+ G_TYPE_INVALID))
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleConnectionManager, gabble_connection_manager, G_TYPE_OBJECT)
+#endif
+
+
+/* signal enum */
+enum
+{
+ NEW_CONNECTION,
+ NO_MORE_CONNECTIONS,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_CON_MGR
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_conmgr,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_conmgr, s)())
+
+ GET_STATIC_VAR_FROM_TLS(ssl,gabble_conmgr,gboolean)
+ #define ssl (*GET_WSD_VAR_NAME(ssl,gabble_conmgr,s)())
+
+ GET_STATIC_VAR_FROM_TLS(httpport,gabble_conmgr,guint)
+ #define httpport (*GET_WSD_VAR_NAME(httpport,gabble_conmgr,s)())
+
+ GET_STATIC_VAR_FROM_TLS(httpproxyport,gabble_conmgr,guint)
+ #define httpproxyport (*GET_WSD_VAR_NAME(httpproxyport,gabble_conmgr,s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_connection_manager_parent_class,gabble_conmgr,gpointer)
+ #define gabble_connection_manager_parent_class (*GET_WSD_VAR_NAME(gabble_connection_manager_parent_class,gabble_conmgr,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_conmgr,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_conmgr,s)())
+
+
+static void gabble_connection_manager_init (GabbleConnectionManager *self);
+static void gabble_connection_manager_class_init (GabbleConnectionManagerClass *klass);
+static void gabble_connection_manager_class_intern_init (gpointer klass)
+{
+gabble_connection_manager_parent_class = g_type_class_peek_parent (klass);
+gabble_connection_manager_class_init ((GabbleConnectionManagerClass*) klass);
+}
+EXPORT_C GType gabble_connection_manager_get_type (void)
+{
+
+if ((g_define_type_id == 0))
+{
+static const GTypeInfo g_define_type_info =
+ { sizeof (GabbleConnectionManagerClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_connection_manager_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleConnectionManager), 0, (GInstanceInitFunc) gabble_connection_manager_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleConnectionManager"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ } ;
+
+
+#else
+
+static guint signals[LAST_SIGNAL] = {0};
+
+static gboolean ssl = TRUE;
+static guint httpport = 8080;
+static guint httpproxyport = 443;
+
+#endif
+
+/* private structure */
+typedef struct _GabbleConnectionManagerPrivate GabbleConnectionManagerPrivate;
+
+struct _GabbleConnectionManagerPrivate
+{
+ gboolean dispose_has_run;
+ GHashTable *connections;
+};
+
+#define GABBLE_CONNECTION_MANAGER_GET_PRIVATE(obj) \
+ ((GabbleConnectionManagerPrivate *)obj->priv)
+
+/* type definition stuff */
+
+static void
+gabble_connection_manager_init (GabbleConnectionManager *self)
+{
+ GabbleConnectionManagerPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_CONNECTION_MANAGER, GabbleConnectionManagerPrivate);
+
+ self->priv = priv;
+
+ priv->connections = g_hash_table_new (g_direct_hash, g_direct_equal);
+}
+
+static void gabble_connection_manager_dispose (GObject *object);
+static void gabble_connection_manager_finalize (GObject *object);
+
+static void
+gabble_connection_manager_class_init (GabbleConnectionManagerClass *gabble_connection_manager_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_connection_manager_class);
+
+ g_type_class_add_private (gabble_connection_manager_class, sizeof (GabbleConnectionManagerPrivate));
+
+ g_message("**NEW LOGS** inside gabble_connection_manager_class_init \n");
+
+ object_class->dispose = gabble_connection_manager_dispose;
+ object_class->finalize = gabble_connection_manager_finalize;
+
+ signals [NEW_CONNECTION] =
+ g_signal_new ("new-connection",
+ G_OBJECT_CLASS_TYPE (gabble_connection_manager_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_connection_manager_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, 3, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING);
+
+ signals [NO_MORE_CONNECTIONS] =
+ g_signal_new ("no-more-connections",
+ G_OBJECT_CLASS_TYPE (gabble_connection_manager_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_connection_manager_class), &dbus_glib_gabble_connection_manager_object_info);
+}
+
+void
+gabble_connection_manager_dispose (GObject *object)
+{
+ GabbleConnectionManager *self = GABBLE_CONNECTION_MANAGER (object);
+ GabbleConnectionManagerPrivate *priv = GABBLE_CONNECTION_MANAGER_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ /* release any references held by the object here */
+
+ if (G_OBJECT_CLASS (gabble_connection_manager_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_connection_manager_parent_class)->dispose (object);
+}
+
+void
+gabble_connection_manager_finalize (GObject *object)
+{
+ GabbleConnectionManager *self = GABBLE_CONNECTION_MANAGER (object);
+ GabbleConnectionManagerPrivate *priv = GABBLE_CONNECTION_MANAGER_GET_PRIVATE (self);
+
+ g_hash_table_destroy(priv->connections);
+
+ G_OBJECT_CLASS (gabble_connection_manager_parent_class)->finalize (object);
+}
+
+
+enum {
+ JABBER_PARAM_ACCOUNT = 0,
+ JABBER_PARAM_PASSWORD,
+ JABBER_PARAM_SERVER,
+ JABBER_PARAM_RESOURCE,
+ JABBER_PARAM_PRIORITY,
+ JABBER_PARAM_PORT,
+ JABBER_PARAM_OLD_SSL,
+ JABBER_PARAM_REGISTER,
+ JABBER_PARAM_LOW_BANDWIDTH,
+ JABBER_PARAM_HTTPS_PROXY_SERVER,
+ JABBER_PARAM_HTTPS_PROXY_PORT,
+ JABBER_PARAM_FALLBACK_CONFERENCE_SERVER,
+ JABBER_PARAM_STUN_SERVER,
+ JABBER_PARAM_STUN_PORT,
+ JABBER_PARAM_IGNORE_SSL_ERRORS,
+ JABBER_PARAM_ALIAS,
+ LAST_JABBER_PARAM
+};
+/* private methods */
+
+static gboolean
+get_parameters (const char *proto, const GabbleParamSpec **params, GError **error)
+{
+ if (!strcmp (proto, "jabber"))
+ {
+ *params = jabber_params;
+ }
+ else
+ {
+ g_debug ("%s: unknown protocol %s", G_STRFUNC, proto);
+
+ g_set_error (error, TELEPATHY_ERRORS, NotImplemented,
+ "unknown protocol %s", proto);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static GValue *param_default_value (const GabbleParamSpec *params, int i)
+{
+ GValue *value;
+
+ value = g_new0(GValue, 1);
+ g_value_init(value, params[i].gtype);
+
+ /* TODO: this check could be stricter if we knew whether register
+ was true. In practice REQUIRED and REGISTER always go together in
+ the Gabble params, though */
+ if (params[i].flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED & TP_CONN_MGR_PARAM_FLAG_REGISTER)
+ {
+ g_assert(params[i].def == NULL);
+ goto OUT;
+ }
+
+ switch (params[i].dtype[0])
+ {
+ case DBUS_TYPE_STRING:
+ g_value_set_static_string (value, (const gchar*) params[i].def);
+ break;
+ case DBUS_TYPE_INT16:
+ g_value_set_int (value, GPOINTER_TO_INT (params[i].def));
+ break;
+ case DBUS_TYPE_UINT16:
+ g_value_set_uint (value, GPOINTER_TO_INT (params[i].def));
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ g_value_set_boolean (value, GPOINTER_TO_INT (params[i].def));
+ break;
+ default:
+ g_error("parameter_defaults: encountered unknown type %s on argument %s",
+ params[i].dtype, params[i].name);
+ }
+
+OUT:
+ return value;
+}
+
+static gboolean
+set_param_from_value (const GabbleParamSpec *paramspec,
+ GValue *value,
+ GabbleParams *params,
+ GError **error)
+{
+ if (G_VALUE_TYPE (value) != paramspec->gtype)
+ {
+ g_debug ("%s: expected type %s for parameter %s, got %s",
+ G_STRFUNC,
+ g_type_name (paramspec->gtype), paramspec->name,
+ G_VALUE_TYPE_NAME (value));
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "expected type %s for account parameter %s, got %s",
+ g_type_name (paramspec->gtype), paramspec->name,
+ G_VALUE_TYPE_NAME (value));
+ return FALSE;
+ }
+
+ switch (paramspec->dtype[0])
+ {
+ case DBUS_TYPE_STRING:
+ {
+ const char *str = g_value_get_string (value);
+ if (!str || *str == '\0')
+ return FALSE;
+ else
+ *((char **) ((char *)params + paramspec->offset)) = g_value_dup_string (value);
+ }
+ break;
+ case DBUS_TYPE_INT16:
+ *((gint *) ((char *)params + paramspec->offset)) = g_value_get_int (value);
+ break;
+ case DBUS_TYPE_UINT16:
+ *((guint *) ((char *)params + paramspec->offset)) = g_value_get_uint (value);
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ *((gboolean *) ((char *)params + paramspec->offset)) = g_value_get_boolean (value);
+ break;
+ default:
+ g_error ("set_param_from_value: encountered unknown type %s on argument %s",
+ paramspec->dtype, paramspec->name);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+parse_parameters (const GabbleParamSpec *paramspec,
+ GHashTable *provided,
+ GabbleParams *params,
+ GError **error)
+{
+ int unhandled;
+ int i;
+ guint mandatory_flag = TP_CONN_MGR_PARAM_FLAG_REQUIRED;
+ GValue *value;
+
+ unhandled = g_hash_table_size (provided);
+
+ value = g_hash_table_lookup (provided, "register");
+ if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_BOOLEAN &&
+ g_value_get_boolean(value))
+ {
+ mandatory_flag = TP_CONN_MGR_PARAM_FLAG_REGISTER;
+ }
+
+ for (i = 0; paramspec[i].name; i++)
+ {
+ value = g_hash_table_lookup (provided, paramspec[i].name);
+
+ if (value == NULL)
+ {
+ if (paramspec[i].flags & mandatory_flag)
+ {
+ g_debug ("%s: missing mandatory param %s",
+ G_STRFUNC, paramspec[i].name);
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "missing mandatory account parameter %s", paramspec[i].name);
+ return FALSE;
+ }
+ else
+ {
+ g_debug ("%s: using default value for param %s",
+ G_STRFUNC, paramspec[i].name);
+ }
+ }
+ else
+ {
+ if (!set_param_from_value (¶mspec[i], value, params, error))
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid value for parameter %s", paramspec[i].name);
+ return FALSE;
+ }
+
+ params->set_mask |= 1 << i;
+
+ unhandled--;
+ if (paramspec[i].gtype == G_TYPE_STRING)
+ {
+ if (0 == strcmp (paramspec[i].name, "password"))
+ {
+ g_debug ("%s: accepted value <hidden> for param password",
+ G_STRFUNC);
+ }
+ else
+ {
+ g_debug ("%s: accepted value %s for param %s",
+ G_STRFUNC,
+ *((char **) ((char *)params + paramspec[i].offset)),
+ paramspec[i].name);
+ }
+ }
+ else
+ {
+ g_debug ("%s: accepted value %u for param %s", G_STRFUNC,
+ *((guint *) ((char *)params + paramspec[i].offset)), paramspec[i].name);
+ }
+ }
+ }
+
+ if (unhandled)
+ {
+ g_debug ("%s: unknown argument name provided", G_STRFUNC);
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "unknown argument name provided");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+free_params (GabbleParams *params)
+{
+ g_free (params->account);
+ g_free (params->password);
+ g_free (params->server);
+ g_free (params->resource);
+ g_free (params->https_proxy_server);
+ g_free (params->fallback_conference_server);
+ g_free (params->stun_server);
+ g_free (params->alias);
+}
+
+/**
+ * connection_disconnected_cb:
+ * @conn: #GabbleConnection
+ * @data: data passed in callback
+ *
+ * Signal handler called when a connection object disconnects.
+ * When they become disconnected, we can unref and discard
+ * them, and they will disappear from the bus.
+ */
+static void
+connection_disconnected_cb (GabbleConnection *conn,
+ gpointer data)
+{
+ GabbleConnectionManager *self = GABBLE_CONNECTION_MANAGER (data);
+ GabbleConnectionManagerPrivate *priv = GABBLE_CONNECTION_MANAGER_GET_PRIVATE (self);
+
+ g_assert (g_hash_table_lookup (priv->connections, conn));
+
+ /* fix: this check should only be done if priv->connections is not null, and conn is not null */
+
+ if( (priv->connections) && (conn))
+ g_hash_table_remove (priv->connections, conn);
+
+ /* end of fix */
+
+ g_object_unref (conn);
+
+ g_debug ("%s: dereferenced connection", G_STRFUNC);
+ if(priv->connections)
+ if (g_hash_table_size (priv->connections) == 0)
+ {
+ g_signal_emit (self, signals [NO_MORE_CONNECTIONS], 0);
+ g_debug ("%s: emitting no more connections", G_STRFUNC);
+ }
+
+
+}
+
+/* public methods */
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+void
+_gabble_connection_manager_register (GabbleConnectionManager *self)
+{
+ DBusGConnection *bus;
+ DBusGProxy *bus_proxy;
+ GError *error = NULL;
+ guint request_name_result;
+
+ g_assert (GABBLE_IS_CONNECTION_MANAGER (self));
+
+ bus = tp_get_bus ();
+ bus_proxy = tp_get_bus_proxy ();
+
+ if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error,
+ G_TYPE_STRING, GABBLE_CONN_MGR_BUS_NAME,
+ G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ g_error ("Failed to request bus name: %s", error->message);
+
+ if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS)
+ {
+ g_warning ("Failed to acquire bus name, connection manager already running?");
+ exit (1);
+ }
+
+ dbus_g_connection_register_g_object (bus, GABBLE_CONN_MGR_OBJECT_PATH, G_OBJECT (self));
+}
+
+/* dbus-exported methods */
+
+/**
+ * gabble_connection_manager_get_parameters
+ *
+ * Implements D-Bus method GetParameters
+ * on interface org.freedesktop.Telepathy.ConnectionManager
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_manager_get_parameters (GabbleConnectionManager *self,
+ const gchar *proto,
+ GPtrArray **ret,
+ GError **error)
+{
+ const GabbleParamSpec *params = NULL;
+ int i;
+
+ if (!get_parameters (proto, ¶ms, error))
+ return FALSE;
+
+ *ret = g_ptr_array_new ();
+
+ for (i = 0; params[i].name; i++)
+ {
+ GValue *def_value;
+ GValue param = { 0, };
+
+ g_value_init (¶m, TP_TYPE_PARAM);
+ g_value_set_static_boxed (¶m,
+ dbus_g_type_specialized_construct (TP_TYPE_PARAM));
+
+ def_value = param_default_value (params, i);
+ dbus_g_type_struct_set (¶m,
+ 0, params[i].name,
+ 1, params[i].flags,
+ 2, params[i].dtype,
+ 3, def_value,
+ G_MAXUINT);
+ g_value_unset(def_value);
+ g_free(def_value);
+
+ g_ptr_array_add (*ret, g_value_get_boxed (¶m));
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_manager_list_protocols
+ *
+ * Implements D-Bus method ListProtocols
+ * on interface org.freedesktop.Telepathy.ConnectionManager
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_manager_list_protocols (GabbleConnectionManager *self,
+ gchar ***ret,
+ GError **error)
+{
+ const char *protocols[] = { "jabber", NULL };
+ g_message("BINGO...gabble_connection_manager_list_protocols entered \n");
+
+ *ret = g_strdupv ((gchar **)protocols);
+
+ g_message("BINGO...leaving gabble_connection_manager_list_protocols \n");
+
+ return TRUE;
+}
+
+
+#define SET_PROPERTY_IF_PARAM_SET(prop, param, member) \
+ if ((params.set_mask & (1 << param)) != 0) \
+ { \
+ g_object_set (conn, prop, member, NULL); \
+ }
+
+
+/**
+ * gabble_connection_manager_request_connection
+ *
+ * Implements D-Bus method RequestConnection
+ * on interface org.freedesktop.Telepathy.ConnectionManager
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_manager_request_connection (GabbleConnectionManager *self,
+ const gchar *proto,
+ GHashTable *parameters,
+ gchar **bus_name,
+ gchar **object_path,
+ GError **error)
+{
+ GabbleConnectionManagerPrivate *priv;
+ GabbleConnection *conn;
+ const GabbleParamSpec *paramspec;
+ GabbleParams params = { 0, };
+
+ g_assert (GABBLE_IS_CONNECTION_MANAGER (self));
+
+ priv = GABBLE_CONNECTION_MANAGER_GET_PRIVATE (self);
+
+ if (!get_parameters (proto, ¶mspec, error))
+ return FALSE;
+
+
+ if (!parse_parameters (paramspec, parameters, ¶ms, error))
+ {
+ free_params (¶ms);
+ return FALSE;
+ }
+
+ conn = g_object_new (GABBLE_TYPE_CONNECTION,
+ "protocol", proto,
+ "password", params.password,
+ NULL);
+
+ g_message("BINGO...after g_object_new \n");
+
+ SET_PROPERTY_IF_PARAM_SET ("connect-server", JABBER_PARAM_SERVER,
+ params.server);
+ SET_PROPERTY_IF_PARAM_SET ("resource", JABBER_PARAM_RESOURCE,
+ params.resource);
+ SET_PROPERTY_IF_PARAM_SET ("priority", JABBER_PARAM_PRIORITY,
+ CLAMP (params.priority, G_MININT8, G_MAXINT8));
+ SET_PROPERTY_IF_PARAM_SET ("port", JABBER_PARAM_PORT, params.port);
+ SET_PROPERTY_IF_PARAM_SET ("old-ssl", JABBER_PARAM_OLD_SSL, params.old_ssl);
+ SET_PROPERTY_IF_PARAM_SET ("register", JABBER_PARAM_REGISTER,
+ params.do_register);
+ SET_PROPERTY_IF_PARAM_SET ("low-bandwidth", JABBER_PARAM_LOW_BANDWIDTH,
+ params.low_bandwidth);
+ SET_PROPERTY_IF_PARAM_SET ("https-proxy-server",
+ JABBER_PARAM_HTTPS_PROXY_SERVER,
+ params.https_proxy_server);
+ SET_PROPERTY_IF_PARAM_SET ("https-proxy-port", JABBER_PARAM_HTTPS_PROXY_PORT,
+ params.https_proxy_port);
+ SET_PROPERTY_IF_PARAM_SET ("fallback-conference-server",
+ JABBER_PARAM_FALLBACK_CONFERENCE_SERVER,
+ params.fallback_conference_server);
+ SET_PROPERTY_IF_PARAM_SET ("stun-server", JABBER_PARAM_STUN_SERVER,
+ params.stun_server);
+ SET_PROPERTY_IF_PARAM_SET ("stun-port", JABBER_PARAM_STUN_PORT,
+ params.stun_port);
+ SET_PROPERTY_IF_PARAM_SET ("ignore-ssl-errors",
+ JABBER_PARAM_IGNORE_SSL_ERRORS,
+ params.ignore_ssl_errors);
+ SET_PROPERTY_IF_PARAM_SET ("alias", JABBER_PARAM_ALIAS, params.alias);
+
+ // split up account into username, stream-server and resource
+ if (!_gabble_connection_set_properties_from_account (conn, params.account, error))
+ {
+ goto ERROR;
+ }
+
+ // free memory allocated by param parser
+ free_params(¶ms);
+
+// with hash table usage - end
+
+
+ // register on bus and save bus name and object path
+ if (!_gabble_connection_register (conn, bus_name, object_path, error))
+ {
+ g_debug ("%s failed: %s", G_STRFUNC, (*error)->message);
+
+ goto ERROR;
+ }
+
+ /* bind to status change signals from the connection object */
+ g_signal_connect (conn, "disconnected",
+ G_CALLBACK (connection_disconnected_cb),
+ self);
+
+ /* store the connection, using a hash table as a set */
+ g_hash_table_insert (priv->connections, conn, GINT_TO_POINTER(TRUE));
+
+ /* emit the new connection signal */
+ g_signal_emit (self, signals [NEW_CONNECTION], 0, *bus_name, *object_path, proto);
+
+ return TRUE;
+
+ERROR:
+ if (conn)
+ g_object_unref (G_OBJECT (conn));
+
+ g_message("ERROR...returning FALSE\n");
+ return FALSE;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-connection-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,146 @@
+/*
+ * gabble-connection-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:STRING,STRING,UINT,UINT,BOOLEAN (gabble-connection-signals-marshal.list:1) */
+void
+gabble_connection_marshal_VOID__STRING_STRING_UINT_UINT_BOOLEAN (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_STRING_UINT_UINT_BOOLEAN) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ guint arg_3,
+ guint arg_4,
+ gboolean arg_5,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_STRING_UINT_UINT_BOOLEAN callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 6);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_STRING_UINT_UINT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_uint (param_values + 4),
+ g_marshal_value_peek_boolean (param_values + 5),
+ data2);
+}
+
+/* VOID:UINT,UINT (gabble-connection-signals-marshal.list:2) */
+void
+gabble_connection_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-connection.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,5227 @@
+/*
+ * gabble-connection.c - Source for GabbleConnection
+ * Copyright (C) 2005 Collabora Ltd.
+ * and/or its subsidiary/subsidiaries. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <glib-object.h>
+#include "loudmouth/loudmouth.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+
+#include "handles.h"
+#include "handle-set.h"
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "telepathy-interfaces.h"
+#include "loudmouth/lm-connection.h"
+
+#include "tp-channel-iface.h"
+#include "tp-channel-factory-iface.h"
+
+#include "gabble-connection.h"
+#include "gabble-connection-glue.h"
+#include "gabble-connection-signals-marshal.h"
+
+
+#include "capabilities.h"
+#include "debug.h"
+#include "disco.h"
+#include "gabble-presence-cache.h"
+#include "gabble-presence.h"
+#include "gabble-register.h"
+#include "im-factory.h"
+#include "search-factory.h"
+#include "jingle-info.h"
+#include "media-factory.h"
+#include "muc-factory.h"
+#include "namespaces.h"
+#include "roster.h"
+#include "util.h"
+#include "vcard-manager.h"
+#include "search-keys-info.h"
+
+#include "gabble-media-channel.h"
+#include "gabble-roomlist-channel.h"
+
+#include "gabble_enums.h"
+#include "sha1.h"
+#include "base64.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_CONNECTION
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define BUS_NAME "org.freedesktop.Telepathy.Connection.gabble"
+#define OBJECT_PATH "/org/freedesktop/Telepathy/Connection/gabble"
+
+#define TP_ALIAS_PAIR_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))
+#define TP_CAPABILITY_PAIR_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
+#define TP_CAPABILITIES_CHANGED_MONSTER_TYPE (dbus_g_type_get_struct \
+ ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, \
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID))
+#define TP_GET_CAPABILITIES_MONSTER_TYPE (dbus_g_type_get_struct \
+ ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, \
+ G_TYPE_INVALID))
+#define TP_CHANNEL_LIST_ENTRY_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, \
+ G_TYPE_INVALID))
+
+#define ERROR_IF_NOT_CONNECTED(CONN, ERROR) \
+ if ((CONN)->status != TP_CONN_STATUS_CONNECTED) \
+ { \
+ gabble_debug (DEBUG_FLAG, "rejected request as disconnected"); \
+ g_set_error (ERROR, TELEPATHY_ERRORS, NotAvailable, \
+ "Connection is disconnected"); \
+ return FALSE; \
+ }
+
+#define ERROR_IF_NOT_CONNECTED_ASYNC(CONN, ERROR, CONTEXT) \
+ if ((CONN)->status != TP_CONN_STATUS_CONNECTED) \
+ { \
+ gabble_debug (DEBUG_FLAG, "rejected request as disconnected"); \
+ (ERROR) = g_error_new (TELEPATHY_ERRORS, NotAvailable, \
+ "Connection is disconnected"); \
+ dbus_g_method_return_error ((CONTEXT), (ERROR)); \
+ g_error_free ((ERROR)); \
+ return; \
+ }
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleConnection, gabble_connection, G_TYPE_OBJECT)
+#endif
+
+typedef struct _StatusInfo StatusInfo;
+
+struct _StatusInfo
+{
+ const gchar *name;
+ TpConnectionPresenceType presence_type;
+ const gboolean self;
+ const gboolean exclusive;
+};
+
+/* order must match PresenceId enum in gabble-connection.h */
+/* in increasing order of presence */
+static const StatusInfo gabble_statuses[LAST_GABBLE_PRESENCE] = {
+ { "offline", TP_CONN_PRESENCE_TYPE_OFFLINE, TRUE, TRUE },
+ { "hidden", TP_CONN_PRESENCE_TYPE_HIDDEN, TRUE, TRUE },
+ { "xa", TP_CONN_PRESENCE_TYPE_EXTENDED_AWAY, TRUE, TRUE },
+ { "away", TP_CONN_PRESENCE_TYPE_AWAY, TRUE, TRUE },
+ { "dnd", TP_CONN_PRESENCE_TYPE_AWAY, TRUE, TRUE },
+ { "available", TP_CONN_PRESENCE_TYPE_AVAILABLE, TRUE, TRUE },
+ { "chat", TP_CONN_PRESENCE_TYPE_AVAILABLE, TRUE, TRUE }
+};
+
+/* signal enum */
+enum
+{
+ ALIASES_CHANGED,
+ CAPABILITIES_CHANGED,
+ NEW_CHANNEL,
+ PRESENCE_UPDATE,
+ STATUS_CHANGED,
+ DISCONNECTED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_CON
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_con,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_con, s)())
+
+
+ GET_STATIC_VAR_FROM_TLS(arguments,gabble_con,GHashTable*)
+ #define arguments (*GET_WSD_VAR_NAME(arguments,gabble_con, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_connection_parent_class,gabble_con,gpointer)
+ #define gabble_connection_parent_class (*GET_WSD_VAR_NAME(gabble_connection_parent_class,gabble_con,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_con,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_con,s)())
+
+ //GET_STATIC_ARRAY_FROM_TLS(assumed_caps,gabble_con,gchar*)
+ /*gchar** _s_gabble_con_assumed_caps() { return (gchar**)((libgabble_ImpurePtr()->_s_gabble_con_assumed_caps)); }
+
+ #define assumed_caps (GET_WSD_VAR_NAME(assumed_caps,gabble_con, s)()) */
+
+
+
+static void gabble_connection_init (GabbleConnection *self);
+static void gabble_connection_class_init (GabbleConnectionClass *klass);
+static void gabble_connection_class_intern_init (gpointer klass)
+{
+gabble_connection_parent_class = g_type_class_peek_parent (klass);
+gabble_connection_class_init ((GabbleConnectionClass*) klass);
+}
+EXPORT_C GType gabble_connection_get_type (void)
+{
+
+if ((g_define_type_id == 0))
+{
+static const GTypeInfo g_define_type_info =
+ { sizeof (GabbleConnectionClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_connection_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleConnection), 0, (GInstanceInitFunc) gabble_connection_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleConnection"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ } ;
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+/* properties */
+enum
+{
+ PROP_PROTOCOL = 1,
+ PROP_CONNECT_SERVER,
+ PROP_PORT,
+ PROP_OLD_SSL,
+ PROP_REGISTER,
+ PROP_LOW_BANDWIDTH,
+ PROP_STREAM_SERVER,
+ PROP_USERNAME,
+ PROP_PASSWORD,
+ PROP_RESOURCE,
+ PROP_PRIORITY,
+ PROP_HTTPS_PROXY_SERVER,
+ PROP_HTTPS_PROXY_PORT,
+ PROP_FALLBACK_CONFERENCE_SERVER,
+ PROP_STUN_SERVER,
+ PROP_STUN_PORT,
+ PROP_STUN_RELAY_MAGIC_COOKIE,
+ PROP_STUN_RELAY_SERVER,
+ PROP_STUN_RELAY_UDP_PORT,
+ PROP_STUN_RELAY_TCP_PORT,
+ PROP_STUN_RELAY_SSLTCP_PORT,
+ PROP_STUN_RELAY_USERNAME,
+ PROP_STUN_RELAY_PASSWORD,
+ PROP_IGNORE_SSL_ERRORS,
+ PROP_ALIAS,
+
+ LAST_PROPERTY
+};
+
+/* TP properties */
+enum
+{
+ CONN_PROP_STUN_SERVER = 0,
+ CONN_PROP_STUN_PORT,
+ CONN_PROP_STUN_RELAY_MAGIC_COOKIE,
+ CONN_PROP_STUN_RELAY_SERVER,
+ CONN_PROP_STUN_RELAY_UDP_PORT,
+ CONN_PROP_STUN_RELAY_TCP_PORT,
+ CONN_PROP_STUN_RELAY_SSLTCP_PORT,
+ CONN_PROP_STUN_RELAY_USERNAME,
+ CONN_PROP_STUN_RELAY_PASSWORD,
+
+ NUM_CONN_PROPS,
+
+ INVALID_CONN_PROP,
+};
+
+const GabblePropertySignature connection_property_signatures[NUM_CONN_PROPS] = {
+ { "stun-server", G_TYPE_STRING },
+ { "stun-port", G_TYPE_UINT },
+ { "stun-relay-magic-cookie", G_TYPE_STRING },
+ { "stun-relay-server", G_TYPE_STRING },
+ { "stun-relay-udp-port", G_TYPE_UINT },
+ { "stun-relay-tcp-port", G_TYPE_UINT },
+ { "stun-relay-ssltcp-port", G_TYPE_UINT },
+ { "stun-relay-username", G_TYPE_STRING },
+ { "stun-relay-password", G_TYPE_STRING },
+};
+
+/* private structure */
+typedef struct _GabbleConnectionPrivate GabbleConnectionPrivate;
+
+struct _GabbleConnectionPrivate
+{
+ LmMessageHandler *iq_jingle_info_cb;
+ LmMessageHandler *iq_search_keys_cb;
+ LmMessageHandler *iq_disco_cb;
+ LmMessageHandler *iq_unknown_cb;
+ LmMessageHandler *stream_error_cb;
+
+ /* telepathy properties */
+ gchar *protocol;
+
+ /* connection properties */
+ gchar *connect_server;
+ guint port;
+ gboolean old_ssl;
+
+ gboolean ignore_ssl_errors;
+ TpConnectionStatusReason ssl_error;
+
+ gboolean do_register;
+
+ gboolean low_bandwidth;
+
+ gchar *https_proxy_server;
+ guint https_proxy_port;
+
+ gchar *fallback_conference_server;
+
+ /* authentication properties */
+ gchar *stream_server;
+ gchar *username;
+ gchar *password;
+ gchar *resource;
+ gint8 priority;
+ gchar *alias;
+
+ /* reference to conference server name */
+ const gchar *conference_server;
+
+ /* channel factories */
+ GPtrArray *channel_factories;
+ GPtrArray *channel_requests;
+ gboolean suppress_next_handler;
+
+ /* serial number of current advertised caps */
+ guint caps_serial;
+
+ /* gobject housekeeping */
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_CONNECTION_GET_PRIVATE(obj) \
+ ((GabbleConnectionPrivate *)obj->priv)
+
+typedef struct _ChannelRequest ChannelRequest;
+
+struct _ChannelRequest
+{
+ DBusGMethodInvocation *context;
+ gchar *channel_type;
+ guint handle_type;
+ guint handle;
+ gboolean suppress_handler;
+};
+
+static void connection_new_channel_cb (TpChannelFactoryIface *, GObject *, gpointer);
+static void connection_channel_error_cb (TpChannelFactoryIface *, GObject *, GError *, gpointer);
+static void connection_nickname_update_cb (GObject *, GabbleHandle, gpointer);
+static void connection_presence_update_cb (GabblePresenceCache *, GabbleHandle, gpointer);
+static void connection_capabilities_update_cb (GabblePresenceCache *, GabbleHandle, GabblePresenceCapabilities, GabblePresenceCapabilities, gpointer);
+
+static void
+gabble_connection_init (GabbleConnection *self)
+{
+ GabbleConnectionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_CONNECTION, GabbleConnectionPrivate);
+ guint i;
+ GValue val = { 0, };
+
+ self->priv = priv;
+ self->lmconn = lm_connection_new (NULL);
+ self->status = TP_CONN_STATUS_NEW;
+ self->handles = gabble_handle_repo_new ();
+ self->disco = gabble_disco_new (self);
+ self->vcard_manager = gabble_vcard_manager_new (self);
+ self->search_instr = NULL;
+ self->search_key_names = NULL;
+ self->search_reported_fields = NULL;
+ self->search_form = FALSE;
+ self->search_service_jid = NULL;
+ self->self_avatar_sha1 = NULL;
+ self->self_handle = 0;
+ g_signal_connect (self->vcard_manager, "nickname-update", G_CALLBACK
+ (connection_nickname_update_cb), self);
+
+ self->presence_cache = gabble_presence_cache_new (self);
+ g_signal_connect (self->presence_cache, "nickname-update", G_CALLBACK
+ (connection_nickname_update_cb), self);
+ g_signal_connect (self->presence_cache, "presence-update", G_CALLBACK
+ (connection_presence_update_cb), self);
+ g_signal_connect (self->presence_cache, "capabilities-update", G_CALLBACK
+ (connection_capabilities_update_cb), self);
+
+ capabilities_fill_cache (self->presence_cache);
+
+ self->roster = gabble_roster_new (self);
+ g_signal_connect (self->roster, "nickname-update", G_CALLBACK
+ (connection_nickname_update_cb), self);
+
+ priv->channel_factories = g_ptr_array_sized_new (1);
+
+ g_ptr_array_add (priv->channel_factories, self->roster);
+
+ g_ptr_array_add (priv->channel_factories,
+ g_object_new (GABBLE_TYPE_MUC_FACTORY,
+ "connection", self,
+ NULL));
+
+ g_ptr_array_add (priv->channel_factories,
+ g_object_new (GABBLE_TYPE_MEDIA_FACTORY,
+ "connection", self,
+ NULL));
+
+ g_ptr_array_add (priv->channel_factories,
+ g_object_new (GABBLE_TYPE_IM_FACTORY,
+ "connection", self,
+ NULL));
+
+ //add for search here
+ g_ptr_array_add (priv->channel_factories,
+ g_object_new (GABBLE_TYPE_SEARCH_FACTORY,
+ "connection", self,
+ NULL));
+
+ for (i = 0; i < priv->channel_factories->len; i++)
+ {
+ GObject *factory = g_ptr_array_index (priv->channel_factories, i);
+ g_signal_connect (factory, "new-channel", G_CALLBACK
+ (connection_new_channel_cb), self);
+ g_signal_connect (factory, "channel-error", G_CALLBACK
+ (connection_channel_error_cb), self);
+ }
+
+ priv->channel_requests = g_ptr_array_new ();
+
+ /* Set default parameters for optional parameters */
+ priv->resource = g_strdup (GABBLE_PARAMS_DEFAULT_RESOURCE);
+ priv->port = GABBLE_PARAMS_DEFAULT_PORT;
+ priv->https_proxy_port = GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT;
+
+ /* initialize properties mixin */
+ gabble_properties_mixin_init (G_OBJECT (self), G_STRUCT_OFFSET (
+ GabbleConnection, properties));
+
+ g_value_init (&val, G_TYPE_UINT);
+ g_value_set_uint (&val, GABBLE_PARAMS_DEFAULT_STUN_PORT);
+
+ gabble_properties_mixin_change_value (G_OBJECT (self), CONN_PROP_STUN_PORT,
+ &val, NULL);
+ gabble_properties_mixin_change_flags (G_OBJECT (self), CONN_PROP_STUN_PORT,
+ TP_PROPERTY_FLAG_READ, 0, NULL);
+
+ g_value_unset (&val);
+
+ priv->caps_serial = 1;
+}
+
+static void
+gabble_connection_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleConnection *self = (GabbleConnection *) object;
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+ const gchar *param_name;
+ guint tp_property_id;
+
+ switch (property_id) {
+ case PROP_PROTOCOL:
+ g_value_set_string (value, priv->protocol);
+ break;
+ case PROP_CONNECT_SERVER:
+ g_value_set_string (value, priv->connect_server);
+ break;
+ case PROP_STREAM_SERVER:
+ g_value_set_string (value, priv->stream_server);
+ break;
+ case PROP_PORT:
+ g_value_set_uint (value, priv->port);
+ break;
+ case PROP_OLD_SSL:
+ g_value_set_boolean (value, priv->old_ssl);
+ break;
+ case PROP_REGISTER:
+ g_value_set_boolean (value, priv->do_register);
+ break;
+ case PROP_LOW_BANDWIDTH:
+ g_value_set_boolean (value, priv->low_bandwidth);
+ break;
+ case PROP_USERNAME:
+ g_value_set_string (value, priv->username);
+ break;
+ case PROP_PASSWORD:
+ g_value_set_string (value, priv->password);
+ break;
+ case PROP_RESOURCE:
+ g_value_set_string (value, priv->resource);
+ break;
+ case PROP_PRIORITY:
+ g_value_set_int (value, priv->priority);
+ break;
+ case PROP_HTTPS_PROXY_SERVER:
+ g_value_set_string (value, priv->https_proxy_server);
+ break;
+ case PROP_HTTPS_PROXY_PORT:
+ g_value_set_uint (value, priv->https_proxy_port);
+ break;
+ case PROP_FALLBACK_CONFERENCE_SERVER:
+ g_value_set_string (value, priv->fallback_conference_server);
+ break;
+ case PROP_IGNORE_SSL_ERRORS:
+ g_value_set_boolean (value, priv->ignore_ssl_errors);
+ break;
+ case PROP_ALIAS:
+ g_value_set_string (value, priv->alias);
+ break;
+ default:
+ param_name = g_param_spec_get_name (pspec);
+
+ if (gabble_properties_mixin_has_property (object, param_name,
+ &tp_property_id))
+ {
+ GValue *tp_property_value =
+ self->properties.properties[tp_property_id].value;
+
+ if (tp_property_value)
+ {
+ g_value_copy (tp_property_value, value);
+ return;
+ }
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_connection_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleConnection *self = (GabbleConnection *) object;
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+ const gchar *param_name;
+ guint tp_property_id;
+
+ switch (property_id) {
+ case PROP_PROTOCOL:
+ g_free (priv->protocol);
+ priv->protocol = g_value_dup_string (value);
+ break;
+ case PROP_CONNECT_SERVER:
+ g_free (priv->connect_server);
+ priv->connect_server = g_value_dup_string (value);
+ break;
+ case PROP_PORT:
+ priv->port = g_value_get_uint (value);
+ break;
+ case PROP_OLD_SSL:
+ priv->old_ssl = g_value_get_boolean (value);
+ break;
+ case PROP_REGISTER:
+ priv->do_register = g_value_get_boolean (value);
+ break;
+ case PROP_LOW_BANDWIDTH:
+ priv->low_bandwidth = g_value_get_boolean (value);
+ break;
+ case PROP_STREAM_SERVER:
+ g_free (priv->stream_server);
+ priv->stream_server = g_value_dup_string (value);
+ break;
+ case PROP_USERNAME:
+ g_free (priv->username);
+ priv->username = g_value_dup_string (value);
+ break;
+ case PROP_PASSWORD:
+ g_free (priv->password);
+ priv->password = g_value_dup_string (value);
+ break;
+ case PROP_RESOURCE:
+ g_free (priv->resource);
+ priv->resource = g_value_dup_string (value);
+ break;
+ case PROP_PRIORITY:
+ priv->priority = CLAMP (g_value_get_int (value), G_MININT8, G_MAXINT8);
+ break;
+ case PROP_HTTPS_PROXY_SERVER:
+ g_free (priv->https_proxy_server);
+ priv->https_proxy_server = g_value_dup_string (value);
+ break;
+ case PROP_HTTPS_PROXY_PORT:
+ priv->https_proxy_port = g_value_get_uint (value);
+ break;
+ case PROP_FALLBACK_CONFERENCE_SERVER:
+ g_free (priv->fallback_conference_server);
+ priv->fallback_conference_server = g_value_dup_string (value);
+ break;
+ case PROP_IGNORE_SSL_ERRORS:
+ priv->ignore_ssl_errors = g_value_get_boolean (value);
+ break;
+ case PROP_ALIAS:
+ g_free (priv->alias);
+ priv->alias = g_value_dup_string (value);
+ break;
+ default:
+ param_name = g_param_spec_get_name (pspec);
+
+ if (gabble_properties_mixin_has_property (object, param_name,
+ &tp_property_id))
+ {
+ gabble_properties_mixin_change_value (object, tp_property_id, value,
+ NULL);
+ gabble_properties_mixin_change_flags (object, tp_property_id,
+ TP_PROPERTY_FLAG_READ,
+ 0, NULL);
+
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_connection_dispose (GObject *object);
+static void gabble_connection_finalize (GObject *object);
+
+static void
+gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_connection_class);
+ GParamSpec *param_spec;
+
+ object_class->get_property = gabble_connection_get_property;
+ object_class->set_property = gabble_connection_set_property;
+
+ g_type_class_add_private (gabble_connection_class, sizeof (GabbleConnectionPrivate));
+
+ object_class->dispose = gabble_connection_dispose;
+ object_class->finalize = gabble_connection_finalize;
+
+ param_spec = g_param_spec_string ("protocol", "Telepathy identifier for protocol",
+ "Identifier string used when the protocol "
+ "name is required. Unused internally.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PROTOCOL, param_spec);
+
+ param_spec = g_param_spec_string ("connect-server", "Hostname or IP of Jabber server",
+ "The server used when establishing a connection.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECT_SERVER, param_spec);
+
+ param_spec = g_param_spec_uint ("port", "Jabber server port",
+ "The port used when establishing a connection.",
+ 0, G_MAXUINT16, GABBLE_PARAMS_DEFAULT_PORT,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PORT, param_spec);
+
+ param_spec = g_param_spec_boolean ("old-ssl", "Old-style SSL tunneled connection",
+ "Establish the entire connection to the server "
+ "within an SSL-encrypted tunnel. Note that this "
+ "is not the same as connecting with TLS, which "
+ "is not yet supported.", FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_OLD_SSL, param_spec);
+
+ param_spec = g_param_spec_boolean ("register", "Register account on server",
+ "Register a new account on server.", FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_REGISTER, param_spec);
+
+ param_spec = g_param_spec_boolean ("low-bandwidth", "Low bandwidth mode",
+ "Determines whether we are in low "
+ "bandwidth mode. This influences "
+ "polling behaviour.", FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_LOW_BANDWIDTH, param_spec);
+
+ param_spec = g_param_spec_string ("stream-server", "The server name used to initialise the stream.",
+ "The server name used when initialising the stream, "
+ "which is usually the part after the @ in the user's JID.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STREAM_SERVER, param_spec);
+
+ param_spec = g_param_spec_string ("username", "Jabber username",
+ "The username used when authenticating.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_USERNAME, param_spec);
+
+ param_spec = g_param_spec_string ("password", "Jabber password",
+ "The password used when authenticating.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PASSWORD, param_spec);
+
+ param_spec = g_param_spec_string ("resource", "Jabber resource",
+ "The Jabber resource used when authenticating.",
+ "Telepathy",
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_RESOURCE, param_spec);
+
+ param_spec = g_param_spec_int ("priority", "Jabber presence priority",
+ "The default priority used when reporting our presence.",
+ G_MININT8, G_MAXINT8, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PRIORITY, param_spec);
+
+ param_spec = g_param_spec_string ("https-proxy-server", "The server name "
+ "used as an HTTPS proxy server",
+ "The server name used as an HTTPS proxy "
+ "server.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_HTTPS_PROXY_SERVER, param_spec);
+
+ param_spec = g_param_spec_uint ("https-proxy-port", "The HTTP proxy server "
+ "port", "The HTTP proxy server port.",
+ 0, G_MAXUINT16, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_HTTPS_PROXY_PORT, param_spec);
+
+ param_spec = g_param_spec_string ("fallback-conference-server",
+ "The conference server used as fallback",
+ "The conference server used as fallback when "
+ "everything else fails.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_FALLBACK_CONFERENCE_SERVER,
+ param_spec);
+
+ param_spec = g_param_spec_string ("stun-server",
+ "STUN server",
+ "STUN server.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_SERVER, param_spec);
+
+ param_spec = g_param_spec_uint ("stun-port",
+ "STUN port",
+ "STUN port.",
+ 0, G_MAXUINT16, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_PORT, param_spec);
+
+ param_spec = g_param_spec_string ("stun-relay-magic-cookie",
+ "STUN relay magic cookie",
+ "STUN relay magic cookie.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_MAGIC_COOKIE,
+ param_spec);
+
+ param_spec = g_param_spec_string ("stun-relay-server",
+ "STUN relay server",
+ "STUN relay server.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_SERVER,
+ param_spec);
+
+ param_spec = g_param_spec_uint ("stun-relay-udp-port",
+ "STUN relay UDP port",
+ "STUN relay UDP port.",
+ 0, G_MAXUINT16, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_UDP_PORT,
+ param_spec);
+
+ param_spec = g_param_spec_uint ("stun-relay-tcp-port",
+ "STUN relay TCP port",
+ "STUN relay TCP port.",
+ 0, G_MAXUINT16, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_TCP_PORT,
+ param_spec);
+
+ param_spec = g_param_spec_uint ("stun-relay-ssltcp-port",
+ "STUN relay SSL-TCP port",
+ "STUN relay SSL-TCP port.",
+ 0, G_MAXUINT16, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_SSLTCP_PORT,
+ param_spec);
+
+ param_spec = g_param_spec_string ("stun-relay-username",
+ "STUN relay username",
+ "STUN relay username.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_USERNAME,
+ param_spec);
+
+ param_spec = g_param_spec_string ("stun-relay-password",
+ "STUN relay password",
+ "STUN relay password.",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STUN_RELAY_PASSWORD,
+ param_spec);
+
+ param_spec = g_param_spec_boolean ("ignore-ssl-errors", "Ignore SSL errors",
+ "Continue connecting even if the server's "
+ "SSL certificate is invalid or missing.",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_IGNORE_SSL_ERRORS, param_spec);
+
+ param_spec = g_param_spec_string ("alias",
+ "Alias/nick for local user",
+ "Alias/nick for local user",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_ALIAS, param_spec);
+
+ /* signal definitions */
+
+ signals[ALIASES_CHANGED] =
+ g_signal_new ("aliases-changed",
+ G_OBJECT_CLASS_TYPE (gabble_connection_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID)))));
+
+ signals[CAPABILITIES_CHANGED] =
+ g_signal_new ("capabilities-changed",
+ G_OBJECT_CLASS_TYPE (gabble_connection_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)))));
+
+ signals[NEW_CHANNEL] =
+ g_signal_new ("new-channel",
+ G_OBJECT_CLASS_TYPE (gabble_connection_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_connection_marshal_VOID__STRING_STRING_UINT_UINT_BOOLEAN,
+ G_TYPE_NONE, 5, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN);
+
+ signals[PRESENCE_UPDATE] =
+ g_signal_new ("presence-update",
+ G_OBJECT_CLASS_TYPE (gabble_connection_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, (dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)))), G_TYPE_INVALID)))));
+
+ signals[STATUS_CHANGED] =
+ g_signal_new ("status-changed",
+ G_OBJECT_CLASS_TYPE (gabble_connection_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_connection_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ signals[DISCONNECTED] =
+ g_signal_new ("disconnected",
+ G_OBJECT_CLASS_TYPE (gabble_connection_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_connection_class), &dbus_glib_gabble_connection_object_info);
+
+ gabble_properties_mixin_class_init (G_OBJECT_CLASS (gabble_connection_class),
+ G_STRUCT_OFFSET (GabbleConnectionClass, properties_class),
+ connection_property_signatures, NUM_CONN_PROPS,
+ NULL);
+}
+
+static gboolean
+_unref_lm_connection (gpointer data)
+{
+ LmConnection *conn = (LmConnection *) data;
+
+ lm_connection_unref (conn);
+ return FALSE;
+}
+
+void
+gabble_connection_dispose (GObject *object)
+{
+ GabbleConnection *self = GABBLE_CONNECTION (object);
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+ DBusGProxy *bus_proxy;
+ guint i;
+ bus_proxy = tp_get_bus_proxy ();
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ gabble_debug (DEBUG_FLAG, "called");
+
+ g_message("1 Inside gabble_connection_dispose() method");
+
+ //<todo> are these asserts a valid one ?
+ //As in case of lm_connection_open these will not be valid assertions ?
+ //to remove these?
+ g_assert ((self->status == TP_CONN_STATUS_DISCONNECTED) ||
+ (self->status == TP_CONN_STATUS_NEW));
+ //This is not a valid statement as the self_handle is set to a value in _gabble_connection_connect which wil call
+ //lm_connection_open(within do_connect). If the call fails then control comes here.. in which case self_handle can be other
+ //than 0)
+ //g_assert (self->self_handle == 0);
+
+ g_message("after assert");
+ if (priv->channel_requests)
+ {
+ g_assert (priv->channel_requests->len == 0);
+ g_ptr_array_free (priv->channel_requests, TRUE);
+ priv->channel_requests = NULL;
+ }
+
+ g_ptr_array_foreach (priv->channel_factories, (GFunc) g_object_unref, NULL);
+ g_ptr_array_free (priv->channel_factories, TRUE);
+ priv->channel_factories = NULL;
+ g_message("unrefed channel factories");
+ if(self->search_instr)
+ {
+ g_free( self->search_instr );
+ self->search_instr = NULL;
+ }
+
+ if(self->search_key_names)
+ {
+ for( i=0; self->search_key_names[i]; i++ )
+ {
+ g_free( self->search_key_names[i] );
+ self->search_key_names[i] = NULL;
+ }
+ g_free( self->search_key_names );
+ self->search_key_names = NULL;
+ }
+ g_message("freed search keys");
+ if ( self->self_avatar_sha1 )
+ {
+ g_free ( self->self_avatar_sha1 );
+ }
+ if(self->search_key_ht)
+ {
+ g_hash_table_destroy (self->search_key_ht);
+ self->search_key_ht = NULL;
+ }
+ if(self->search_service_jid)
+ {
+ g_free(self->search_service_jid);
+ self->search_service_jid = NULL;
+ }
+ /* unreffing channel factories frees the roster */
+ self->roster = NULL;
+
+ g_object_unref (self->disco);
+ self->disco = NULL;
+
+ g_object_unref (self->vcard_manager);
+ self->vcard_manager = NULL;
+
+ g_object_unref (self->presence_cache);
+ self->presence_cache = NULL;
+
+ /* if this is not already the case, we'll crash anyway */
+ g_assert (!lm_connection_is_open (self->lmconn));
+ g_assert (priv->iq_search_keys_cb == NULL);
+ g_assert (priv->iq_jingle_info_cb == NULL);
+ g_assert (priv->iq_disco_cb == NULL);
+ g_assert (priv->iq_unknown_cb == NULL);
+ g_assert (priv->stream_error_cb == NULL);
+
+ /*
+ * The Loudmouth connection can't be unref'd immediately because this
+ * function might (indirectly) return into Loudmouth code which expects the
+ * connection to always be there.
+ */
+ g_idle_add (_unref_lm_connection, self->lmconn);
+
+ if (NULL != self->bus_name)
+ {
+ dbus_g_proxy_call_no_reply (bus_proxy, "ReleaseName",
+ G_TYPE_STRING, self->bus_name,
+ G_TYPE_INVALID);
+ }
+
+ if (G_OBJECT_CLASS (gabble_connection_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_connection_parent_class)->dispose (object);
+
+ g_message("out of the method");
+}
+
+void
+gabble_connection_finalize (GObject *object)
+{
+ GabbleConnection *self = GABBLE_CONNECTION (object);
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ gabble_debug (DEBUG_FLAG, "called with %p", object);
+
+ g_free (self->bus_name);
+ g_free (self->object_path);
+
+ g_free (priv->protocol);
+ g_free (priv->connect_server);
+ g_free (priv->stream_server);
+ g_free (priv->username);
+ g_free (priv->password);
+ g_free (priv->resource);
+
+ g_free (priv->https_proxy_server);
+ g_free (priv->fallback_conference_server);
+
+ g_free (priv->alias);
+
+ gabble_properties_mixin_finalize (object);
+
+ gabble_handle_repo_destroy (self->handles);
+
+ G_OBJECT_CLASS (gabble_connection_parent_class)->finalize (object);
+}
+
+/**
+ * _gabble_connection_set_properties_from_account
+ *
+ * Parses an account string which may be one of the following forms:
+ * username
+ * username/resource
+ * username@server
+ * username@server/resource
+ * and sets the properties for username, stream server and resource
+ * appropriately. Also sets the connect server to the stream server if one has
+ * not yet been specified.
+ */
+
+gboolean
+_gabble_connection_set_properties_from_account (GabbleConnection *conn,
+ const gchar *account,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ char *username, *server, *resource;
+ gboolean result;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+ g_assert (account != NULL);
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ username = server = resource = NULL;
+ result = TRUE;
+
+ gabble_decode_jid (account, &username, &server, &resource);
+
+ if (username == NULL || server == NULL ||
+ *username == '\0' || *server == '\0')
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "unable to get username and server from account");
+ result = FALSE;
+ goto OUT;
+ }
+
+ g_object_set (G_OBJECT (conn),
+ "username", username,
+ "stream-server", server,
+ NULL);
+
+ /* only override the default resource if we actually got one */
+ if (resource)
+ g_object_set (G_OBJECT (conn), "resource", resource, NULL);
+
+OUT:
+ g_free (username);
+ g_free (server);
+ g_free (resource);
+
+ return result;
+}
+
+/**
+ * _gabble_connection_register
+ *
+ * Make the connection object appear on the bus, returning the bus
+ * name and object path used.
+ */
+gboolean
+_gabble_connection_register (GabbleConnection *conn,
+ gchar **bus_name,
+ gchar **object_path,
+ GError **error)
+{
+ DBusGConnection *bus;
+ DBusGProxy *bus_proxy;
+ GabbleConnectionPrivate *priv;
+ const char *allowed_chars = "_1234567890"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ char *safe_proto;
+ char *unique_name;
+ guint request_name_result;
+ GError *request_error;
+
+ g_message("1 Inside _gabble_connection_register() method");
+ g_assert (GABBLE_IS_CONNECTION (conn));
+
+ bus = tp_get_bus ();
+ bus_proxy = tp_get_bus_proxy ();
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ safe_proto = g_strdup (priv->protocol);
+ g_strcanon (safe_proto, allowed_chars, '_');
+
+ unique_name = g_strdup_printf ("_%s_%s_%s",
+ priv->username,
+ priv->stream_server,
+ priv->resource);
+ g_strcanon (unique_name, allowed_chars, '_');
+
+ conn->bus_name = g_strdup_printf (BUS_NAME ".%s.%s",
+ safe_proto,
+ unique_name);
+ conn->object_path = g_strdup_printf (OBJECT_PATH "/%s/%s",
+ safe_proto,
+ unique_name);
+
+ g_free (safe_proto);
+ g_free (unique_name);
+
+ if (!dbus_g_proxy_call (bus_proxy, "RequestName", &request_error,
+ G_TYPE_STRING, conn->bus_name,
+ G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Error acquiring bus name %s: %s", conn->bus_name,
+ request_error->message);
+
+ g_error_free (request_error);
+
+ g_free (conn->bus_name);
+ conn->bus_name = NULL;
+
+ return FALSE;
+ }
+
+ if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+ {
+ gchar *msg;
+
+ switch (request_name_result)
+ {
+ case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
+ msg = "Request has been queued, though we request non-queueing.";
+ break;
+ case DBUS_REQUEST_NAME_REPLY_EXISTS:
+ msg = "A connection manger already has this busname.";
+ break;
+ case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
+ msg = "Connection manager already has a connection to this account.";
+ break;
+ default:
+ msg = "Unknown error return from ReleaseName";
+ }
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Error acquiring bus name %s: %s", conn->bus_name, msg);
+
+ g_free (conn->bus_name);
+ conn->bus_name = NULL;
+
+ return FALSE;
+ }
+
+ gabble_debug (DEBUG_FLAG, "bus name %s", conn->bus_name);
+
+ dbus_g_connection_register_g_object (bus, conn->object_path, G_OBJECT (conn));
+
+ gabble_debug (DEBUG_FLAG, "object path %s", conn->object_path);
+
+ *bus_name = g_strdup (conn->bus_name);
+ *object_path = g_strdup (conn->object_path);
+
+ return TRUE;
+}
+
+
+/**
+ * _gabble_connection_send
+ *
+ * Send an LmMessage and trap network errors appropriately.
+ */
+gboolean
+_gabble_connection_send (GabbleConnection *conn, LmMessage *msg, GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ GError *lmerror = NULL;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ if (!lm_connection_send (conn->lmconn, msg, &lmerror))
+ {
+ gabble_debug (DEBUG_FLAG, "failed: %s", lmerror->message);
+
+ g_set_error (error, TELEPATHY_ERRORS, NetworkError,
+ "message send failed: %s", lmerror->message);
+
+ g_error_free (lmerror);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+typedef struct {
+ GabbleConnectionMsgReplyFunc reply_func;
+
+ GabbleConnection *conn;
+ LmMessage *sent_msg;
+ gpointer user_data;
+
+ GObject *object;
+ gboolean object_alive;
+} GabbleMsgHandlerData;
+
+static LmHandlerResult
+message_send_reply_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *reply_msg,
+ gpointer user_data)
+{
+ GabbleMsgHandlerData *handler_data = user_data;
+ LmMessageSubType sub_type;
+
+ sub_type = lm_message_get_sub_type (reply_msg);
+
+ /* Is it a reply to this message? If we're talking to another loudmouth,
+ * they can send us messages which have the same ID as ones we send. :-O */
+ if (sub_type != LM_MESSAGE_SUB_TYPE_RESULT &&
+ sub_type != LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (handler_data->object_alive)
+ {
+ return handler_data->reply_func (handler_data->conn,
+ handler_data->sent_msg,
+ reply_msg,
+ handler_data->object,
+ handler_data->user_data);
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+message_send_object_destroy_notify_cb (gpointer data,
+ GObject *where_the_object_was)
+{
+ GabbleMsgHandlerData *handler_data = data;
+
+ handler_data->object = NULL;
+ handler_data->object_alive = FALSE;
+}
+
+static void
+message_send_handler_destroy_cb (gpointer data)
+{
+ GabbleMsgHandlerData *handler_data = data;
+
+ lm_message_unref (handler_data->sent_msg);
+
+ if (handler_data->object != NULL)
+ {
+ g_object_weak_unref (handler_data->object,
+ message_send_object_destroy_notify_cb,
+ handler_data);
+ }
+
+ g_free (handler_data);
+}
+
+/**
+ * _gabble_connection_send_with_reply
+ *
+ * Send a tracked LmMessage and trap network errors appropriately.
+ *
+ * If object is non-NULL the handler will follow the lifetime of that object,
+ * which means that if the object is destroyed the callback will not be invoked.
+ */
+gboolean
+_gabble_connection_send_with_reply (GabbleConnection *conn,
+ LmMessage *msg,
+ GabbleConnectionMsgReplyFunc reply_func,
+ GObject *object,
+ gpointer user_data,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ LmMessageHandler *handler;
+ GabbleMsgHandlerData *handler_data;
+ gboolean ret;
+ GError *lmerror = NULL;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ lm_message_ref (msg);
+
+ handler_data = g_new (GabbleMsgHandlerData, 1);
+ handler_data->reply_func = reply_func;
+ handler_data->conn = conn;
+ handler_data->sent_msg = msg;
+ handler_data->user_data = user_data;
+
+ handler_data->object = object;
+ handler_data->object_alive = TRUE;
+
+ if (object != NULL)
+ {
+ g_object_weak_ref (object, message_send_object_destroy_notify_cb,
+ handler_data);
+ }
+
+ handler = lm_message_handler_new (message_send_reply_cb, handler_data,
+ message_send_handler_destroy_cb);
+
+ ret = lm_connection_send_with_reply (conn->lmconn, msg, handler, &lmerror);
+ if (!ret)
+ {
+ gabble_debug (DEBUG_FLAG, "failed: %s", lmerror->message);
+
+ if (error)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NetworkError,
+ "message send failed: %s", lmerror->message);
+ }
+
+ g_error_free (lmerror);
+ }
+
+ lm_message_handler_unref (handler);
+
+ return ret;
+}
+
+static LmHandlerResult connection_iq_disco_cb (LmMessageHandler*, LmConnection*, LmMessage*, gpointer);
+static LmHandlerResult connection_iq_unknown_cb (LmMessageHandler*, LmConnection*, LmMessage*, gpointer);
+static LmHandlerResult connection_stream_error_cb (LmMessageHandler*, LmConnection*, LmMessage*, gpointer);
+static LmSSLResponse connection_ssl_cb (LmSSL*, LmSSLStatus, gpointer);
+static void connection_open_cb (LmConnection*, gboolean, gpointer);
+static void connection_auth_cb (LmConnection*, gboolean, gpointer);
+static void connection_disco_cb (GabbleDisco *, GabbleDiscoRequest *, const gchar *, const gchar *, LmMessageNode *, GError *, gpointer);
+static void connection_disconnected_cb (LmConnection *, LmDisconnectReason, gpointer);
+static void connection_status_change (GabbleConnection *, TpConnectionStatus, TpConnectionStatusReason);
+
+static void channel_request_cancel (gpointer data, gpointer user_data);
+
+static void emit_one_presence_update (GabbleConnection *self, GabbleHandle handle);
+
+
+static gboolean
+do_connect (GabbleConnection *conn, GError **error)
+{
+ GError *lmerror = NULL;
+
+ gabble_debug (DEBUG_FLAG, "calling lm_connection_open");
+ g_message("**gabble do_connect: before calling lm_connection_open\n");
+
+ if (!lm_connection_open (conn->lmconn, connection_open_cb,
+ conn, NULL, &lmerror))
+ {
+ gabble_debug (DEBUG_FLAG, "lm_connection_open failed %s", lmerror->message);
+
+ g_set_error (error, TELEPATHY_ERRORS, NetworkError,
+ "lm_connection_open failed: %s", lmerror->message);
+
+ g_signal_emit (conn, signals[DISCONNECTED], 0);
+ g_error_free (lmerror);
+
+ return FALSE;
+ }
+
+ g_message("**gabble do_connect: after calling lm_connection_open and it passed\n");
+
+ return TRUE;
+}
+
+static void
+connect_callbacks (GabbleConnection *conn)
+{
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ g_message("inside connect_callbacks\n");
+ g_assert (priv->iq_search_keys_cb == NULL);
+ g_assert (priv->iq_jingle_info_cb == NULL);
+ g_assert (priv->iq_disco_cb == NULL);
+ g_assert (priv->iq_unknown_cb == NULL);
+ g_assert (priv->stream_error_cb == NULL);
+
+
+
+ priv->iq_search_keys_cb = lm_message_handler_new (search_keys_iq_cb,
+ conn, NULL);
+ lm_connection_register_message_handler (conn->lmconn,
+ priv->iq_search_keys_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL);
+
+ priv->iq_jingle_info_cb = lm_message_handler_new (jingle_info_iq_callback,
+ conn, NULL);
+ lm_connection_register_message_handler (conn->lmconn,
+ priv->iq_jingle_info_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL);
+
+ priv->iq_disco_cb = lm_message_handler_new (connection_iq_disco_cb,
+ conn, NULL);
+ lm_connection_register_message_handler (conn->lmconn, priv->iq_disco_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL);
+
+ priv->iq_unknown_cb = lm_message_handler_new (connection_iq_unknown_cb,
+ conn, NULL);
+ lm_connection_register_message_handler (conn->lmconn, priv->iq_unknown_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_LAST);
+
+ priv->stream_error_cb = lm_message_handler_new (connection_stream_error_cb,
+ conn, NULL);
+ lm_connection_register_message_handler (conn->lmconn, priv->stream_error_cb,
+ LM_MESSAGE_TYPE_STREAM_ERROR,
+ LM_HANDLER_PRIORITY_LAST);
+ g_message("leaving connect_callbacks\n");
+}
+
+static void
+disconnect_callbacks (GabbleConnection *conn)
+{
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ g_message("[disconnect_callbacks]");
+ g_assert (priv->iq_search_keys_cb != NULL);
+ g_assert (priv->iq_jingle_info_cb != NULL);
+ g_assert (priv->iq_disco_cb != NULL);
+ g_assert (priv->iq_unknown_cb != NULL);
+ g_assert (priv->stream_error_cb != NULL);
+
+ lm_connection_unregister_message_handler (conn->lmconn, priv->iq_search_keys_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (priv->iq_search_keys_cb);
+ priv->iq_search_keys_cb = NULL;
+
+ lm_connection_unregister_message_handler (conn->lmconn, priv->iq_jingle_info_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (priv->iq_jingle_info_cb);
+ priv->iq_jingle_info_cb = NULL;
+
+ lm_connection_unregister_message_handler (conn->lmconn, priv->iq_disco_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (priv->iq_disco_cb);
+ priv->iq_disco_cb = NULL;
+
+ lm_connection_unregister_message_handler (conn->lmconn, priv->iq_unknown_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (priv->iq_unknown_cb);
+ priv->iq_unknown_cb = NULL;
+
+ lm_connection_unregister_message_handler (conn->lmconn, priv->stream_error_cb,
+ LM_MESSAGE_TYPE_STREAM_ERROR);
+ lm_message_handler_unref (priv->stream_error_cb);
+ priv->stream_error_cb = NULL;
+}
+
+/**
+ * _gabble_connection_connect
+ *
+ * Use the stored server & authentication details to commence
+ * the stages for connecting to the server and authenticating. Will
+ * re-use an existing LmConnection if it is present, or create it
+ * if necessary.
+ *
+ * Stage 1 is _gabble_connection_connect calling lm_connection_open
+ * Stage 2 is connection_open_cb calling lm_connection_authenticate
+ * Stage 3 is connection_auth_cb initiating service discovery
+ * Stage 4 is connection_disco_cb advertising initial presence, requesting
+ * the roster and setting the CONNECTED state
+ */
+static gboolean
+_gabble_connection_connect (GabbleConnection *conn,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ char *jid;
+ GabblePresence *presence;
+ g_message("[_gabble_connection_connect]");
+ g_assert (priv->port > 0 && priv->port <= G_MAXUINT16);
+ g_assert (priv->stream_server != NULL);
+ g_assert (priv->username != NULL);
+ g_assert (priv->password != NULL);
+ g_assert (priv->resource != NULL);
+ g_assert (lm_connection_is_open (conn->lmconn) == FALSE);
+
+ g_message("In _gabble_connection_connect" );
+
+ jid = g_strdup_printf ("%s@%s", priv->username, priv->stream_server);
+ lm_connection_set_jid (conn->lmconn, jid);
+
+ conn->self_handle = gabble_handle_for_contact (conn->handles,
+ jid, FALSE);
+ g_free (jid);
+
+ if (conn->self_handle == 0)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "Invalid JID: %s@%s", priv->username, priv->stream_server);
+ return FALSE;
+ }
+ gabble_handle_ref (conn->handles, TP_HANDLE_TYPE_CONTACT, conn->self_handle);
+
+ /* set initial presence */
+ /* TODO: some way for the user to set this */
+ gabble_presence_cache_update (conn->presence_cache, conn->self_handle,
+ priv->resource, GABBLE_PRESENCE_AVAILABLE, NULL, priv->priority);
+ emit_one_presence_update (conn, conn->self_handle);
+
+ /* set initial capabilities */
+ presence = gabble_presence_cache_get (conn->presence_cache, conn->self_handle);
+
+ gabble_presence_set_capabilities (presence, priv->resource,
+ capabilities_get_initial_caps (), priv->caps_serial++);
+
+ /* always override server and port if one was forced upon us */
+ if (priv->connect_server != NULL)
+ {
+ lm_connection_set_server (conn->lmconn, priv->connect_server);
+ lm_connection_set_port (conn->lmconn, priv->port);
+ g_message("LM Server is %s \n",priv->connect_server );
+ g_message("LM port is %ld \n",priv->port);
+ }
+ /* otherwise set the server & port to the stream server,
+ * if one didn't appear from a SRV lookup */
+ else if (lm_connection_get_server (conn->lmconn) == NULL)
+ {
+ lm_connection_set_server (conn->lmconn, priv->stream_server);
+ lm_connection_set_port (conn->lmconn, priv->port);
+ }
+
+
+ if (priv->https_proxy_server)
+ {
+ LmProxy *proxy;
+
+ proxy = lm_proxy_new_with_server (LM_PROXY_TYPE_HTTP,
+ priv->https_proxy_server, priv->https_proxy_port);
+
+ lm_connection_set_proxy (conn->lmconn, proxy);
+
+ lm_proxy_unref (proxy);
+ }
+
+ if (priv->old_ssl)
+ {
+ LmSSL *ssl = lm_ssl_new (NULL, connection_ssl_cb, conn, NULL);
+ lm_connection_set_ssl (conn->lmconn, ssl);
+ lm_ssl_unref (ssl);
+ }
+ else //if we want to use tls (not old ssl?) then need to set tls flags.
+ {
+ LmSSL *ssl = lm_ssl_new (NULL, connection_ssl_cb, conn, NULL);
+ lm_connection_set_ssl (conn->lmconn, ssl);
+
+ lm_ssl_use_starttls (ssl, TRUE, TRUE);
+
+ lm_ssl_unref (ssl);
+ }
+
+ /* send whitespace to the server every 30 seconds */
+ //lm_connection_set_keep_alive_rate (conn->lmconn, 45);
+
+ lm_connection_set_disconnect_function (conn->lmconn,
+ connection_disconnected_cb,
+ conn,
+ NULL);
+
+ if (do_connect (conn, error))
+ {
+ gboolean valid;
+
+ connection_status_change (conn,
+ TP_CONN_STATUS_CONNECTING,
+ TP_CONN_STATUS_REASON_REQUESTED);
+
+ valid = gabble_handle_ref (conn->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ conn->self_handle);
+ g_message("before after valid assert" );
+ g_assert (valid);
+ g_message("In after valid assert" );
+ }
+ else
+ {
+ return FALSE;
+ }
+ g_message("Out _gabble_connection_connect" );
+ return TRUE;
+}
+
+
+
+static void
+connection_disconnected_cb (LmConnection *lmconn,
+ LmDisconnectReason lm_reason,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+ g_message("[connection_disconnected_cb]\n");
+ g_assert (conn->lmconn == lmconn);
+
+ gabble_debug (DEBUG_FLAG, "called with reason %u", lm_reason);
+
+ /* if we were expecting this disconnection, we're done so can tell
+ * the connection manager to unref us. otherwise it's a network error
+ * or some other screw up we didn't expect, so we emit the status
+ * change */
+ if (conn->status == TP_CONN_STATUS_DISCONNECTED)
+ {
+ g_message("[connection_disconnected_cb]expected; emitting DISCONNECTED");
+ g_signal_emit (conn, signals[DISCONNECTED], 0);
+ }
+ else
+ {
+ g_message("[connection_disconnected_cb]unexpected; calling connection_status_change");
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_NETWORK_ERROR);
+ }
+}
+
+
+/**
+ * connection_status_change:
+ * @conn: a #GabbleConnection
+ * @status: new status to advertise
+ * @reason: reason for new status
+ *
+ * Compares status with current status. If different, emits a signal
+ * for the new status, and updates it in the #GabbleConnection.
+ */
+static void
+connection_status_change (GabbleConnection *conn,
+ TpConnectionStatus status,
+ TpConnectionStatusReason reason)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ g_message ("[connection_status_change]status %u reason %u", status, reason);
+
+ g_assert (status != TP_CONN_STATUS_NEW);
+
+ if (conn->status != status)
+ {
+ if ((status == TP_CONN_STATUS_DISCONNECTED) &&
+ (conn->status == TP_CONN_STATUS_NEW))
+ {
+ g_message("[connection_status_change] line 1721");
+ conn->status = status;
+
+ /* unref our self handle if it's set */
+ if (conn->self_handle != 0)
+ {
+ gabble_handle_unref (conn->handles, TP_HANDLE_TYPE_CONTACT,
+ conn->self_handle);
+ conn->self_handle = 0;
+ }
+
+ g_message("[connection_status_change]new connection closed; emitting DISCONNECTED");
+ g_signal_emit (conn, signals[DISCONNECTED], 0);
+ return;
+ }
+
+ conn->status = status;
+
+ if (status == TP_CONN_STATUS_DISCONNECTED)
+ {
+ /* remove the channels so we don't get any race conditions where
+ * method calls are delivered to a channel after we've started
+ * disconnecting */
+ g_message("[connection_status_change] TP_CONN_STATUS_DISCONNECTED");
+
+ /* trigger close_all on all channel factories */
+ g_ptr_array_foreach (priv->channel_factories, (GFunc)
+ tp_channel_factory_iface_close_all, NULL);
+
+ /* cancel all queued channel requests */
+ if (priv->channel_requests->len > 0)
+ {
+ g_ptr_array_foreach (priv->channel_requests, (GFunc)
+ channel_request_cancel, NULL);
+ g_ptr_array_remove_range (priv->channel_requests, 0,
+ priv->channel_requests->len);
+ }
+
+ /* unref our self handle */
+ gabble_handle_unref (conn->handles, TP_HANDLE_TYPE_CONTACT,
+ conn->self_handle);
+ conn->self_handle = 0;
+ }
+
+ g_message("[connection_status_change]emitting status-changed with status %u reason %u",
+ status, reason);
+
+ g_signal_emit (conn, signals[STATUS_CHANGED], 0, status, reason);
+
+ if (status == TP_CONN_STATUS_CONNECTING)
+ {
+ /* add our callbacks */
+ connect_callbacks (conn);
+
+ /* trigger connecting on all channel factories */
+ g_ptr_array_foreach (priv->channel_factories, (GFunc)
+ tp_channel_factory_iface_connecting, NULL);
+ }
+ else if (status == TP_CONN_STATUS_CONNECTED)
+ {
+ /* send whitespace to the server every 30 seconds resetting to 30*/
+ lm_connection_set_keep_alive_rate (conn->lmconn, 10);
+
+ /* trigger connected on all channel factories */
+ g_ptr_array_foreach (priv->channel_factories, (GFunc)
+ tp_channel_factory_iface_connected, NULL);
+ }
+ else if (status == TP_CONN_STATUS_DISCONNECTED)
+ {
+ /* remove our callbacks */
+ disconnect_callbacks (conn);
+
+ /* trigger disconnected on all channel factories */
+ g_ptr_array_foreach (priv->channel_factories, (GFunc)
+ tp_channel_factory_iface_disconnected, NULL);
+
+ /* if the connection is open, this function will close it for you.
+ * if it's already closed (eg network error) then we're done, so
+ * can emit DISCONNECTED and have the connection manager unref us */
+ if (lm_connection_is_open (conn->lmconn))
+ {
+ g_message ("still open; calling lm_connection_close");
+ lm_connection_close (conn->lmconn, NULL);
+ }
+ else
+ {
+ /* lm_connection_is_open() returns FALSE if LmConnection is in the
+ * middle of connecting, so call this just in case */
+ lm_connection_cancel_open (conn->lmconn);
+ g_message ("closed; emitting DISCONNECTED");
+ g_signal_emit (conn, signals[DISCONNECTED], 0);
+ }
+ }
+ }
+ else
+ {
+ g_warning ("%s: attempted to re-emit the current status %u reason %u",
+ G_STRFUNC, status, reason);
+ }
+ g_message("[connection_status_change]");
+ g_message ("out connection status changed ");
+}
+
+static ChannelRequest *
+channel_request_new (DBusGMethodInvocation *context,
+ const char *channel_type,
+ guint handle_type,
+ guint handle,
+ gboolean suppress_handler)
+{
+ ChannelRequest *ret;
+
+ g_assert (NULL != context);
+ g_assert (NULL != channel_type);
+
+ ret = g_new0 (ChannelRequest, 1);
+ ret->context = context;
+ ret->channel_type = g_strdup (channel_type);
+ ret->handle_type = handle_type;
+ ret->handle = handle;
+ ret->suppress_handler = suppress_handler;
+
+ return ret;
+}
+
+static void
+channel_request_free (ChannelRequest *request)
+{
+ g_assert (NULL == request->context);
+ g_free (request->channel_type);
+ g_free (request);
+}
+
+static void
+channel_request_cancel (gpointer data, gpointer user_data)
+{
+ ChannelRequest *request = (ChannelRequest *) data;
+ GError *error = NULL;
+
+ gabble_debug (DEBUG_FLAG, "cancelling request for %s/%d/%d", request->channel_type, request->handle_type, request->handle);
+
+ error = g_error_new (TELEPATHY_ERRORS, Disconnected, "unable to "
+ "service this channel request, we're disconnecting!");
+
+ dbus_g_method_return_error (request->context, error);
+ request->context = NULL;
+
+ g_error_free (error);
+ channel_request_free (request);
+}
+
+static GPtrArray *
+find_matching_channel_requests (GabbleConnection *conn,
+ const gchar *channel_type,
+ guint handle_type,
+ guint handle,
+ gboolean *suppress_handler)
+{
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ GPtrArray *requests;
+ guint i;
+
+ requests = g_ptr_array_sized_new (1);
+
+ for (i = 0; i < priv->channel_requests->len; i++)
+ {
+ ChannelRequest *request = g_ptr_array_index (priv->channel_requests, i);
+
+ if (0 != strcmp (request->channel_type, channel_type))
+ continue;
+
+ if (handle_type != request->handle_type)
+ continue;
+
+ if (handle != request->handle)
+ continue;
+
+ if (request->suppress_handler && suppress_handler)
+ *suppress_handler = TRUE;
+
+ g_ptr_array_add (requests, request);
+ }
+
+ return requests;
+}
+
+static void
+connection_new_channel_cb (TpChannelFactoryIface *factory,
+ GObject *chan,
+ gpointer data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (data);
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ gchar *object_path = NULL, *channel_type = NULL;
+ guint handle_type = 0, handle = 0;
+ gboolean suppress_handler = priv->suppress_next_handler;
+ GPtrArray *tmp;
+ guint i;
+
+ g_object_get (chan,
+ "object-path", &object_path,
+ "channel-type", &channel_type,
+ "handle-type", &handle_type,
+ "handle", &handle,
+ NULL);
+
+ gabble_debug (DEBUG_FLAG, "called for %s", object_path);
+
+ tmp = find_matching_channel_requests (conn, channel_type, handle_type,
+ handle, &suppress_handler);
+
+ g_signal_emit (conn, signals[NEW_CHANNEL], 0,
+ object_path, channel_type,
+ handle_type, handle,
+ suppress_handler);
+
+ for (i = 0; i < tmp->len; i++)
+ {
+ ChannelRequest *request = g_ptr_array_index (tmp, i);
+
+ gabble_debug (DEBUG_FLAG, "completing queued request, channel_type=%s, handle_type=%u, "
+ "handle=%u, suppress_handler=%u", request->channel_type,
+ request->handle_type, request->handle, request->suppress_handler);
+
+ dbus_g_method_return (request->context, object_path);
+ request->context = NULL;
+
+ g_ptr_array_remove (priv->channel_requests, request);
+
+ channel_request_free (request);
+ }
+
+ g_ptr_array_free (tmp, TRUE);
+
+ g_free (object_path);
+ g_free (channel_type);
+}
+
+static void
+connection_channel_error_cb (TpChannelFactoryIface *factory,
+ GObject *chan,
+ GError *error,
+ gpointer data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (data);
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ gchar *channel_type = NULL;
+ guint handle_type = 0, handle = 0;
+ GPtrArray *tmp;
+ guint i;
+
+ gabble_debug (DEBUG_FLAG, "channel_type=%s, handle_type=%u, handle=%u, error_code=%u, "
+ "error_message=\"%s\"", channel_type, handle_type, handle,
+ error->code, error->message);
+
+ g_object_get (chan,
+ "channel-type", &channel_type,
+ "handle-type", &handle_type,
+ "handle", &handle,
+ NULL);
+
+ tmp = find_matching_channel_requests (conn, channel_type, handle_type,
+ handle, NULL);
+
+ for (i = 0; i < tmp->len; i++)
+ {
+ ChannelRequest *request = g_ptr_array_index (tmp, i);
+
+ gabble_debug (DEBUG_FLAG, "completing queued request %p, channel_type=%s, "
+ "handle_type=%u, handle=%u, suppress_handler=%u",
+ request, request->channel_type,
+ request->handle_type, request->handle, request->suppress_handler);
+
+ dbus_g_method_return_error (request->context, error);
+ request->context = NULL;
+
+ g_ptr_array_remove (priv->channel_requests, request);
+
+ channel_request_free (request);
+ }
+
+ g_ptr_array_free (tmp, TRUE);
+ g_free (channel_type);
+}
+
+static void
+connection_presence_update_cb (GabblePresenceCache *cache, GabbleHandle handle, gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+
+ emit_one_presence_update (conn, handle);
+}
+
+GabbleConnectionAliasSource
+_gabble_connection_get_cached_alias (GabbleConnection *conn,
+ GabbleHandle handle,
+ gchar **alias)
+{
+ GabbleConnectionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (conn,
+ GABBLE_TYPE_CONNECTION, GabbleConnectionPrivate);
+ GabbleConnectionAliasSource ret = GABBLE_CONNECTION_ALIAS_NONE;
+ GabblePresence *pres;
+ const gchar *tmp;
+ gchar *user = NULL, *resource = NULL;
+
+ g_return_val_if_fail (NULL != conn, GABBLE_CONNECTION_ALIAS_NONE);
+ g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), GABBLE_CONNECTION_ALIAS_NONE);
+ g_return_val_if_fail (gabble_handle_is_valid (conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), GABBLE_CONNECTION_ALIAS_NONE);
+
+ tmp = gabble_roster_handle_get_name (conn->roster, handle);
+ if (NULL != tmp)
+ {
+ ret = GABBLE_CONNECTION_ALIAS_FROM_ROSTER;
+
+ if (NULL != alias)
+ *alias = g_strdup (tmp);
+
+ goto OUT;
+ }
+
+ pres = gabble_presence_cache_get (conn->presence_cache, handle);
+ if (NULL != pres && NULL != pres->nickname)
+ {
+ ret = GABBLE_CONNECTION_ALIAS_FROM_PRESENCE;
+
+ if (NULL != alias)
+ *alias = g_strdup (pres->nickname);
+
+ goto OUT;
+ }
+
+ /* if it's our own handle, use alias passed to the connmgr, if any */
+ if (handle == conn->self_handle && priv->alias != NULL)
+ {
+ ret = GABBLE_CONNECTION_ALIAS_FROM_CONNMGR;
+
+ if (NULL != alias)
+ *alias = g_strdup (priv->alias);
+
+ goto OUT;
+ }
+
+ /* if we've seen a nickname in their vCard, use that */
+ tmp = gabble_vcard_manager_get_cached_alias (conn->vcard_manager, handle);
+ if (NULL != tmp)
+ {
+ ret = GABBLE_CONNECTION_ALIAS_FROM_VCARD;
+
+ if (NULL != alias)
+ *alias = g_strdup (tmp);
+
+ goto OUT;
+ }
+
+ /* fallback to JID */
+ tmp = gabble_handle_inspect (conn->handles, TP_HANDLE_TYPE_CONTACT, handle);
+ g_assert (NULL != tmp);
+
+ gabble_decode_jid (tmp, &user, NULL, &resource);
+
+ /* MUC handles have the nickname in the resource */
+ if (NULL != resource)
+ {
+ ret = GABBLE_CONNECTION_ALIAS_FROM_JID;
+
+ if (NULL != alias)
+ {
+ *alias = resource;
+ resource = NULL;
+ }
+
+ goto OUT;
+ }
+
+ /* otherwise just take their local part */
+ if (NULL != user)
+ {
+ ret = GABBLE_CONNECTION_ALIAS_FROM_JID;
+
+ if (NULL != alias)
+ {
+ *alias = user;
+ user = NULL;
+ }
+
+ goto OUT;
+ }
+
+OUT:
+ g_free (user);
+ g_free (resource);
+ return ret;
+}
+
+static void
+connection_nickname_update_cb (GObject *object,
+ GabbleHandle handle,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+ GabbleConnectionAliasSource signal_source, real_source;
+ gchar *alias = NULL;
+ GPtrArray *aliases;
+ GValue entry = { 0, };
+
+ if (object == G_OBJECT (conn->roster))
+ {
+ signal_source = GABBLE_CONNECTION_ALIAS_FROM_ROSTER;
+ }
+ else if (object == G_OBJECT (conn->presence_cache))
+ {
+ signal_source = GABBLE_CONNECTION_ALIAS_FROM_PRESENCE;
+ }
+ else if (object == G_OBJECT (conn->vcard_manager))
+ {
+ signal_source = GABBLE_CONNECTION_ALIAS_FROM_VCARD;
+ }
+ else
+ {
+ g_assert_not_reached ();
+ return;
+ }
+
+ real_source = _gabble_connection_get_cached_alias (conn, handle, &alias);
+
+ g_assert (real_source != GABBLE_CONNECTION_ALIAS_NONE);
+
+ /* if the active alias for this handle is already known and from
+ * a higher priority, this signal is not interesting so we do
+ * nothing */
+ if (real_source > signal_source)
+ {
+ gabble_debug (DEBUG_FLAG, "ignoring boring alias change for handle %u, signal from %u "
+ "but source %u has alias \"%s\"", handle, signal_source,
+ real_source, alias);
+ goto OUT;
+ }
+
+ g_value_init (&entry, TP_ALIAS_PAIR_TYPE);
+ g_value_take_boxed (&entry, dbus_g_type_specialized_construct
+ (TP_ALIAS_PAIR_TYPE));
+
+ dbus_g_type_struct_set (&entry,
+ 0, handle,
+ 1, alias,
+ G_MAXUINT);
+
+ aliases = g_ptr_array_sized_new (1);
+ g_ptr_array_add (aliases, g_value_get_boxed (&entry));
+
+ g_signal_emit (conn, signals[ALIASES_CHANGED], 0, aliases);
+
+ g_value_unset (&entry);
+ g_ptr_array_free (aliases, TRUE);
+
+OUT:
+ g_free (alias);
+}
+
+/**
+ * status_is_available
+ *
+ * Returns a boolean to indicate whether the given gabble status is
+ * available on this connection.
+ */
+static gboolean
+status_is_available (GabbleConnection *conn, int status)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+ g_assert (status < LAST_GABBLE_PRESENCE);
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ if (gabble_statuses[status].presence_type == TP_CONN_PRESENCE_TYPE_HIDDEN &&
+ (conn->features & GABBLE_CONNECTION_FEATURES_PRESENCE_INVISIBLE) == 0)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+/**
+ * destroy_the_bastard:
+ * @data: a GValue to destroy
+ *
+ * destroys a GValue allocated on the heap
+ */
+static void
+destroy_the_bastard (GValue *value)
+{
+ g_value_unset (value);
+ g_free (value);
+}
+
+static GHashTable *
+construct_presence_hash (GabbleConnection *self,
+ const GArray *contact_handles)
+{
+ guint i;
+ GabbleHandle handle;
+ GHashTable *presence_hash, *contact_status, *parameters;
+ GValueArray *vals;
+ GValue *message;
+ GabblePresence *presence;
+ GabblePresenceId status;
+ const gchar *status_message;
+ /* this is never set at the moment*/
+ guint timestamp = 0;
+
+ g_assert (gabble_handles_are_valid (self->handles, TP_HANDLE_TYPE_CONTACT,
+ contact_handles, FALSE, NULL));
+
+ presence_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
+ (GDestroyNotify) g_value_array_free);
+
+ for (i = 0; i < contact_handles->len; i++)
+ {
+ handle = g_array_index (contact_handles, GabbleHandle, i);
+ presence = gabble_presence_cache_get (self->presence_cache, handle);
+
+ if (presence)
+ {
+ status = presence->status;
+ status_message = presence->status_message;
+ }
+ else
+ {
+ status = GABBLE_PRESENCE_OFFLINE;
+ status_message = NULL;
+ }
+
+ message = g_new0 (GValue, 1);
+ g_value_init (message, G_TYPE_STRING);
+ g_value_set_static_string (message, status_message);
+
+ parameters = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) destroy_the_bastard);
+
+ g_hash_table_insert (parameters, "message", message);
+
+ contact_status = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) g_hash_table_destroy);
+ g_hash_table_insert (contact_status,
+ (gchar *) gabble_statuses[status].name, parameters);
+
+ vals = g_value_array_new (2);
+
+ g_value_array_append (vals, NULL);
+ g_value_init (g_value_array_get_nth (vals, 0), G_TYPE_UINT);
+ g_value_set_uint (g_value_array_get_nth (vals, 0), timestamp);
+
+ g_value_array_append (vals, NULL);
+ g_value_init (g_value_array_get_nth (vals, 1),
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)));
+ g_value_take_boxed (g_value_array_get_nth (vals, 1), contact_status);
+
+ g_hash_table_insert (presence_hash, GINT_TO_POINTER (handle), vals);
+ }
+
+ return presence_hash;
+}
+
+/**
+ * emit_presence_update:
+ * @self: A #GabbleConnection
+ * @contact_handles: A zero-terminated array of #GabbleHandle for
+ * the contacts to emit presence for
+ *
+ * Emits the Telepathy PresenceUpdate signal with the current
+ * stored presence information for the given contact.
+ */
+static void
+emit_presence_update (GabbleConnection *self,
+ const GArray *contact_handles)
+{
+ GHashTable *presence_hash;
+
+ presence_hash = construct_presence_hash (self, contact_handles);
+ g_signal_emit (self, signals[PRESENCE_UPDATE], 0, presence_hash);
+ g_hash_table_destroy (presence_hash);
+}
+
+/**
+ * emit_one_presence_update:
+ * Convenience function for calling emit_presence_update with one handle.
+ */
+
+static void
+emit_one_presence_update (GabbleConnection *self,
+ GabbleHandle handle)
+{
+ GArray *handles = g_array_sized_new (FALSE, FALSE, sizeof (GabbleHandle), 1);
+
+ g_array_insert_val (handles, 0, handle);
+ emit_presence_update (self, handles);
+ g_array_free (handles, TRUE);
+}
+
+/**
+ * signal_own_presence:
+ * @self: A #GabbleConnection
+ * @error: pointer in which to return a GError in case of failure.
+ *
+ * Signal the user's stored presence to the jabber server
+ *
+ * Retuns: FALSE if an error occurred
+ */
+static gboolean
+signal_own_presence (GabbleConnection *self, GError **error)
+{
+
+ GabblePresence *presence;
+ LmMessage *message;
+ LmMessageNode *node;
+ gboolean ret;
+ gchar *ext_string = NULL;
+ GSList *features, *i;
+ GabbleConnectionPrivate *priv;
+
+ if ( NULL == self )
+ {
+ g_debug ("%s: accesing after dereferenced connection", G_STRFUNC);
+ return FALSE;
+ }
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ presence = gabble_presence_cache_get (self->presence_cache, self->self_handle);
+ message = gabble_presence_as_message (presence, priv->resource);
+ node = lm_message_get_node (message);
+
+ if (presence->status == GABBLE_PRESENCE_HIDDEN)
+ {
+ if ((self->features & GABBLE_CONNECTION_FEATURES_PRESENCE_INVISIBLE) != 0)
+ lm_message_node_set_attribute (node, "type", "invisible");
+ }
+
+ features = capabilities_get_features (presence->caps);
+
+ for (i = features; NULL != i; i = i->next)
+ {
+ const Feature *feat = (const Feature *) i->data;
+
+ if ((NULL != feat->bundle) && g_strdiff (VERSION, feat->bundle))
+ {
+ if (NULL != ext_string)
+ {
+ gchar *tmp = ext_string;
+ ext_string = g_strdup_printf ("%s %s", ext_string, feat->bundle);
+ g_free (tmp);
+ }
+ else
+ {
+ ext_string = g_strdup (feat->bundle);
+ }
+ }
+ }
+
+ node = lm_message_node_add_child (node, "c", NULL);
+ lm_message_node_set_attributes (
+ node,
+ "xmlns", NS_CAPS,
+ "node", NS_GABBLE_CAPS,
+ "ver", VERSION,
+ NULL);
+
+ if (NULL != ext_string)
+ lm_message_node_set_attribute (node, "ext", ext_string);
+
+ ret = _gabble_connection_send (self, message, error);
+
+ lm_message_unref (message);
+
+ g_free (ext_string);
+ g_slist_free (features);
+
+ return ret;
+}
+
+static LmMessage *_lm_iq_message_make_result (LmMessage *iq_message);
+
+/**
+ * _gabble_connection_send_iq_result
+ *
+ * Function used to acknowledge an IQ stanza.
+ */
+void
+_gabble_connection_acknowledge_set_iq (GabbleConnection *conn,
+ LmMessage *iq)
+{
+ LmMessage *result;
+
+ g_assert (LM_MESSAGE_TYPE_IQ == lm_message_get_type (iq));
+ g_assert (LM_MESSAGE_SUB_TYPE_SET == lm_message_get_sub_type (iq));
+
+ result = _lm_iq_message_make_result (iq);
+
+ if (NULL != result)
+ {
+ _gabble_connection_send (conn, result, NULL);
+ lm_message_unref (result);
+ }
+}
+
+
+/**
+ * _gabble_connection_send_iq_error
+ *
+ * Function used to acknowledge an IQ stanza with an error.
+ */
+void
+_gabble_connection_send_iq_error (GabbleConnection *conn,
+ LmMessage *message,
+ GabbleXmppError error,
+ const gchar *errmsg)
+{
+ const gchar *to, *id;
+ LmMessage *msg;
+ LmMessageNode *iq_node;
+
+ iq_node = lm_message_get_node (message);
+ to = lm_message_node_get_attribute (iq_node, "from");
+ id = lm_message_node_get_attribute (iq_node, "id");
+
+ if (id == NULL)
+ {
+ NODE_DEBUG (iq_node, "can't acknowledge IQ with no id");
+ return;
+ }
+
+ msg = lm_message_new_with_sub_type (to, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_ERROR);
+
+ lm_message_node_set_attribute (msg->node, "id", id);
+
+ lm_message_node_steal_children (msg->node, iq_node);
+
+ gabble_xmpp_error_to_node (error, msg->node, errmsg);
+
+ _gabble_connection_send (conn, msg, NULL);
+
+ lm_message_unref (msg);
+}
+
+static LmMessage *
+_lm_iq_message_make_result (LmMessage *iq_message)
+{
+ LmMessage *result;
+ LmMessageNode *iq, *result_iq;
+ const gchar *from_jid, *id;
+
+ g_assert (lm_message_get_type (iq_message) == LM_MESSAGE_TYPE_IQ);
+ g_assert (lm_message_get_sub_type (iq_message) == LM_MESSAGE_SUB_TYPE_GET ||
+ lm_message_get_sub_type (iq_message) == LM_MESSAGE_SUB_TYPE_SET);
+
+ iq = lm_message_get_node (iq_message);
+ id = lm_message_node_get_attribute (iq, "id");
+
+ if (id == NULL)
+ {
+ NODE_DEBUG (iq, "can't acknowledge IQ with no id");
+ return NULL;
+ }
+
+ from_jid = lm_message_node_get_attribute (iq, "from");
+
+ result = lm_message_new_with_sub_type (from_jid, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_RESULT);
+ result_iq = lm_message_get_node (result);
+ lm_message_node_set_attribute (result_iq, "id", id);
+
+ return result;
+}
+
+/**
+ * connection_iq_disco_cb
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler handles
+ * disco-related IQs.
+ */
+static LmHandlerResult
+connection_iq_disco_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+ LmMessage *result;
+ LmMessageNode *iq, *result_iq, *query, *result_query;
+ const gchar *node, *suffix;
+ GSList *features;
+ GSList *i;
+ GabblePresence *pres;
+
+ if ( NULL == conn )
+ {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_GET)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ iq = lm_message_get_node (message);
+ query = lm_message_node_get_child_with_namespace (iq, "query",
+ NS_DISCO_INFO);
+
+ if (!query)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ node = lm_message_node_get_attribute (query, "node");
+
+ if (node && (
+ 0 != strncmp (node, NS_GABBLE_CAPS "#", strlen (NS_GABBLE_CAPS) + 1) ||
+ strlen(node) < strlen (NS_GABBLE_CAPS) + 2))
+ {
+ NODE_DEBUG (iq, "got iq disco query with unexpected node attribute");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (node == NULL)
+ suffix = NULL;
+ else
+ suffix = node + strlen (NS_GABBLE_CAPS) + 1;
+
+ result = _lm_iq_message_make_result (message);
+ result_iq = lm_message_get_node (result);
+ result_query = lm_message_node_add_child (result_iq, "query", NULL);
+ lm_message_node_set_attribute (result_query, "xmlns", NS_DISCO_INFO);
+
+ pres = gabble_presence_cache_get (conn->presence_cache, conn->self_handle);
+ gabble_debug (DEBUG_FLAG, "got disco request for bundle %s, caps are %x", node, pres->caps);
+ features = capabilities_get_features (pres->caps);
+
+ g_debug("%s: caps now %u", G_STRFUNC, pres->caps);
+
+ for (i = features; NULL != i; i = i->next)
+ {
+ const Feature *feature = (const Feature *) i->data;
+
+ if (NULL == node || !g_strdiff (suffix, feature->bundle))
+ {
+ LmMessageNode *node = lm_message_node_add_child (result_query,
+ "feature", NULL);
+ lm_message_node_set_attribute (node, "var", feature->ns);
+ }
+ }
+
+ NODE_DEBUG (result_iq, "sending disco response");
+
+ if (!lm_connection_send (conn->lmconn, result, NULL))
+ gabble_debug (DEBUG_FLAG, "sending disco response failed");
+
+ g_slist_free (features);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+/**
+ * connection_iq_unknown_cb
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler is
+ * at a lower priority than the others, and should reply with an error
+ * about unsupported get/set attempts.
+ */
+static LmHandlerResult
+connection_iq_unknown_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+
+ g_assert (connection == conn->lmconn);
+
+ NODE_DEBUG (message->node, "got unknown iq");
+
+ switch (lm_message_get_sub_type (message))
+ {
+ case LM_MESSAGE_SUB_TYPE_GET:
+ case LM_MESSAGE_SUB_TYPE_SET:
+ _gabble_connection_send_iq_error (conn, message,
+ XMPP_ERROR_SERVICE_UNAVAILABLE, NULL);
+ break;
+ default:
+ break;
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+/**
+ * connection_stream_error_cb
+ *
+ * Called by loudmouth when we get stream error, which means that
+ * we're about to close the connection. The message contains the reason
+ * for the connection hangup.
+ */
+static LmHandlerResult
+connection_stream_error_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+ LmMessageNode *conflict_node;
+
+ g_assert (connection == conn->lmconn);
+
+ NODE_DEBUG (message->node, "got stream error");
+
+ conflict_node = lm_message_node_get_child (message->node, "conflict");
+ if (conflict_node)
+ {
+ gabble_debug (DEBUG_FLAG, "found conflict node, emiting status change");
+
+ /* Another client with the same resource just
+ * appeared, we're going down. */
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_NAME_IN_USE);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+
+/**
+ * connection_ssl_cb
+ *
+ * If we're doing old SSL, this function gets called if the certificate
+ * is dodgy.
+ */
+static LmSSLResponse
+connection_ssl_cb (LmSSL *lmssl,
+ LmSSLStatus status,
+ gpointer data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (data);
+
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ const char *reason;
+ TpConnectionStatusReason tp_reason;
+
+ g_message("inside ssl_cb\n");
+ switch (status) {
+ case LM_SSL_STATUS_NO_CERT_FOUND:
+ reason = "The server doesn't provide a certificate.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_NOT_PROVIDED;
+ break;
+ case LM_SSL_STATUS_UNTRUSTED_CERT:
+ reason = "The certificate can not be trusted.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_UNTRUSTED;
+ break;
+ case LM_SSL_STATUS_CERT_EXPIRED:
+ reason = "The certificate has expired.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_EXPIRED;
+ break;
+ case LM_SSL_STATUS_CERT_NOT_ACTIVATED:
+ reason = "The certificate has not been activated.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_NOT_ACTIVATED;
+ break;
+ case LM_SSL_STATUS_CERT_HOSTNAME_MISMATCH:
+ reason = "The server hostname doesn't match the one in the certificate.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_HOSTNAME_MISMATCH;
+ break;
+ case LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH:
+ reason = "The fingerprint doesn't match the expected value.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_FINGERPRINT_MISMATCH;
+ break;
+ case LM_SSL_STATUS_GENERIC_ERROR:
+ reason = "An unknown SSL error occurred.";
+ tp_reason = TP_CONN_STATUS_REASON_CERT_OTHER_ERROR;
+ break;
+ default:
+ g_assert_not_reached();
+ reason = "Unknown SSL error code from Loudmouth.";
+ tp_reason = TP_CONN_STATUS_REASON_ENCRYPTION_ERROR;
+ break;
+ }
+
+ gabble_debug (DEBUG_FLAG, "called: %s", reason);
+
+ if (priv->ignore_ssl_errors)
+ {
+ return LM_SSL_RESPONSE_CONTINUE;
+ }
+ else
+ {
+ priv->ssl_error = tp_reason;
+ return LM_SSL_RESPONSE_STOP;
+ }
+}
+
+static void
+do_auth (GabbleConnection *conn)
+{
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ GError *error = NULL;
+
+ gabble_debug (DEBUG_FLAG, "authenticating with username: %s, password: <hidden>, resource: %s",
+ priv->username, priv->resource);
+
+ if (!lm_connection_authenticate (conn->lmconn, priv->username, priv->password,
+ priv->resource, connection_auth_cb,
+ conn, NULL, &error))
+ {
+ gabble_debug (DEBUG_FLAG, "failed: %s", error->message);
+ g_error_free (error);
+
+ /* the reason this function can fail is through network errors,
+ * authentication failures are reported to our auth_cb */
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_NETWORK_ERROR);
+ }
+}
+
+static void
+registration_finished_cb (GabbleRegister *reg,
+ gboolean success,
+ gint err_code,
+ const gchar *err_msg,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+
+ g_message("registration_finished_cb\n");
+ if (conn->status != TP_CONN_STATUS_CONNECTING)
+ {
+ g_assert (conn->status == TP_CONN_STATUS_DISCONNECTED);
+ return;
+ }
+
+ gabble_debug (DEBUG_FLAG, "%s", (success) ? "succeeded" : "failed");
+
+ g_object_unref (reg);
+
+ if (success)
+ {
+ do_auth (conn);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "err_code = %d, err_msg = '%s'",
+ err_code, err_msg);
+
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ (err_code == InvalidArgument) ? TP_CONN_STATUS_REASON_NAME_IN_USE :
+ TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED);
+ }
+}
+
+static void
+do_register (GabbleConnection *conn)
+{
+ GabbleRegister *reg;
+
+ reg = gabble_register_new (conn);
+
+ g_signal_connect (reg, "finished", (GCallback) registration_finished_cb,
+ conn);
+
+ gabble_register_start (reg);
+}
+
+/**
+ * connection_open_cb
+ *
+ * Stage 2 of connecting, this function is called by loudmouth after the
+ * result of the non-blocking lm_connection_open call is known. It makes
+ * a request to authenticate the user with the server, or optionally
+ * registers user on the server first.
+ */
+static void
+connection_open_cb (LmConnection *lmconn,
+ gboolean success,
+ gpointer data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (data);
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ g_message("[connection_open_cb]");
+ if ((conn->status != TP_CONN_STATUS_CONNECTING) &&
+ (conn->status != TP_CONN_STATUS_NEW))
+ {
+ g_assert (conn->status == TP_CONN_STATUS_DISCONNECTED);
+ return;
+ }
+
+ g_assert (priv);
+ g_assert (lmconn == conn->lmconn);
+
+ if (!success)
+ {
+ if (lm_connection_get_proxy (lmconn))
+ {
+ g_message ("failed, retrying without proxy");
+
+ lm_connection_set_proxy (lmconn, NULL);
+
+ if (do_connect (conn, NULL))
+ {
+ return;
+ }
+ }
+ else
+ {
+ g_message ("failed");
+ }
+
+ if (priv->ssl_error)
+ {
+ g_message ("[connection_open_cb] priv->ssl_error");
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ priv->ssl_error);
+ }
+ else
+ {
+ g_message ("[connection_open_cb] reached else");
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_NETWORK_ERROR);
+ }
+
+ return;
+ }
+
+ if (!priv->do_register)
+ do_auth (conn);
+ else
+ do_register (conn);
+}
+
+/**
+ * connection_auth_cb
+ *
+ * Stage 3 of connecting, this function is called by loudmouth after the
+ * result of the non-blocking lm_connection_authenticate call is known.
+ * It sends a discovery request to find the server's features.
+ */
+static void
+connection_auth_cb (LmConnection *lmconn,
+ gboolean success,
+ gpointer data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (data);
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+ GError *error = NULL;
+
+ g_message("In connection_auth_cb\n");
+
+ if (conn->status != TP_CONN_STATUS_CONNECTING)
+ {
+ g_assert (conn->status == TP_CONN_STATUS_DISCONNECTED);
+ return;
+ }
+
+ g_assert (priv);
+ g_assert (lmconn == conn->lmconn);
+
+ if (!success)
+ {
+ gabble_debug (DEBUG_FLAG, "failed");
+ g_message("Inside !success\n");
+
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_AUTHENTICATION_FAILED);
+
+ return;
+ }
+
+ if (!gabble_disco_request_with_timeout (conn->disco, GABBLE_DISCO_TYPE_INFO,
+ priv->stream_server, NULL, 5000,
+ connection_disco_cb, conn,
+ G_OBJECT (conn), &error))
+ {
+ gabble_debug (DEBUG_FLAG, "sending disco request failed: %s",
+ error->message);
+ g_message("sending disco request failed\n");
+
+ g_error_free (error);
+
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_NETWORK_ERROR);
+ }
+}
+
+/**
+ * connection_disco_cb
+ *
+ * Stage 4 of connecting, this function is called by GabbleDisco after the
+ * result of the non-blocking server feature discovery call is known. It sends
+ * the user's initial presence to the server, marking them as available,
+ * and requests the roster.
+ */
+static void
+connection_disco_cb (GabbleDisco *disco,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *result,
+ GError *disco_error,
+ gpointer user_data)
+{
+ GabbleConnection *conn = user_data;
+ GabbleConnectionPrivate *priv;
+ GError *error = NULL;
+
+ g_message("Inside connection_disco_cb\n");
+
+ if ( NULL == conn )
+ {
+ return;
+ }
+ if (conn->status != TP_CONN_STATUS_CONNECTING)
+ {
+ g_assert (conn->status == TP_CONN_STATUS_DISCONNECTED);
+ return;
+ }
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ if (disco_error)
+ {
+ g_message("got disco error, setting no features\n");
+ gabble_debug (DEBUG_FLAG, "got disco error, setting no features: %s", disco_error->message);
+ }
+ else
+ {
+ LmMessageNode *iter;
+
+ NODE_DEBUG (result, "got");
+
+ for (iter = result->children; iter != NULL; iter = iter->next)
+ {
+ if (0 == strcmp (iter->name, "feature"))
+ {
+ const gchar *var = lm_message_node_get_attribute (iter, "var");
+
+ if (var == NULL)
+ continue;
+
+ if (0 == strcmp (var, NS_GOOGLE_JINGLE_INFO))
+ conn->features |= GABBLE_CONNECTION_FEATURES_GOOGLE_JINGLE_INFO;
+ else if (0 == strcmp (var, NS_GOOGLE_ROSTER))
+ conn->features |= GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER;
+ else if (0 == strcmp (var, NS_PRESENCE_INVISIBLE))
+ conn->features |= GABBLE_CONNECTION_FEATURES_PRESENCE_INVISIBLE;
+ else if (0 == strcmp (var, NS_PRIVACY))
+ conn->features |= GABBLE_CONNECTION_FEATURES_PRIVACY;
+ else if (0 == strcmp (var, NS_SEARCH))
+ conn->features |= GABBLE_CONNECTION_FEATURES_SEARCH;
+ }
+ }
+
+ gabble_debug (DEBUG_FLAG, "set features flags to %d", conn->features);
+ }
+
+ g_message("before signal_own_presence\n");
+
+ /* send presence to the server to indicate availability */
+ if (!signal_own_presence (conn, &error))
+ {
+ gabble_debug (DEBUG_FLAG, "sending initial presence failed: %s", error->message);
+ g_message("sending initial presence failed\n");
+ goto ERROR;
+ }
+
+ g_message("after signal_own_presence\n");
+
+ /* go go gadget on-line */
+ connection_status_change (conn, TP_CONN_STATUS_CONNECTED, TP_CONN_STATUS_REASON_REQUESTED);
+
+ if (conn->features & GABBLE_CONNECTION_FEATURES_GOOGLE_JINGLE_INFO)
+ {
+ jingle_info_discover_servers (conn);
+ }
+
+ if(conn->features & GABBLE_CONNECTION_FEATURES_SEARCH)
+ {
+ get_search_keys_info(conn,jid);
+ }
+
+ return;
+
+ERROR:
+ if (error)
+ g_error_free (error);
+
+ connection_status_change (conn,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_NETWORK_ERROR);
+
+ return;
+}
+
+
+static GHashTable *
+get_statuses_arguments()
+{
+
+#ifndef EMULATOR
+ static GHashTable *arguments = NULL;
+#endif
+
+
+ if (arguments == NULL)
+ {
+ arguments = g_hash_table_new (g_str_hash, g_str_equal);
+
+ g_hash_table_insert (arguments, "message", "s");
+ g_hash_table_insert (arguments, "priority", "n");
+ }
+
+ return arguments;
+}
+
+/****************************************************************************
+ * D-BUS EXPORTED METHODS *
+ ****************************************************************************/
+
+
+/**
+ * gabble_connection_add_status
+ *
+ * Implements D-Bus method AddStatus
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_add_status (GabbleConnection *self,
+ const gchar *status,
+ GHashTable *parms,
+ GError **error)
+{
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ ERROR_IF_NOT_CONNECTED (self, error);
+
+ g_set_error (error, TELEPATHY_ERRORS, NotImplemented,
+ "Only one status is possible at a time with this protocol");
+
+ return FALSE;
+}
+
+static void
+_emit_capabilities_changed (GabbleConnection *conn,
+ GabbleHandle handle,
+ GabblePresenceCapabilities old_caps,
+ GabblePresenceCapabilities new_caps)
+{
+ GPtrArray *caps_arr;
+ const CapabilityConversionData *ccd;
+ guint i;
+
+ if (old_caps == new_caps)
+ return;
+
+ caps_arr = g_ptr_array_new ();
+
+ for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
+ {
+ if (ccd->c2tf_fn (old_caps | new_caps))
+ {
+ GValue caps_monster_struct = {0, };
+ guint old_tpflags = ccd->c2tf_fn (old_caps);
+ guint old_caps = old_tpflags ?
+ TP_CONN_CAPABILITY_FLAG_CREATE |
+ TP_CONN_CAPABILITY_FLAG_INVITE : 0;
+ guint new_tpflags = ccd->c2tf_fn (new_caps);
+ guint new_caps = new_tpflags ?
+ TP_CONN_CAPABILITY_FLAG_CREATE |
+ TP_CONN_CAPABILITY_FLAG_INVITE : 0;
+
+ if (0 == (old_tpflags ^ new_tpflags))
+ continue;
+
+ g_value_init (&caps_monster_struct,
+ TP_CAPABILITIES_CHANGED_MONSTER_TYPE);
+ g_value_take_boxed (&caps_monster_struct,
+ dbus_g_type_specialized_construct
+ (TP_CAPABILITIES_CHANGED_MONSTER_TYPE));
+
+ dbus_g_type_struct_set (&caps_monster_struct,
+ 0, handle,
+ 1, ccd->iface,
+ 2, old_caps,
+ 3, new_caps,
+ 4, old_tpflags,
+ 5, new_tpflags,
+ G_MAXUINT);
+
+ g_ptr_array_add (caps_arr, g_value_get_boxed (&caps_monster_struct));
+ }
+ }
+
+ if (caps_arr->len)
+ g_signal_emit (conn, signals[CAPABILITIES_CHANGED], 0, caps_arr);
+
+ for (i = 0; i < caps_arr->len; i++)
+ {
+ g_boxed_free (TP_CAPABILITIES_CHANGED_MONSTER_TYPE,
+ g_ptr_array_index (caps_arr, i));
+ }
+ g_ptr_array_free (caps_arr, TRUE);
+}
+
+static void
+connection_capabilities_update_cb (GabblePresenceCache *cache,
+ GabbleHandle handle,
+ GabblePresenceCapabilities old_caps,
+ GabblePresenceCapabilities new_caps,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+
+ _emit_capabilities_changed (conn, handle, old_caps, new_caps);
+}
+
+/**
+ * gabble_connection_advertise_capabilities
+ *
+ * Implements D-Bus method AdvertiseCapabilities
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Capabilities
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_advertise_capabilities (GabbleConnection *self,
+ const GPtrArray *add,
+ const gchar **remove,
+ GPtrArray **ret,
+ GError **error)
+{
+ guint i;
+ GabblePresence *pres;
+ GabblePresenceCapabilities add_caps = 0, remove_caps = 0, caps, save_caps;
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+ const CapabilityConversionData *ccd;
+
+ ERROR_IF_NOT_CONNECTED (self, error);
+
+ pres = gabble_presence_cache_get (self->presence_cache, self->self_handle);
+ gabble_debug (DEBUG_FLAG, "caps before: %x", pres->caps);
+
+ for (i = 0; i < add->len; i++)
+ {
+ GValue iface_flags_pair = {0, };
+ gchar *iface;
+ guint flags;
+
+ g_value_init (&iface_flags_pair, TP_CAPABILITY_PAIR_TYPE);
+ g_value_set_static_boxed (&iface_flags_pair, g_ptr_array_index (add, i));
+
+ dbus_g_type_struct_get (&iface_flags_pair,
+ 0, &iface,
+ 1, &flags,
+ G_MAXUINT);
+
+ for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
+ if (g_str_equal (iface, ccd->iface))
+ add_caps |= ccd->tf2c_fn (flags);
+ }
+
+ for (i = 0; NULL != remove[i]; i++)
+ {
+ for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
+ if (g_str_equal (remove[i], ccd->iface))
+ remove_caps |= ccd->tf2c_fn (~0);
+ }
+
+ pres = gabble_presence_cache_get (self->presence_cache, self->self_handle);
+ save_caps = caps = pres->caps;
+
+ caps |= add_caps;
+ caps ^= (caps & remove_caps);
+
+ gabble_debug (DEBUG_FLAG, "caps to add: %x", add_caps);
+ gabble_debug (DEBUG_FLAG, "caps to remove: %x", remove_caps);
+ gabble_debug (DEBUG_FLAG, "caps after: %x", caps);
+
+ if (caps ^ save_caps)
+ {
+ gabble_debug (DEBUG_FLAG, "before != after, changing");
+ gabble_presence_set_capabilities (pres, priv->resource, caps, priv->caps_serial++);
+ gabble_debug (DEBUG_FLAG, "set caps: %x", pres->caps);
+ }
+
+ *ret = g_ptr_array_new ();
+
+ for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
+ {
+ if (ccd->c2tf_fn (pres->caps))
+ {
+ GValue iface_flags_pair = {0, };
+
+ g_value_init (&iface_flags_pair, TP_CAPABILITY_PAIR_TYPE);
+ g_value_take_boxed (&iface_flags_pair,
+ dbus_g_type_specialized_construct (TP_CAPABILITY_PAIR_TYPE));
+
+ dbus_g_type_struct_set (&iface_flags_pair,
+ 0, ccd->iface,
+ 1, ccd->c2tf_fn (pres->caps),
+ G_MAXUINT);
+
+ g_ptr_array_add (*ret, g_value_get_boxed (&iface_flags_pair));
+ }
+ }
+
+ if (caps ^ save_caps)
+ {
+ if (!signal_own_presence (self, error))
+ return FALSE;
+
+ _emit_capabilities_changed (self, self->self_handle, save_caps, caps);
+ }
+
+ return TRUE;
+}
+
+/**
+ * gabble_connection_clear_status
+ *
+ * Implements D-Bus method ClearStatus
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_clear_status (GabbleConnection *self,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error);
+
+ gabble_presence_cache_update (self->presence_cache, self->self_handle,
+ priv->resource, GABBLE_PRESENCE_AVAILABLE, NULL, priv->priority);
+ emit_one_presence_update (self, self->self_handle);
+ return signal_own_presence (self, error);
+}
+
+
+/**
+ * gabble_connection_connect
+ * Implements D-Bus method Connect
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+
+gboolean
+gabble_connection_connect (GabbleConnection *self,
+ GError **error)
+{
+ g_assert(GABBLE_IS_CONNECTION (self));
+
+ if (self->status == TP_CONN_STATUS_NEW)
+ return _gabble_connection_connect (self, error);
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_disconnect
+ *
+ * Implements D-Bus method Disconnect
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_disconnect (GabbleConnection *self,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ g_message("gabble_connection_disconnect: going to change status to TP_CONN_STATUS_DISCONNECTED ") ;
+ connection_status_change (self,
+ TP_CONN_STATUS_DISCONNECTED,
+ TP_CONN_STATUS_REASON_REQUESTED);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_get_alias_flags
+ *
+ * Implements D-Bus method GetAliasFlags
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_alias_flags (GabbleConnection *self,
+ guint *ret,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ *ret = TP_CONN_ALIAS_FLAG_USER_SET;
+
+ return TRUE;
+}
+
+//#ifndef EMULATOR
+static const gchar *assumed_caps[] =
+{
+ TP_IFACE_CHANNEL_TYPE_TEXT,
+ TP_IFACE_CHANNEL_INTERFACE_GROUP,
+ NULL
+};
+//#endif
+
+
+/**
+ * gabble_connection_get_capabilities
+ *
+ * Implements D-Bus method GetCapabilities
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Capabilities
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_capabilities (GabbleConnection *self,
+ const GArray *handles,
+ GPtrArray **ret,
+ GError **error)
+{
+ guint i;
+
+ ERROR_IF_NOT_CONNECTED (self, error);
+
+ if (!gabble_handles_are_valid (self->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ handles,
+ TRUE,
+ error))
+ {
+ return FALSE;
+ }
+
+ *ret = g_ptr_array_new ();
+
+ for (i = 0; i < handles->len; i++)
+ {
+ GabbleHandle handle = g_array_index (handles, guint, i);
+ GabblePresence *pres;
+ const CapabilityConversionData *ccd;
+ guint typeflags;
+ //#ifndef EMULATOR
+ const gchar **assumed;
+ //#else
+ //gchar **assumed;
+ //#endif
+
+ if (0 == handle)
+ {
+ /* FIXME report the magical channel types available on the connection itself */
+ continue;
+ }
+
+ pres = gabble_presence_cache_get (self->presence_cache, handle);
+
+ if (NULL != pres)
+ for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
+ {
+ typeflags = ccd->c2tf_fn (pres->caps);
+
+ if (typeflags)
+ {
+ GValue monster = {0, };
+
+ g_value_init (&monster, TP_GET_CAPABILITIES_MONSTER_TYPE);
+ g_value_take_boxed (&monster,
+ dbus_g_type_specialized_construct (
+ TP_GET_CAPABILITIES_MONSTER_TYPE));
+
+ dbus_g_type_struct_set (&monster,
+ 0, handle,
+ 1, ccd->iface,
+ 2, TP_CONN_CAPABILITY_FLAG_CREATE |
+ TP_CONN_CAPABILITY_FLAG_INVITE,
+ 3, typeflags,
+ G_MAXUINT);
+
+ g_ptr_array_add (*ret, g_value_get_boxed (&monster));
+ }
+ }
+
+ for (assumed = assumed_caps; NULL != *assumed; assumed++)
+ {
+ GValue monster = {0, };
+
+ g_value_init (&monster, TP_GET_CAPABILITIES_MONSTER_TYPE);
+ g_value_take_boxed (&monster,
+ dbus_g_type_specialized_construct (TP_GET_CAPABILITIES_MONSTER_TYPE));
+
+ dbus_g_type_struct_set (&monster,
+ 0, handle,
+ 1, *assumed,
+ 2, TP_CONN_CAPABILITY_FLAG_CREATE |
+ TP_CONN_CAPABILITY_FLAG_INVITE,
+ 3, 0,
+ G_MAXUINT);
+
+ g_ptr_array_add (*ret, g_value_get_boxed (&monster));
+ }
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_interfaces (GabbleConnection *self,
+ gchar ***ret,
+ GError **error)
+{
+ const char *interfaces[] = {
+ TP_IFACE_CONN_INTERFACE_ALIASING,
+ TP_IFACE_CONN_INTERFACE_CAPABILITIES,
+ TP_IFACE_CONN_INTERFACE_PRESENCE,
+ TP_IFACE_PROPERTIES,
+ TP_IFACE_CONN_INTERFACE_AVATAR,
+ NULL };
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_get_presence
+ *
+ * Implements D-Bus method GetPresence
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_get_presence (GabbleConnection *self,
+ const GArray *contacts,
+ DBusGMethodInvocation *context)
+{
+ GHashTable *presence_hash;
+ GError *error = NULL;
+
+ if (!gabble_handles_are_valid (self->handles, TP_HANDLE_TYPE_CONTACT,
+ contacts, FALSE, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ }
+
+ presence_hash = construct_presence_hash (self, contacts);
+ dbus_g_method_return (context, presence_hash);
+ g_hash_table_destroy (presence_hash);
+}
+
+
+/**
+ * gabble_connection_get_properties
+ *
+ * Implements D-Bus method GetProperties
+ * on interface org.freedesktop.Telepathy.Properties
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_properties (GabbleConnection *self,
+ const GArray *properties,
+ GPtrArray **ret,
+ GError **error)
+{
+ return gabble_properties_mixin_get_properties (G_OBJECT (self), properties,
+ ret, error);
+}
+
+
+/**
+ * gabble_connection_get_protocol
+ *
+ * Implements D-Bus method GetProtocol
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_protocol (GabbleConnection *self,
+ gchar **ret,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ *ret = g_strdup (priv->protocol);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_get_self_handle
+ *
+ * Implements D-Bus method GetSelfHandle
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_self_handle (GabbleConnection *self,
+ guint *ret,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ *ret = self->self_handle;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_get_status
+ *
+ * Implements D-Bus method GetStatus
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_status (GabbleConnection *self,
+ guint *ret,
+ GError **error)
+{
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ if (self->status == TP_CONN_STATUS_NEW)
+ {
+ *ret = TP_CONN_STATUS_DISCONNECTED;
+ }
+ else
+ {
+ *ret = self->status;
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_get_statuses
+ *
+ * Implements D-Bus method GetStatuses
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_get_statuses (GabbleConnection *self,
+ GHashTable **ret,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ GValueArray *status;
+ int i;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ gabble_debug (DEBUG_FLAG, "called.");
+
+ *ret = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, (GDestroyNotify) g_value_array_free);
+
+ for (i=0; i < LAST_GABBLE_PRESENCE; i++)
+ {
+ /* don't report the invisible presence if the server
+ * doesn't have the presence-invisible feature */
+ if (!status_is_available (self, i))
+ continue;
+
+ status = g_value_array_new (5);
+
+ g_value_array_append (status, NULL);
+ g_value_init (g_value_array_get_nth (status, 0), G_TYPE_UINT);
+ g_value_set_uint (g_value_array_get_nth (status, 0),
+ gabble_statuses[i].presence_type);
+
+ g_value_array_append (status, NULL);
+ g_value_init (g_value_array_get_nth (status, 1), G_TYPE_BOOLEAN);
+ g_value_set_boolean (g_value_array_get_nth (status, 1),
+ gabble_statuses[i].self);
+
+ g_value_array_append (status, NULL);
+ g_value_init (g_value_array_get_nth (status, 2), G_TYPE_BOOLEAN);
+ g_value_set_boolean (g_value_array_get_nth (status, 2),
+ gabble_statuses[i].exclusive);
+
+ g_value_array_append (status, NULL);
+ g_value_init (g_value_array_get_nth (status, 3),
+ DBUS_TYPE_G_STRING_STRING_HASHTABLE);
+ g_value_set_static_boxed (g_value_array_get_nth (status, 3),
+ get_statuses_arguments());
+
+ g_hash_table_insert (*ret, (gchar*) gabble_statuses[i].name, status);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_hold_handles
+ *
+ * Implements D-Bus method HoldHandles
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_hold_handles (GabbleConnection *self,
+ guint handle_type,
+ const GArray *handles,
+ DBusGMethodInvocation *context)
+{
+ GabbleConnectionPrivate *priv;
+ GError *error = NULL;
+ gchar *sender;
+ guint i;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED_ASYNC (self, error, context)
+
+ if (!gabble_handles_are_valid (self->handles,
+ handle_type,
+ handles,
+ FALSE,
+ &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ sender = dbus_g_method_get_sender (context);
+ for (i = 0; i < handles->len; i++)
+ {
+ GabbleHandle handle = g_array_index (handles, GabbleHandle, i);
+ if (!gabble_handle_client_hold (self->handles, sender, handle,
+ handle_type, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+ }
+
+ dbus_g_method_return (context);
+}
+
+
+/**
+ * gabble_connection_inspect_handles
+ *
+ * Implements D-Bus method InspectHandles
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+void
+gabble_connection_inspect_handles (GabbleConnection *self,
+ guint handle_type,
+ const GArray *handles,
+ DBusGMethodInvocation *context)
+{
+ GabbleConnectionPrivate *priv;
+ GError *error = NULL;
+ const gchar **ret;
+ guint i;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED_ASYNC (self, error, context);
+
+ if (!gabble_handles_are_valid (self->handles,
+ handle_type,
+ handles,
+ FALSE,
+ &error))
+ {
+ dbus_g_method_return_error (context, error);
+
+ g_error_free (error);
+
+ return;
+ }
+
+ ret = g_new (const gchar *, handles->len + 1);
+
+ for (i = 0; i < handles->len; i++)
+ {
+ GabbleHandle handle;
+ const gchar *tmp;
+
+ handle = g_array_index (handles, GabbleHandle, i);
+ tmp = gabble_handle_inspect (self->handles, handle_type, handle);
+ g_assert (tmp != NULL);
+
+ ret[i] = tmp;
+ }
+
+ ret[i] = NULL;
+
+ dbus_g_method_return (context, ret);
+
+ g_free (ret);
+}
+
+/**
+ * list_channel_factory_foreach_one:
+ * @key: iterated key
+ * @value: iterated value
+ * @data: data attached to this key/value pair
+ *
+ * Called by the exported ListChannels function, this should iterate over
+ * the handle/channel pairs in a channel factory, and to the GPtrArray in
+ * the data pointer, add a GValueArray containing the following:
+ * a D-Bus object path for the channel object on this service
+ * a D-Bus interface name representing the channel type
+ * an integer representing the handle type this channel communicates with, or zero
+ * an integer handle representing the contact, room or list this channel communicates with, or zero
+ */
+static void
+list_channel_factory_foreach_one (TpChannelIface *chan,
+ gpointer data)
+{
+ GObject *channel = G_OBJECT (chan);
+ GPtrArray *channels = (GPtrArray *) data;
+ gchar *path, *type;
+ guint handle_type, handle;
+ GValue entry = { 0, };
+
+ g_value_init (&entry, TP_CHANNEL_LIST_ENTRY_TYPE);
+ g_value_take_boxed (&entry, dbus_g_type_specialized_construct
+ (TP_CHANNEL_LIST_ENTRY_TYPE));
+
+ g_object_get (channel,
+ "object-path", &path,
+ "channel-type", &type,
+ "handle-type", &handle_type,
+ "handle", &handle,
+ NULL);
+
+ dbus_g_type_struct_set (&entry,
+ 0, path,
+ 1, type,
+ 2, handle_type,
+ 3, handle,
+ G_MAXUINT);
+
+ g_ptr_array_add (channels, g_value_get_boxed (&entry));
+
+ g_free (path);
+ g_free (type);
+}
+
+/**
+ * gabble_connection_list_channels
+ *
+ * Implements D-Bus method ListChannels
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_list_channels (GabbleConnection *self,
+ GPtrArray **ret,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ GPtrArray *channels;
+ guint i;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ /* I think on average, each factory will have 2 channels :D */
+ channels = g_ptr_array_sized_new (priv->channel_factories->len * 2);
+
+ for (i = 0; i < priv->channel_factories->len; i++)
+ {
+ TpChannelFactoryIface *factory = g_ptr_array_index
+ (priv->channel_factories, i);
+ tp_channel_factory_iface_foreach (factory,
+ list_channel_factory_foreach_one, channels);
+ }
+
+ *ret = channels;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_connection_list_properties
+ *
+ * Implements D-Bus method ListProperties
+ * on interface org.freedesktop.Telepathy.Properties
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_list_properties (GabbleConnection *self,
+ GPtrArray **ret,
+ GError **error)
+{
+ return gabble_properties_mixin_list_properties (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_connection_release_handles
+ *
+ * Implements D-Bus method ReleaseHandles
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_release_handles (GabbleConnection *self,
+ guint handle_type,
+ const GArray * handles,
+ DBusGMethodInvocation *context)
+{
+ GabbleConnectionPrivate *priv;
+ char *sender;
+ GError *error = NULL;
+ guint i;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED_ASYNC (self, error, context)
+
+ if (!gabble_handles_are_valid (self->handles,
+ handle_type,
+ handles,
+ FALSE,
+ &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ sender = dbus_g_method_get_sender (context);
+ for (i = 0; i < handles->len; i++)
+ {
+ GabbleHandle handle = g_array_index (handles, GabbleHandle, i);
+ if (!gabble_handle_client_release (self->handles, sender, handle,
+ handle_type, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+ }
+
+ dbus_g_method_return (context);
+}
+
+
+/**
+ * gabble_connection_remove_status
+ *
+ * Implements D-Bus method RemoveStatus
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_remove_status (GabbleConnection *self,
+ const gchar *status,
+ GError **error)
+{
+ GabblePresence *presence;
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ presence = gabble_presence_cache_get (self->presence_cache,
+ self->self_handle);
+
+ if (strcmp (status, gabble_statuses[presence->status].name) == 0)
+ {
+ gabble_presence_cache_update (self->presence_cache, self->self_handle,
+ priv->resource, GABBLE_PRESENCE_AVAILABLE, NULL, priv->priority);
+ emit_one_presence_update (self, self->self_handle);
+ return signal_own_presence (self, error);
+ }
+ else
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "Attempting to remove non-existent presence.");
+ return FALSE;
+ }
+}
+
+
+typedef struct _AliasesRequest AliasesRequest;
+
+struct _AliasesRequest
+{
+ GabbleConnection *conn;
+ DBusGMethodInvocation *request_call;
+ guint pending_vcard_requests;
+ GArray *contacts;
+ GabbleVCardManagerRequest **vcard_requests;
+ gchar **aliases;
+};
+
+
+static AliasesRequest *
+aliases_request_new (GabbleConnection *conn,
+ DBusGMethodInvocation *request_call,
+ const GArray *contacts)
+{
+ AliasesRequest *request;
+
+ request = g_slice_new0 (AliasesRequest);
+ request->conn = conn;
+ request->request_call = request_call;
+ request->contacts = g_array_new (FALSE, FALSE, sizeof (GabbleHandle));
+ g_array_insert_vals (request->contacts, 0, contacts->data, contacts->len);
+ request->vcard_requests =
+ g_new0 (GabbleVCardManagerRequest *, contacts->len);
+ request->aliases = g_new0 (gchar *, contacts->len + 1);
+ return request;
+}
+
+
+static void
+aliases_request_free (AliasesRequest *request)
+{
+ guint i;
+
+ for (i = 0; i < request->contacts->len; i++)
+ {
+ if (request->vcard_requests[i] != NULL)
+ gabble_vcard_manager_cancel_request (request->conn->vcard_manager,
+ request->vcard_requests[i]);
+ }
+
+ g_array_free (request->contacts, TRUE);
+ g_free (request->vcard_requests);
+ g_strfreev (request->aliases);
+ g_slice_free (AliasesRequest, request);
+}
+
+
+static gboolean
+aliases_request_try_return (AliasesRequest *request)
+{
+ if (request->pending_vcard_requests == 0)
+ {
+ dbus_g_method_return (request->request_call, request->aliases);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static void
+aliases_request_vcard_cb (GabbleVCardManager *manager,
+ GabbleVCardManagerRequest *request,
+ GabbleHandle handle,
+ LmMessageNode *vcard,
+ GError *error,
+ gpointer user_data)
+{
+ AliasesRequest *aliases_request = (AliasesRequest *) user_data;
+ GabbleConnectionAliasSource source;
+ guint i;
+ gboolean found = FALSE;
+ gchar *alias = NULL;
+
+ g_assert (aliases_request->pending_vcard_requests > 0);
+
+ /* The index of the vCard request in the vCard request array is the
+ * index of the contact/alias in their respective arrays. */
+
+ for (i = 0; i < aliases_request->contacts->len; i++)
+ if (aliases_request->vcard_requests[i] == request)
+ {
+ found = TRUE;
+ break;
+ }
+
+ g_assert (found);
+ source = _gabble_connection_get_cached_alias (aliases_request->conn,
+ g_array_index (aliases_request->contacts, GabbleHandle, i), &alias);
+ g_assert (source != GABBLE_CONNECTION_ALIAS_NONE);
+ g_assert (NULL != alias);
+
+ aliases_request->pending_vcard_requests--;
+ aliases_request->vcard_requests[i] = NULL;
+ aliases_request->aliases[i] = alias;
+
+ if (aliases_request_try_return (aliases_request))
+ aliases_request_free (aliases_request);
+}
+
+
+/**
+ * gabble_connection_request_aliases
+ *
+ * Implements D-Bus method RequestAliases
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_request_aliases (GabbleConnection *self,
+ const GArray *contacts,
+ DBusGMethodInvocation *context)
+{
+ guint i;
+ AliasesRequest *request;
+ GError *error = NULL;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ ERROR_IF_NOT_CONNECTED_ASYNC (self, error, context)
+
+ if (!gabble_handles_are_valid (self->handles, TP_HANDLE_TYPE_CONTACT,
+ contacts, FALSE, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ request = aliases_request_new (self, context, contacts);
+
+ for (i = 0; i < contacts->len; i++)
+ {
+ GabbleHandle handle = g_array_index (contacts, GabbleHandle, i);
+ GabbleConnectionAliasSource source;
+ GabbleVCardManagerRequest *vcard_request;
+ gchar *alias;
+
+ source = _gabble_connection_get_cached_alias (self, handle, &alias);
+ g_assert (source != GABBLE_CONNECTION_ALIAS_NONE);
+ g_assert (NULL != alias);
+
+ if (source >= GABBLE_CONNECTION_ALIAS_FROM_VCARD ||
+ gabble_vcard_manager_has_cached_alias (self->vcard_manager, handle))
+ {
+ /* Either the alias we got was from a vCard or better, or we already
+ * tried getting an alias from a vcard and failed, so there's no
+ * point trying again. */
+ request->aliases[i] = alias;
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "requesting vCard for alias of contact %s",
+ gabble_handle_inspect (self->handles, TP_HANDLE_TYPE_CONTACT,
+ handle));
+
+ g_free (alias);
+ vcard_request = gabble_vcard_manager_request (self->vcard_manager,
+ handle, 0, aliases_request_vcard_cb, request, G_OBJECT (self),
+ &error);
+
+ if (NULL != error)
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ aliases_request_free (request);
+ return;
+ }
+
+ request->vcard_requests[i] = vcard_request;
+ request->pending_vcard_requests++;
+ }
+ }
+
+ if (aliases_request_try_return (request))
+ aliases_request_free (request);
+}
+
+
+/**
+ * gabble_connection_request_channel
+ *
+ * Implements D-Bus method RequestChannel
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_request_channel (GabbleConnection *self,
+ const gchar *type,
+ guint handle_type,
+ guint handle,
+ gboolean suppress_handler,
+ DBusGMethodInvocation *context)
+{
+ GabbleConnectionPrivate *priv;
+ TpChannelFactoryRequestStatus status =
+ TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
+ gchar *object_path = NULL;
+ GError *error = NULL;
+ guint i;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED_ASYNC (self, error, context);
+
+ for (i = 0; i < priv->channel_factories->len; i++)
+ {
+ TpChannelFactoryIface *factory = g_ptr_array_index
+ (priv->channel_factories, i);
+ TpChannelFactoryRequestStatus cur_status;
+ TpChannelIface *chan = NULL;
+ ChannelRequest *request = NULL;
+
+ priv->suppress_next_handler = suppress_handler;
+
+ cur_status = tp_channel_factory_iface_request (factory, type,
+ (TpHandleType) handle_type, handle, &chan, &error);
+
+ priv->suppress_next_handler = FALSE;
+
+ switch (cur_status)
+ {
+ case TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE:
+ g_assert (NULL != chan);
+ g_object_get (chan, "object-path", &object_path, NULL);
+ goto OUT;
+ case TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED:
+ gabble_debug (DEBUG_FLAG, "queueing request, channel_type=%s, handle_type=%u, "
+ "handle=%u, suppress_handler=%u", type, handle_type,
+ handle, suppress_handler);
+ request = channel_request_new (context, type, handle_type, handle,
+ suppress_handler);
+ g_ptr_array_add (priv->channel_requests, request);
+ return;
+ case TP_CHANNEL_FACTORY_REQUEST_STATUS_ERROR:
+ /* pass through error */
+ goto OUT;
+ default:
+ /* always return the most specific error */
+ if (cur_status > status)
+ status = cur_status;
+ }
+ }
+
+ switch (status)
+ {
+ case TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE:
+ gabble_debug (DEBUG_FLAG, "invalid handle %u", handle);
+
+ error = g_error_new (TELEPATHY_ERRORS, InvalidHandle,
+ "invalid handle %u", handle);
+
+ break;
+
+ case TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE:
+ gabble_debug (DEBUG_FLAG, "requested channel is unavailable with "
+ "handle type %u", handle_type);
+
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "requested channel is not available with "
+ "handle type %u", handle_type);
+
+ break;
+
+ case TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED:
+ gabble_debug (DEBUG_FLAG, "unsupported channel type %s", type);
+
+ error = g_error_new (TELEPATHY_ERRORS, NotImplemented,
+ "unsupported channel type %s", type);
+
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+OUT:
+ if (NULL != error)
+ {
+ g_assert (NULL == object_path);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ g_assert (NULL != object_path);
+ dbus_g_method_return (context, object_path);
+ g_free (object_path);
+}
+
+
+static void
+hold_and_return_handles (DBusGMethodInvocation *context,
+ GabbleConnection *conn,
+ GArray *handles,
+ guint handle_type)
+{
+ GError *error = NULL;
+ gchar *sender = dbus_g_method_get_sender(context);
+ guint i;
+
+ for (i = 0; i < handles->len; i++)
+ {
+ GabbleHandle handle = (GabbleHandle) g_array_index (handles, guint, i);
+ if (!gabble_handle_client_hold (conn->handles, sender, handle, handle_type, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+ }
+ dbus_g_method_return (context, handles);
+}
+
+
+const char *
+_gabble_connection_find_conference_server (GabbleConnection *conn)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (conn);
+
+ if (priv->conference_server == NULL)
+ {
+ /* Find first server that has NS_MUC feature */
+ const GabbleDiscoItem *item = gabble_disco_service_find (conn->disco,
+ NULL, NULL, NS_MUC);
+ if (item != NULL)
+ priv->conference_server = item->jid;
+ }
+
+ if (priv->conference_server == NULL)
+ priv->conference_server = priv->fallback_conference_server;
+
+ return priv->conference_server;
+}
+
+
+static gchar *
+_gabble_connection_get_canonical_room_name (GabbleConnection *conn,
+ const gchar *name)
+{
+ const gchar *server;
+
+ g_assert (GABBLE_IS_CONNECTION (conn));
+
+ if (index (name, '@'))
+ return g_strdup (name);
+
+ server = _gabble_connection_find_conference_server (conn);
+
+ if (server == NULL)
+ return NULL;
+
+ return g_strdup_printf ("%s@%s", name, server);
+}
+
+
+typedef struct _RoomVerifyContext RoomVerifyContext;
+
+typedef struct {
+ GabbleConnection *conn;
+ DBusGMethodInvocation *invocation;
+ gboolean errored;
+ guint count;
+ GArray *handles;
+ RoomVerifyContext *contexts;
+} RoomVerifyBatch;
+
+struct _RoomVerifyContext {
+ gchar *jid;
+ guint index;
+ RoomVerifyBatch *batch;
+ GabbleDiscoRequest *request;
+};
+
+static void
+room_verify_batch_free (RoomVerifyBatch *batch)
+{
+ guint i;
+
+ g_array_free (batch->handles, TRUE);
+ for (i = 0; i < batch->count; i++)
+ {
+ g_free(batch->contexts[i].jid);
+ }
+ g_free (batch->contexts);
+ g_free (batch);
+}
+
+/* Frees the error and the batch. */
+static void
+room_verify_batch_raise_error (RoomVerifyBatch *batch,
+ GError *error)
+{
+ guint i;
+
+ dbus_g_method_return_error (batch->invocation, error);
+ g_error_free (error);
+ batch->errored = TRUE;
+ for (i = 0; i < batch->count; i++)
+ {
+ if (batch->contexts[i].request)
+ {
+ gabble_disco_cancel_request(batch->conn->disco,
+ batch->contexts[i].request);
+ }
+ }
+ room_verify_batch_free (batch);
+}
+
+static RoomVerifyBatch *
+room_verify_batch_new (GabbleConnection *conn,
+ DBusGMethodInvocation *invocation,
+ guint count,
+ const gchar **jids)
+{
+ RoomVerifyBatch *batch = g_new(RoomVerifyBatch, 1);
+ guint i;
+
+ batch->errored = FALSE;
+ batch->conn = conn;
+ batch->invocation = invocation;
+ batch->count = count;
+ batch->handles = g_array_sized_new(FALSE, FALSE, sizeof(GabbleHandle), count);
+ batch->contexts = g_new0(RoomVerifyContext, count);
+ for (i = 0; i < count; i++)
+ {
+ const gchar *name = jids[i];
+ gchar *qualified_name;
+ GabbleHandle handle;
+
+ batch->contexts[i].index = i;
+ batch->contexts[i].batch = batch;
+
+ qualified_name = _gabble_connection_get_canonical_room_name (conn, name);
+
+ if (!qualified_name)
+ {
+ GError *error = NULL;
+ gabble_debug (DEBUG_FLAG, "requested handle %s contains no conference server",
+ name);
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable, "requested "
+ "room handle %s does not specify a server, but we have not discovered "
+ "any local conference servers and no fallback was provided", name);
+ room_verify_batch_raise_error (batch, error);
+ return NULL;
+ }
+
+ batch->contexts[i].jid = qualified_name;
+
+ /* has the handle been verified before? */
+ if (gabble_handle_for_room_exists (conn->handles, qualified_name, FALSE))
+ {
+ handle = gabble_handle_for_room (conn->handles, qualified_name);
+ }
+ else
+ {
+ handle = 0;
+ }
+ g_array_append_val (batch->handles, handle);
+ }
+
+ return batch;
+}
+
+/* If all handles in the array have been disco'd or got from cache,
+free the batch and return TRUE. Else return FALSE. */
+static gboolean
+room_verify_batch_try_return (RoomVerifyBatch *batch)
+{
+ guint i;
+
+ for (i = 0; i < batch->count; i++)
+ {
+ if (!g_array_index(batch->handles, GabbleHandle, i))
+ {
+ /* we're not ready yet */
+ return FALSE;
+ }
+ }
+
+ hold_and_return_handles (batch->invocation, batch->conn, batch->handles, TP_HANDLE_TYPE_ROOM);
+ room_verify_batch_free (batch);
+ return TRUE;
+}
+
+static void
+room_jid_disco_cb (GabbleDisco *disco,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *query_result,
+ GError *error,
+ gpointer user_data)
+{
+ RoomVerifyContext *rvctx = user_data;
+ RoomVerifyBatch *batch = rvctx->batch;
+ LmMessageNode *lm_node;
+ gboolean found = FALSE;
+ GabbleHandle handle;
+
+ /* stop the request getting cancelled after it's already finished */
+ rvctx->request = NULL;
+
+ /* if an error is being handled already, quietly go away */
+ if (batch->errored)
+ {
+ return;
+ }
+
+ if (error != NULL)
+ {
+ gabble_debug (DEBUG_FLAG, "disco reply error %s", error->message);
+
+ /* disco will free the old error, _raise_error will free the new one */
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "can't retrieve room info: %s", error->message);
+
+ room_verify_batch_raise_error (batch, error);
+
+ return;
+ }
+
+ for (lm_node = query_result->children; lm_node; lm_node = lm_node->next)
+ {
+ const gchar *var;
+
+ if (g_strdiff (lm_node->name, "feature"))
+ continue;
+
+ var = lm_message_node_get_attribute (lm_node, "var");
+
+ /* for servers who consider schema compliance to be an optional bonus */
+ if (var == NULL)
+ var = lm_message_node_get_attribute (lm_node, "type");
+
+ if (!g_strdiff (var, NS_MUC))
+ {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ gabble_debug (DEBUG_FLAG, "no MUC support for service name in jid %s", rvctx->jid);
+
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable, "specified server "
+ "doesn't support MUC");
+
+ room_verify_batch_raise_error (batch, error);
+
+ return;
+ }
+
+ handle = gabble_handle_for_room (batch->conn->handles, rvctx->jid);
+ g_assert (handle != 0);
+
+ gabble_debug (DEBUG_FLAG, "disco reported MUC support for service name in jid %s", rvctx->jid);
+ g_array_index (batch->handles, GabbleHandle, rvctx->index) = handle;
+
+ /* if this was the last callback to be run, send off the result */
+ room_verify_batch_try_return (batch);
+}
+
+/**
+ * room_jid_verify:
+ *
+ * Utility function that verifies that the service name of
+ * the specified jid exists and reports MUC support.
+ */
+static gboolean
+room_jid_verify (RoomVerifyBatch *batch,
+ guint index,
+ DBusGMethodInvocation *context)
+{
+ gchar *room, *service;
+ gboolean ret;
+ GError *error = NULL;
+
+ room = service = NULL;
+ gabble_decode_jid (batch->contexts[index].jid, &room, &service, NULL);
+
+ g_assert (room && service);
+
+ ret = (gabble_disco_request (batch->conn->disco, GABBLE_DISCO_TYPE_INFO,
+ service, NULL, room_jid_disco_cb,
+ batch->contexts + index,
+ G_OBJECT (batch->conn), &error) != NULL);
+ if (!ret)
+ {
+ room_verify_batch_raise_error (batch, error);
+ }
+
+ g_free (room);
+ g_free (service);
+
+ return ret;
+}
+
+
+/**
+ * gabble_connection_request_handles
+ *
+ * Implements D-Bus method RequestHandles
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_request_handles (GabbleConnection *self,
+ guint handle_type,
+ const gchar **names,
+ DBusGMethodInvocation *context)
+{
+ guint count = 0, i;
+ const gchar **cur_name;
+ GError *error = NULL;
+ GArray *handles = NULL;
+ RoomVerifyBatch *batch = NULL;
+
+ for (cur_name = names; *cur_name != NULL; cur_name++)
+ {
+ count++;
+ }
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ ERROR_IF_NOT_CONNECTED_ASYNC (self, error, context)
+
+ if (!gabble_handle_type_is_valid (handle_type, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ switch (handle_type)
+ {
+ case TP_HANDLE_TYPE_CONTACT:
+ handles = g_array_sized_new(FALSE, FALSE, sizeof(GabbleHandle), count);
+
+ for (i = 0; i < count; i++)
+ {
+ GabbleHandle handle;
+ const gchar *name = names[i];
+
+ if (!gabble_handle_jid_is_valid (handle_type, name, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+
+ g_array_free (handles, TRUE);
+ return;
+ }
+
+ handle = gabble_handle_for_contact (self->handles, name, FALSE);
+
+ if (handle == 0)
+ {
+ gabble_debug (DEBUG_FLAG, "requested handle %s was invalid", name);
+
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "requested handle %s was invalid", name);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+
+ g_array_free (handles, TRUE);
+ return;
+ }
+
+ g_array_append_val(handles, handle);
+ }
+ hold_and_return_handles (context, self, handles, handle_type);
+ g_array_free(handles, TRUE);
+ break;
+
+ case TP_HANDLE_TYPE_ROOM:
+ batch = room_verify_batch_new (self, context, count, names);
+ if (!batch)
+ {
+ /* an error occurred while setting up the batch, and we returned error
+ to dbus */
+ return;
+ }
+
+ /* have all the handles been verified already? If so, nothing to do */
+ if (room_verify_batch_try_return (batch))
+ {
+ return;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ if (!room_jid_verify (batch, i, context))
+ {
+ return;
+ }
+ }
+
+ /* we've set the verification process going - the callback will handle
+ returning or raising error */
+ break;
+
+ case TP_HANDLE_TYPE_LIST:
+ handles = g_array_sized_new(FALSE, FALSE, sizeof(GabbleHandle), count);
+
+ for (i = 0; i < count; i++)
+ {
+ GabbleHandle handle;
+ const gchar *name = names[i];
+
+ handle = gabble_handle_for_list (self->handles, name);
+
+ if (handle == 0)
+ {
+ gabble_debug (DEBUG_FLAG, "requested list channel %s not available", name);
+
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "requested list channel %s not available",
+ name);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+
+ g_array_free (handles, TRUE);
+ return;
+ }
+ g_array_append_val(handles, handle);
+ }
+ hold_and_return_handles (context, self, handles, handle_type);
+ g_array_free(handles, TRUE);
+ break;
+
+ default:
+ gabble_debug (DEBUG_FLAG, "unimplemented handle type %u", handle_type);
+
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "unimplemented handle type %u", handle_type);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ }
+}
+
+
+/**
+ * gabble_connection_request_presence
+ *
+ * Implements D-Bus method RequestPresence
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_request_presence (GabbleConnection *self,
+ const GArray *contacts,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ if (!gabble_handles_are_valid (self->handles, TP_HANDLE_TYPE_CONTACT,
+ contacts, FALSE, error))
+ return FALSE;
+
+ if (contacts->len)
+ emit_presence_update (self, contacts);
+
+ return TRUE;
+}
+
+
+struct _i_hate_g_hash_table_foreach
+{
+ GabbleConnection *conn;
+ GError **error;
+ gboolean retval;
+};
+
+static void
+setaliases_foreach (gpointer key, gpointer value, gpointer user_data)
+{
+ struct _i_hate_g_hash_table_foreach *data =
+ (struct _i_hate_g_hash_table_foreach *) user_data;
+ GabbleHandle handle = GPOINTER_TO_INT (key);
+ gchar *alias = (gchar *) value;
+ GError *error = NULL;
+
+ if (!gabble_handle_is_valid (data->conn->handles, TP_HANDLE_TYPE_CONTACT,
+ handle, &error))
+ {
+ data->retval = FALSE;
+ }
+ else if (data->conn->self_handle == handle)
+ {
+ /* only alter the roster if we're already there, e.g. because someone
+ * added us with another client
+ */
+ if (gabble_roster_handle_has_entry (data->conn->roster, handle)
+ && !gabble_roster_handle_set_name (data->conn->roster, handle,
+ alias, data->error))
+ {
+ data->retval = FALSE;
+ }
+ }
+ else if (!gabble_roster_handle_set_name (data->conn->roster, handle, alias,
+ data->error))
+ {
+ data->retval = FALSE;
+ }
+
+ if (data->conn->self_handle == handle)
+ {
+ /* User has done SetAliases on themselves - patch their vCard.
+ * FIXME: because SetAliases is currently synchronous, we ignore errors
+ * here, and just let the request happen in the background
+ */
+ gabble_vcard_manager_edit (data->conn->vcard_manager,
+ 0, NULL, NULL, G_OBJECT(data->conn), NULL,
+ "NICKNAME", alias, NULL);
+ }
+
+ if (NULL != error)
+ {
+ if (NULL == *(data->error))
+ {
+ *(data->error) = error;
+ }
+ else
+ {
+ g_error_free (error);
+ }
+ }
+}
+
+/**
+ * gabble_connection_set_aliases
+ *
+ * Implements D-Bus method SetAliases
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Aliasing
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_set_aliases (GabbleConnection *self,
+ GHashTable *aliases,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ struct _i_hate_g_hash_table_foreach data = { NULL, NULL, TRUE };
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ data.conn = self;
+ data.error = error;
+
+ g_hash_table_foreach (aliases, setaliases_foreach, &data);
+
+ return data.retval;
+}
+
+
+/**
+ * gabble_connection_set_last_activity_time
+ *
+ * Implements D-Bus method SetLastActivityTime
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_set_last_activity_time (GabbleConnection *self,
+ guint time,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ return TRUE;
+}
+
+
+static void
+setstatuses_foreach (gpointer key, gpointer value, gpointer user_data)
+{
+ struct _i_hate_g_hash_table_foreach *data =
+ (struct _i_hate_g_hash_table_foreach*) user_data;
+ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (data->conn);
+
+ int i;
+
+ for (i = 0; i < LAST_GABBLE_PRESENCE; i++)
+ {
+ if (0 == strcmp (gabble_statuses[i].name, (const gchar*) key))
+ break;
+ }
+
+ if (i < LAST_GABBLE_PRESENCE)
+ {
+ GHashTable *args = (GHashTable *)value;
+ GValue *message = g_hash_table_lookup (args, "message");
+ GValue *priority = g_hash_table_lookup (args, "priority");
+ const gchar *status = NULL;
+ gint8 prio = priv->priority;
+
+ if (!status_is_available (data->conn, i))
+ {
+ gabble_debug (DEBUG_FLAG, "requested status %s is not available", (const gchar *) key);
+ g_set_error (data->error, TELEPATHY_ERRORS, NotAvailable,
+ "requested status '%s' is not available on this connection",
+ (const gchar *) key);
+ data->retval = FALSE;
+ return;
+ }
+
+ if (message)
+ {
+ if (!G_VALUE_HOLDS_STRING (message))
+ {
+ gabble_debug (DEBUG_FLAG, "got a status message which was not a string");
+ g_set_error (data->error, TELEPATHY_ERRORS, InvalidArgument,
+ "Status argument 'message' requires a string");
+ data->retval = FALSE;
+ return;
+ }
+ status = g_value_get_string (message);
+ }
+
+ if (priority)
+ {
+ if (!G_VALUE_HOLDS_INT (priority))
+ {
+ gabble_debug (DEBUG_FLAG, "got a priority value which was not a signed integer");
+ g_set_error (data->error, TELEPATHY_ERRORS, InvalidArgument,
+ "Status argument 'priority' requires a signed integer");
+ data->retval = FALSE;
+ return;
+ }
+ prio = CLAMP (g_value_get_int (priority), G_MININT8, G_MAXINT8);
+ }
+
+ gabble_presence_cache_update (data->conn->presence_cache, data->conn->self_handle, priv->resource, i, status, prio);
+ emit_one_presence_update (data->conn, data->conn->self_handle);
+ data->retval = signal_own_presence (data->conn, data->error);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "got unknown status identifier %s", (const gchar *) key);
+ g_set_error (data->error, TELEPATHY_ERRORS, InvalidArgument,
+ "unknown status identifier: %s", (const gchar *) key);
+ data->retval = FALSE;
+ }
+}
+
+/**
+ * gabble_connection_set_properties
+ *
+ * Implements D-Bus method SetProperties
+ * on interface org.freedesktop.Telepathy.Properties
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_connection_set_properties (GabbleConnection *self,
+ const GPtrArray *properties,
+ DBusGMethodInvocation *context)
+{
+ gabble_properties_mixin_set_properties (G_OBJECT (self), properties, context);
+}
+
+/**
+ * gabble_connection_set_status
+ *
+ * Implements D-Bus method SetStatus
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Presence
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_set_status (GabbleConnection *self,
+ GHashTable *statuses,
+ GError **error)
+{
+ GabbleConnectionPrivate *priv;
+ struct _i_hate_g_hash_table_foreach data = { NULL, NULL, TRUE };
+
+ g_assert (GABBLE_IS_CONNECTION (self));
+
+ priv = GABBLE_CONNECTION_GET_PRIVATE (self);
+
+ ERROR_IF_NOT_CONNECTED (self, error)
+
+ if (g_hash_table_size (statuses) != 1)
+ {
+ gabble_debug (DEBUG_FLAG, "got more than one status");
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "Only one status may be set at a time in this protocol");
+ return FALSE;
+ }
+
+ data.conn = self;
+ data.error = error;
+ g_hash_table_foreach (statuses, setstatuses_foreach, &data);
+
+ return data.retval;
+}
+
+/**
+ * gabble_connection_build_avatar
+ *
+ * Implements D-Bus method SetAvatar
+ * on interface org.freedesktop.Telepathy.Connection.Avatar
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+
+LmMessage* gabble_connection_build_avatar(GabbleConnection *self,
+ const GArray* bin_image, gchar* mime )
+ {
+ int i = 0;
+ LmMessage *message;
+ LmMessageNode *lm_node,*photo_node;
+ LmMessageHandler* handler = NULL;
+ char* base64 = NULL;
+ GError* error = NULL;
+ //NULL values to be checked ? never returns NULL?
+ if ( bin_image )
+ {
+ if ( self->self_avatar_sha1 )
+ {
+ free( self->self_avatar_sha1 );
+ self->self_avatar_sha1 = NULL;
+ }
+ self->self_avatar_sha1 = sha1_hex( bin_image->data, bin_image->len );
+ base64 = base64_encode ( bin_image->len, bin_image->data );
+ }
+
+ message = lm_message_new_with_sub_type ( NULL,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET );
+ lm_node = lm_message_node_add_child (message->node, "vCard", NULL);
+ lm_message_node_set_attribute (lm_node, "xmlns", NS_VCARD_TEMP);
+ photo_node = lm_message_node_add_child (lm_node, "PHOTO", NULL);
+ lm_message_node_add_child (photo_node, "TYPE", mime);
+ lm_message_node_add_child (photo_node, "BINVAL", base64);
+ g_free(base64);
+ return message;
+ }
+
+/**
+ * gabble_connection_set_avatar
+ *
+ * Implements D-Bus method SetAvatar
+ * on interface org.freedesktop.Telepathy.Connection
+ *
+ */
+gboolean
+gabble_connection_set_avatar( GabbleConnection *self, const GArray* bin_image, gchar* mime_type, gchar**avatar_sha1,
+ GError** err )
+ {
+
+ gboolean ret = FALSE;
+ LmMessage *message;
+
+
+ //There is no need to check bin_image and mime for NULL.. NULL is a valid value for those
+ message = gabble_connection_build_avatar( self, bin_image, mime_type );
+
+ ret = _gabble_connection_send ( self, message, err );
+
+ if ( *err )
+ {
+ *avatar_sha1 = NULL;
+ //ret is already false.. so false returned
+ }
+ else {
+ if ( self->self_avatar_sha1 )
+ {
+ *avatar_sha1 = g_strdup( self->self_avatar_sha1 );
+ }
+ ret = TRUE;
+ }
+
+ lm_message_unref( message );
+
+ return ret;
+ }
+
+/**
+ * gabble_connection_clear_avatar
+ *
+ * Implements D-Bus method ClearAvatar
+ * on interface org.freedesktop.Telepathy.Connection.Interface.Avatar
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_connection_clear_avatar( GabbleConnection *self,
+ GError **error)
+ {
+ LmMessage *message;
+ gboolean ret = TRUE;
+
+
+ //Build the avatar xml with NULL as image data and NULL as mimetype
+ message = gabble_connection_build_avatar( self,
+ NULL, NULL );
+
+ ret = _gabble_connection_send ( self, message, error );
+
+ if ( self->self_avatar_sha1 )
+ {
+ free( self->self_avatar_sha1 );
+ self->self_avatar_sha1 = NULL;
+ }
+
+ lm_message_unref( message );
+
+ return ret;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-error.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,437 @@
+/*
+ * gabble-error.c - Source for Gabble's error handling API
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "gabble-error.h"
+#include "namespaces.h"
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(quark,gabble_error,GQuark)
+ #define quark (*GET_WSD_VAR_NAME(quark,gabble_error,s)())
+
+#endif
+
+#define MAX_LEGACY_ERRORS 3
+
+typedef struct {
+ const gchar *name;
+ const gchar *description;
+ const gchar *type;
+ guint specialises;
+ const gchar *namespace;
+ const guint16 legacy_errors[MAX_LEGACY_ERRORS];
+} XmppErrorSpec;
+
+static const XmppErrorSpec xmpp_errors[NUM_XMPP_ERRORS] =
+{
+ {
+ "redirect",
+ "the recipient or server is redirecting requests for this information "
+ "to another entity",
+ "modify",
+ 0,
+ NULL,
+ { 302, 0, },
+ },
+
+ {
+ "gone",
+ "the recipient or server can no longer be contacted at this address",
+ "modify",
+ 0,
+ NULL,
+ { 302, 0, },
+ },
+
+ {
+ "bad-request",
+ "the sender has sent XML that is malformed or that cannot be processed",
+ "modify",
+ 0,
+ NULL,
+ { 400, 0, },
+ },
+ {
+ "unexpected-request",
+ "the recipient or server understood the request but was not expecting "
+ "it at this time",
+ "wait",
+ 0,
+ NULL,
+ { 400, 0, },
+ },
+ {
+ "jid-malformed",
+ "the sending entity has provided or communicated an XMPP address or "
+ "aspect thereof (e.g., a resource identifier) that does not adhere "
+ "to the syntax defined in Addressing Scheme (Section 3)",
+ "modify",
+ 0,
+ NULL,
+ { 400, 0, },
+ },
+
+ {
+ "not-authorized",
+ "the sender must provide proper credentials before being allowed to "
+ "perform the action, or has provided improper credentials",
+ "auth",
+ 0,
+ NULL,
+ { 401, 0, },
+ },
+
+ {
+ "payment-required",
+ "the requesting entity is not authorized to access the requested "
+ "service because payment is required",
+ "auth",
+ 0,
+ NULL,
+ { 402, 0, },
+ },
+
+ {
+ "forbidden",
+ "the requesting entity does not possess the required permissions to "
+ "perform the action",
+ "auth",
+ 0,
+ NULL,
+ { 403, 0, },
+ },
+
+ {
+ "item-not-found",
+ "the addressed JID or item requested cannot be found",
+ "cancel",
+ 0,
+ NULL,
+ { 404, 0, },
+ },
+ {
+ "recipient-unavailable",
+ "the intended recipient is temporarily unavailable",
+ "wait",
+ 0,
+ NULL,
+ { 404, 0, },
+ },
+ {
+ "remote-server-not-found",
+ "a remote server or service specified as part or all of the JID of the "
+ "intended recipient (or required to fulfill a request) could not be "
+ "contacted within a reasonable amount of time",
+ "cancel",
+ 0,
+ NULL,
+ { 404, 0, },
+ },
+
+ {
+ "not-allowed",
+ "the recipient or server does not allow any entity to perform the action",
+ "cancel",
+ 0,
+ NULL,
+ { 405, 0, },
+ },
+
+ {
+ "not-acceptable",
+ "the recipient or server understands the request but is refusing to "
+ "process it because it does not meet criteria defined by the recipient "
+ "or server (e.g., a local policy regarding acceptable words in messages)",
+ "modify",
+ 0,
+ NULL,
+ { 406, 0, },
+ },
+
+ {
+ "registration-required",
+ "the requesting entity is not authorized to access the requested service "
+ "because registration is required",
+ "auth",
+ 0,
+ NULL,
+ { 407, 0, },
+ },
+ {
+ "subscription-required",
+ "the requesting entity is not authorized to access the requested service "
+ "because a subscription is required",
+ "auth",
+ 0,
+ NULL,
+ { 407, 0, },
+ },
+
+ {
+ "remote-server-timeout",
+ "a remote server or service specified as part or all of the JID of the "
+ "intended recipient (or required to fulfill a request) could not be "
+ "contacted within a reasonable amount of time",
+ "wait",
+ 0,
+ NULL,
+ { 408, 504, 0, },
+ },
+
+ {
+ "conflict",
+ "access cannot be granted because an existing resource or session exists "
+ "with the same name or address",
+ "cancel",
+ 0,
+ NULL,
+ { 409, 0, },
+ },
+
+ {
+ "internal-server-error",
+ "the server could not process the stanza because of a misconfiguration "
+ "or an otherwise-undefined internal server error",
+ "wait",
+ 0,
+ NULL,
+ { 500, 0, },
+ },
+ {
+ "undefined-condition",
+ "application-specific condition",
+ NULL,
+ 0,
+ NULL,
+ { 500, 0, },
+ },
+ {
+ "resource-constraint",
+ "the server or recipient lacks the system resources necessary to service "
+ "the request",
+ "wait",
+ 0,
+ NULL,
+ { 500, 0, },
+ },
+
+ {
+ "feature-not-implemented",
+ "the feature requested is not implemented by the recipient or server and "
+ "therefore cannot be processed",
+ "cancel",
+ 0,
+ NULL,
+ { 501, 0, },
+ },
+
+ {
+ "service-unavailable",
+ "the server or recipient does not currently provide the requested "
+ "service",
+ "cancel",
+ 0,
+ NULL,
+ { 502, 503, 510, },
+ },
+
+ {
+ "out-of-order",
+ "the request cannot occur at this point in the state machine",
+ "cancel",
+ XMPP_ERROR_UNEXPECTED_REQUEST,
+ NS_JINGLE_ERRORS,
+ { 0, },
+ },
+
+ {
+ "unknown-session",
+ "the 'sid' attribute specifies a session that is unknown to the "
+ "recipient",
+ "cancel",
+ XMPP_ERROR_BAD_REQUEST,
+ NS_JINGLE_ERRORS,
+ { 0, },
+ },
+
+ {
+ "unsupported-transports",
+ "the recipient does not support any of the desired content transport "
+ "methods",
+ "cancel",
+ XMPP_ERROR_FEATURE_NOT_IMPLEMENTED,
+ NS_JINGLE_ERRORS,
+ { 0, },
+ },
+
+ {
+ "unsupported-content",
+ "the recipient does not support any of the desired content description"
+ "formats",
+ "cancel",
+ XMPP_ERROR_FEATURE_NOT_IMPLEMENTED,
+ NS_JINGLE_ERRORS,
+ { 0, },
+ },
+};
+
+GQuark
+gabble_xmpp_error_quark (void)
+{
+
+#ifndef EMULATOR
+ static GQuark quark = 0;
+#endif
+
+ if (!quark)
+ quark = g_quark_from_static_string ("gabble-xmpp-error");
+ return quark;
+}
+
+GabbleXmppError
+gabble_xmpp_error_from_node (LmMessageNode *error_node)
+{
+ gint i, j;
+ const gchar *error_code_str;
+
+ /* First, try to look it up the modern way */
+ if (error_node->children)
+ {
+ for (i = 0; i < NUM_XMPP_ERRORS; i++)
+ {
+ if (lm_message_node_get_child (error_node, xmpp_errors[i].name))
+ {
+ return i;
+ }
+ }
+ }
+
+ /* Ok, do it the legacy way */
+ error_code_str = lm_message_node_get_attribute (error_node, "code");
+ if (error_code_str)
+ {
+ gint error_code;
+
+ error_code = atoi (error_code_str);
+
+ for (i = 0; i < NUM_XMPP_ERRORS; i++)
+ {
+ const XmppErrorSpec *spec = &xmpp_errors[i];
+
+ for (j = 0; j < MAX_LEGACY_ERRORS; j++)
+ {
+ gint cur_code = spec->legacy_errors[j];
+ if (cur_code == 0)
+ break;
+
+ if (cur_code == error_code)
+ return i;
+ }
+ }
+ }
+
+ return INVALID_XMPP_ERROR;
+}
+
+GError *
+gabble_xmpp_error_to_g_error (GabbleXmppError error)
+{
+ if (error >= NUM_XMPP_ERRORS)
+ return NULL;
+
+ return g_error_new (GABBLE_XMPP_ERROR,
+ error,
+ xmpp_errors[error].description);
+}
+
+/*
+ * See RFC 3920: 4.7 Stream Errors, 9.3 Stanza Errors.
+ */
+LmMessageNode *
+gabble_xmpp_error_to_node (GabbleXmppError error,
+ LmMessageNode *parent_node,
+ const gchar *errmsg)
+{
+ const XmppErrorSpec *spec, *extra;
+ LmMessageNode *error_node, *node;
+ gchar str[6];
+
+ if (error >= NUM_XMPP_ERRORS)
+ return NULL;
+
+ if (xmpp_errors[error].specialises)
+ {
+ extra = &xmpp_errors[error];
+ spec = &xmpp_errors[extra->specialises];
+ }
+ else
+ {
+ extra = NULL;
+ spec = &xmpp_errors[error];
+ }
+
+ error_node = lm_message_node_add_child (parent_node, "error", NULL);
+
+ sprintf (str, "%d", spec->legacy_errors[0]);
+ lm_message_node_set_attribute (error_node, "code", str);
+
+ if (spec->type)
+ {
+ lm_message_node_set_attribute (error_node, "type", spec->type);
+ }
+
+ node = lm_message_node_add_child (error_node, spec->name, NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_XMPP_STANZAS);
+
+ if (extra != NULL)
+ {
+ node = lm_message_node_add_child (error_node, extra->name, NULL);
+ lm_message_node_set_attribute (node, "xmlns", extra->namespace);
+ }
+
+ if (NULL != errmsg)
+ lm_message_node_add_child (error_node, "text", errmsg);
+
+ return error_node;
+}
+
+const gchar *
+gabble_xmpp_error_string (GabbleXmppError error)
+{
+ if (error < NUM_XMPP_ERRORS)
+ return xmpp_errors[error].name;
+ else
+ return NULL;
+}
+
+const gchar *
+gabble_xmpp_error_description (GabbleXmppError error)
+{
+ if (error < NUM_XMPP_ERRORS)
+ return xmpp_errors[error].description;
+ else
+ return NULL;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-im-channel-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,69 @@
+/*
+ * gabble-im-channel-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-im-channel.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,573 @@
+/*
+ * gabble-im-channel.c - Source for GabbleIMChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include "loudmouth/loudmouth.h"
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_IM
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "gabble-presence.h"
+#include "gabble-presence-cache.h"
+#include "handles.h"
+#include "roster.h"
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "telepathy-interfaces.h"
+#include "tp-channel-iface.h"
+
+#include "gabble-im-channel.h"
+#include "gabble-im-channel-glue.h"
+#include "gabble-im-channel-signals-marshal.h"
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleIMChannel, gabble_im_channel, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+
+#endif
+
+/* signal enum */
+enum
+{
+ CLOSED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_IM
+#endif
+
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_im,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_im, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_im_channel_parent_class,gabble_im,gpointer)
+ #define gabble_im_channel_parent_class (*GET_WSD_VAR_NAME(gabble_im_channel_parent_class,gabble_im,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_im,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_im,s)())
+
+
+static void gabble_im_channel_init (GabbleIMChannel *self);
+static void gabble_im_channel_class_init (GabbleIMChannelClass *klass);
+static void gabble_im_channel_class_intern_init (gpointer klass)
+{
+ gabble_im_channel_parent_class = g_type_class_peek_parent (klass);
+ gabble_im_channel_class_init ((GabbleIMChannelClass*) klass);
+ }
+ EXPORT_C GType gabble_im_channel_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ { static const GTypeInfo g_define_type_info =
+ { sizeof (GabbleIMChannelClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_im_channel_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleIMChannel), 0, (GInstanceInitFunc) gabble_im_channel_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleIMChannel"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) ((void *)0) }; g_type_add_interface_static (g_define_type_id, tp_channel_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id;
+ };
+
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_CHANNEL_TYPE,
+ PROP_HANDLE_TYPE,
+ PROP_HANDLE,
+ PROP_CONNECTION,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleIMChannelPrivate GabbleIMChannelPrivate;
+
+struct _GabbleIMChannelPrivate
+{
+ GabbleConnection *conn;
+ char *object_path;
+ GabbleHandle handle;
+
+ gchar *peer_jid;
+
+ gboolean closed;
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_IM_CHANNEL_GET_PRIVATE(obj) \
+ ((GabbleIMChannelPrivate *)obj->priv)
+
+static void
+gabble_im_channel_init (GabbleIMChannel *self)
+{
+ GabbleIMChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_IM_CHANNEL, GabbleIMChannelPrivate);
+
+ self->priv = priv;
+}
+
+static GObject *
+gabble_im_channel_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleIMChannelPrivate *priv;
+ DBusGConnection *bus;
+ gboolean valid, send_nick;
+
+ obj = G_OBJECT_CLASS (gabble_im_channel_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_IM_CHANNEL_GET_PRIVATE (GABBLE_IM_CHANNEL (obj));
+
+ valid = gabble_handle_ref (priv->conn->handles, TP_HANDLE_TYPE_CONTACT, priv->handle);
+ g_assert (valid);
+
+ priv->peer_jid = g_strdup (gabble_handle_inspect (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, priv->handle));
+
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ if (gabble_roster_handle_get_subscription (priv->conn->roster, priv->handle)
+ & GABBLE_ROSTER_SUBSCRIPTION_FROM)
+ send_nick = FALSE;
+ else
+ send_nick = TRUE;
+
+ gabble_text_mixin_init (obj, G_STRUCT_OFFSET (GabbleIMChannel, text),
+ priv->conn->handles, send_nick);
+
+ gabble_text_mixin_set_message_types (obj,
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE,
+ G_MAXUINT);
+
+ return obj;
+}
+
+static void
+gabble_im_channel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleIMChannel *chan = GABBLE_IM_CHANNEL (object);
+ GabbleIMChannelPrivate *priv = GABBLE_IM_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_CHANNEL_TYPE:
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_TEXT);
+ break;
+ case PROP_HANDLE_TYPE:
+ g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, priv->handle);
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_im_channel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleIMChannel *chan = GABBLE_IM_CHANNEL (object);
+ GabbleIMChannelPrivate *priv = GABBLE_IM_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_HANDLE:
+ priv->handle = g_value_get_uint (value);
+ break;
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_im_channel_dispose (GObject *object);
+static void gabble_im_channel_finalize (GObject *object);
+
+static void
+gabble_im_channel_class_init (GabbleIMChannelClass *gabble_im_channel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_im_channel_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_im_channel_class, sizeof (GabbleIMChannelPrivate));
+
+ object_class->constructor = gabble_im_channel_constructor;
+
+ object_class->get_property = gabble_im_channel_get_property;
+ object_class->set_property = gabble_im_channel_set_property;
+
+ object_class->dispose = gabble_im_channel_dispose;
+ object_class->finalize = gabble_im_channel_finalize;
+
+ g_object_class_override_property (object_class, PROP_OBJECT_PATH, "object-path");
+ g_object_class_override_property (object_class, PROP_CHANNEL_TYPE, "channel-type");
+ g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type");
+ g_object_class_override_property (object_class, PROP_HANDLE, "handle");
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "IM channel object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (gabble_im_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ gabble_text_mixin_class_init (object_class, G_STRUCT_OFFSET (GabbleIMChannelClass, text_class));
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_im_channel_class), &dbus_glib_gabble_im_channel_object_info);
+}
+
+void
+gabble_im_channel_dispose (GObject *object)
+{
+ GabbleIMChannel *self = GABBLE_IM_CHANNEL (object);
+ GabbleIMChannelPrivate *priv = GABBLE_IM_CHANNEL_GET_PRIVATE (self);
+ GabbleRosterSubscription subscription;
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ subscription = gabble_roster_handle_get_subscription (priv->conn->roster,
+ priv->handle);
+
+ if ((GABBLE_ROSTER_SUBSCRIPTION_TO & subscription) == 0)
+ {
+ GabblePresence *presence;
+
+ presence = gabble_presence_cache_get (priv->conn->presence_cache,
+ priv->handle);
+
+ if (NULL != presence)
+ {
+ presence->keep_unavailable = FALSE;
+ gabble_presence_cache_maybe_remove (priv->conn->presence_cache,
+ priv->handle);
+ }
+ }
+
+ if (!priv->closed)
+ g_signal_emit(self, signals[CLOSED], 0);
+
+ if (G_OBJECT_CLASS (gabble_im_channel_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_im_channel_parent_class)->dispose (object);
+}
+
+void
+gabble_im_channel_finalize (GObject *object)
+{
+ GabbleIMChannel *self = GABBLE_IM_CHANNEL (object);
+ GabbleIMChannelPrivate *priv = GABBLE_IM_CHANNEL_GET_PRIVATE (self);
+
+ /* free any data held directly by the object here */
+
+ gabble_handle_unref (priv->conn->handles, TP_HANDLE_TYPE_CONTACT, priv->handle);
+
+ g_free (priv->object_path);
+ g_free (priv->peer_jid);
+
+ gabble_text_mixin_finalize (object);
+
+ G_OBJECT_CLASS (gabble_im_channel_parent_class)->finalize (object);
+}
+
+/**
+ * _gabble_im_channel_receive
+ *
+ */
+gboolean _gabble_im_channel_receive (GabbleIMChannel *chan,
+ TpChannelTextMessageType type,
+ GabbleHandle sender,
+ const char *from,
+ time_t timestamp,
+ const char *text)
+{
+ GabbleIMChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_IM_CHANNEL (chan));
+ priv = GABBLE_IM_CHANNEL_GET_PRIVATE (chan);
+
+ /* update peer's full JID if it's changed */
+ if (0 != strcmp (from, priv->peer_jid))
+ {
+ g_free (priv->peer_jid);
+ priv->peer_jid = g_strdup (from);
+ }
+
+ if (timestamp == 0)
+ timestamp = time (NULL);
+
+ return gabble_text_mixin_receive (G_OBJECT (chan), type, sender, timestamp, text);
+}
+
+/**
+ * gabble_im_channel_acknowledge_pending_messages
+ *
+ * Implements D-Bus method AcknowledgePendingMessages
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_acknowledge_pending_messages (GabbleIMChannel *self,
+ const GArray *ids,
+ GError **error)
+{
+ g_assert (GABBLE_IS_IM_CHANNEL (self));
+
+ return gabble_text_mixin_acknowledge_pending_messages (G_OBJECT (self), ids,
+ error);
+}
+
+
+/**
+ * gabble_im_channel_close
+ *
+ * Implements D-Bus method Close
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_close (GabbleIMChannel *self,
+ GError **error)
+{
+ GabbleIMChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_IM_CHANNEL (self));
+
+ gabble_debug (DEBUG_FLAG, "called on %p", self);
+
+ priv = GABBLE_IM_CHANNEL_GET_PRIVATE (self);
+ priv->closed = TRUE;
+
+ g_signal_emit (self, signals[CLOSED], 0);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_im_channel_get_channel_type
+ *
+ * Implements D-Bus method GetChannelType
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_get_channel_type (GabbleIMChannel *self,
+ gchar **ret,
+ GError **error)
+{
+ *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_TEXT);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_im_channel_get_handle
+ *
+ * Implements D-Bus method GetHandle
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_get_handle (GabbleIMChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error)
+{
+ GabbleIMChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_IM_CHANNEL (self));
+
+ priv = GABBLE_IM_CHANNEL_GET_PRIVATE (self);
+
+ *ret = TP_HANDLE_TYPE_CONTACT;
+ *ret1 = priv->handle;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_im_channel_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_get_interfaces (GabbleIMChannel *self,
+ gchar ***ret,
+ GError **error)
+{
+ const char *interfaces[] = { NULL };
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_im_channel_get_message_types
+ *
+ * Implements D-Bus method GetMessageTypes
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_get_message_types (GabbleIMChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_text_mixin_get_message_types (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_im_channel_list_pending_messages
+ *
+ * Implements D-Bus method ListPendingMessages
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_list_pending_messages (GabbleIMChannel *self,
+ gboolean clear,
+ GPtrArray **ret,
+ GError **error)
+{
+ g_assert (GABBLE_IS_IM_CHANNEL (self));
+
+ return gabble_text_mixin_list_pending_messages (G_OBJECT (self), clear, ret,
+ error);
+}
+
+
+/**
+ * gabble_im_channel_send
+ *
+ * Implements D-Bus method Send
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_im_channel_send (GabbleIMChannel *self,
+ guint type,
+ const gchar *text,
+ GError **error)
+{
+ GabbleIMChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_IM_CHANNEL (self));
+ priv = GABBLE_IM_CHANNEL_GET_PRIVATE (self);
+
+ return gabble_text_mixin_send (G_OBJECT (self), type, 0, priv->peer_jid,
+ text, priv->conn, TRUE /* emit_signal */, error);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-channel-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,222 @@
+/*
+ * gabble-media-channel-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:UINT,UINT,STRING (gabble-media-channel-signals-marshal.list:1) */
+void
+gabble_media_channel_marshal_VOID__UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
+/* VOID:STRING,STRING (gabble-media-channel-signals-marshal.list:2) */
+void
+gabble_media_channel_marshal_VOID__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+}
+
+/* VOID:UINT,UINT (gabble-media-channel-signals-marshal.list:3) */
+void
+gabble_media_channel_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
+/* VOID:UINT,UINT,UINT (gabble-media-channel-signals-marshal.list:4) */
+void
+gabble_media_channel_marshal_VOID__UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-channel.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1622 @@
+/*
+ * gabble-media-channel.c - Source for GabbleMediaChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#include "ansi.h"
+#include "debug.h"
+#include "gabble-connection.h"
+#include "gabble-media-session.h"
+#include "gabble-presence.h"
+#include "gabble-presence-cache.h"
+
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "telepathy-interfaces.h"
+#include "tp-channel-iface.h"
+
+#include "gabble-media-channel.h"
+#include "gabble-media-channel-signals-marshal.h"
+#include "gabble-media-channel-glue.h"
+
+#include "gabble-media-session.h"
+#include "gabble-media-stream.h"
+
+#include "media-factory.h"
+
+#include "gabble_enums.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+
+#define TP_SESSION_HANDLER_SET_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ DBUS_TYPE_G_OBJECT_PATH, \
+ G_TYPE_STRING, \
+ G_TYPE_INVALID))
+
+#define TP_CHANNEL_STREAM_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_INVALID))
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleMediaChannel, gabble_media_channel,
+ G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+#endif
+
+/* signal enum */
+enum
+{
+ CLOSED,
+ NEW_SESSION_HANDLER,
+ STREAM_ADDED,
+ STREAM_DIRECTION_CHANGED,
+ STREAM_ERROR,
+ STREAM_REMOVED,
+ STREAM_STATE_CHANGED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_MED_CHANNEL
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_med_chnl,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_med_chnl, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_media_channel_parent_class,gabble_med_chnl,gpointer)
+ #define gabble_media_channel_parent_class (*GET_WSD_VAR_NAME(gabble_media_channel_parent_class,gabble_med_chnl,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_med_chnl,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_med_chnl,s)())
+
+static void gabble_media_channel_init (GabbleMediaChannel *self);
+static void gabble_media_channel_class_init (GabbleMediaChannelClass *klass);
+static void gabble_media_channel_class_intern_init (gpointer klass)
+ {
+ gabble_media_channel_parent_class = g_type_class_peek_parent (klass);
+ gabble_media_channel_class_init ((GabbleMediaChannelClass*) klass);
+ }
+ EXPORT_C GType gabble_media_channel_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ { static const GTypeInfo g_define_type_info = { sizeof (GabbleMediaChannelClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_media_channel_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleMediaChannel), 0, (GInstanceInitFunc) gabble_media_channel_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleMediaChannel"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) ((void *)0) }; g_type_add_interface_static (g_define_type_id, tp_channel_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id;
+ };
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_CHANNEL_TYPE,
+ PROP_HANDLE_TYPE,
+ PROP_HANDLE,
+ PROP_CONNECTION,
+ PROP_CREATOR,
+ PROP_FACTORY,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleMediaChannelPrivate GabbleMediaChannelPrivate;
+
+struct _GabbleMediaChannelPrivate
+{
+ GabbleConnection *conn;
+ gchar *object_path;
+ GabbleHandle creator;
+
+ GabbleMediaFactory *factory;
+ GabbleMediaSession *session;
+ GPtrArray *streams;
+
+ guint next_stream_id;
+
+ gboolean closed;
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_MEDIA_CHANNEL_GET_PRIVATE(obj) \
+ ((GabbleMediaChannelPrivate *)obj->priv)
+
+static void
+gabble_media_channel_init (GabbleMediaChannel *self)
+{
+ GabbleMediaChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_MEDIA_CHANNEL, GabbleMediaChannelPrivate);
+
+ self->priv = priv;
+
+ priv->next_stream_id = 1;
+}
+
+static GObject *
+gabble_media_channel_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleMediaChannelPrivate *priv;
+ DBusGConnection *bus;
+ GIntSet *set;
+
+ obj = G_OBJECT_CLASS (gabble_media_channel_parent_class)->
+ constructor (type, n_props, props);
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (GABBLE_MEDIA_CHANNEL (obj));
+
+ /* register object on the bus */
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ gabble_group_mixin_init (obj, G_STRUCT_OFFSET (GabbleMediaChannel, group),
+ priv->conn->handles, priv->conn->self_handle);
+
+ /* automatically add creator to channel */
+ set = g_intset_new ();
+ g_intset_add (set, priv->creator);
+
+ gabble_group_mixin_change_members (obj, "", set, NULL, NULL, NULL, 0, 0);
+
+ g_intset_destroy (set);
+
+ /* allow member adding */
+ gabble_group_mixin_change_flags (obj, TP_CHANNEL_GROUP_FLAG_CAN_ADD, 0);
+
+ return obj;
+}
+
+static void session_state_changed_cb (GabbleMediaSession *session, GParamSpec *arg1, GabbleMediaChannel *channel);
+static void session_stream_added_cb (GabbleMediaSession *session, GabbleMediaStream *stream, GabbleMediaChannel *chan);
+static void session_terminated_cb (GabbleMediaSession *session, guint terminator, guint reason, gpointer user_data);
+
+/**
+ * create_session
+ *
+ * Creates a GabbleMediaSession object for given peer.
+ *
+ * If sid is set to NULL a unique sid is generated and
+ * the "initiator" property of the newly created
+ * GabbleMediaSession is set to our own handle.
+ */
+static GabbleMediaSession*
+create_session (GabbleMediaChannel *channel,
+ GabbleHandle peer,
+ const gchar *peer_resource,
+ const gchar *sid)
+{
+ GabbleMediaChannelPrivate *priv;
+ GabbleMediaSession *session;
+ gchar *object_path;
+ JingleInitiator initiator;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (channel));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (channel);
+
+ g_assert (priv->session == NULL);
+
+ object_path = g_strdup_printf ("%s/MediaSession%u", priv->object_path, peer);
+
+ if (sid == NULL)
+ {
+ initiator = INITIATOR_LOCAL;
+ sid = _gabble_media_factory_allocate_sid (priv->factory, channel);
+ }
+ else
+ {
+ initiator = INITIATOR_REMOTE;
+ _gabble_media_factory_register_sid (priv->factory, sid, channel);
+ }
+
+ session = g_object_new (GABBLE_TYPE_MEDIA_SESSION,
+ "connection", priv->conn,
+ "media-channel", channel,
+ "object-path", object_path,
+ "session-id", sid,
+ "initiator", initiator,
+ "peer", peer,
+ "peer-resource", peer_resource,
+ NULL);
+
+ g_signal_connect (session, "notify::state",
+ (GCallback) session_state_changed_cb, channel);
+ g_signal_connect (session, "stream-added",
+ (GCallback) session_stream_added_cb, channel);
+ g_signal_connect (session, "terminated",
+ (GCallback) session_terminated_cb, channel);
+
+ priv->session = session;
+
+ priv->streams = g_ptr_array_sized_new (1);
+
+ g_signal_emit (channel, signals[NEW_SESSION_HANDLER], 0,
+ object_path, "rtp");
+
+ g_free (object_path);
+
+ return session;
+}
+
+gboolean
+_gabble_media_channel_dispatch_session_action (GabbleMediaChannel *chan,
+ GabbleHandle peer,
+ const gchar *peer_resource,
+ const gchar *sid,
+ LmMessage *message,
+ LmMessageNode *session_node,
+ const gchar *action,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+ GabbleMediaSession *session = priv->session;
+ gboolean session_is_new = FALSE;
+
+ if (session == NULL)
+ {
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (chan);
+ GIntSet *set;
+
+ session = create_session (chan, peer, peer_resource, sid);
+ session_is_new = TRUE;
+
+ /* make us local pending */
+ set = g_intset_new ();
+ g_intset_add (set, mixin->self_handle);
+
+ gabble_group_mixin_change_members (G_OBJECT (chan), "", NULL, NULL, set,
+ NULL, 0, 0);
+
+ g_intset_destroy (set);
+
+ /* and update flags accordingly */
+ gabble_group_mixin_change_flags (G_OBJECT (chan),
+ TP_CHANNEL_GROUP_FLAG_CAN_ADD |
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE,
+ 0);
+ }
+
+ g_object_ref (session);
+
+ if (_gabble_media_session_handle_action (session, message, session_node,
+ action, error))
+ {
+ g_object_unref (session);
+ return TRUE;
+ }
+ else
+ {
+ if (session_is_new)
+ _gabble_media_session_terminate (session, INITIATOR_LOCAL,
+ TP_CHANNEL_GROUP_CHANGE_REASON_ERROR);
+
+ g_object_unref (session);
+ return FALSE;
+ }
+}
+
+static void
+gabble_media_channel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaChannel *chan = GABBLE_MEDIA_CHANNEL (object);
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_CHANNEL_TYPE:
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
+ break;
+ case PROP_HANDLE_TYPE:
+ g_value_set_uint (value, TP_HANDLE_TYPE_NONE);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, 0);
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ case PROP_CREATOR:
+ g_value_set_uint (value, priv->creator);
+ break;
+ case PROP_FACTORY:
+ g_value_set_object (value, priv->factory);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_media_channel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaChannel *chan = GABBLE_MEDIA_CHANNEL (object);
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_HANDLE:
+ /* this property is writable in the interface, but not actually
+ * meaningfully changable on this channel, so we do nothing */
+ break;
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ case PROP_CREATOR:
+ priv->creator = g_value_get_uint (value);
+ break;
+ case PROP_FACTORY:
+ priv->factory = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_media_channel_dispose (GObject *object);
+static void gabble_media_channel_finalize (GObject *object);
+static gboolean gabble_media_channel_remove_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+
+static void
+gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_media_channel_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_media_channel_class, sizeof (GabbleMediaChannelPrivate));
+
+ object_class->constructor = gabble_media_channel_constructor;
+
+ object_class->get_property = gabble_media_channel_get_property;
+ object_class->set_property = gabble_media_channel_set_property;
+
+ object_class->dispose = gabble_media_channel_dispose;
+ object_class->finalize = gabble_media_channel_finalize;
+
+ gabble_group_mixin_class_init (object_class,
+ G_STRUCT_OFFSET (GabbleMediaChannelClass, group_class),
+ _gabble_media_channel_add_member,
+ gabble_media_channel_remove_member);
+
+ g_object_class_override_property (object_class, PROP_OBJECT_PATH, "object-path");
+ g_object_class_override_property (object_class, PROP_CHANNEL_TYPE, "channel-type");
+ g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type");
+ g_object_class_override_property (object_class, PROP_HANDLE, "handle");
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "media channel object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ param_spec = g_param_spec_uint ("creator", "Channel creator",
+ "The GabbleHandle representing the contact "
+ "who created the channel.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CREATOR, param_spec);
+
+ param_spec = g_param_spec_object ("factory", "GabbleMediaFactory object",
+ "The factory that created this object.",
+ GABBLE_TYPE_MEDIA_FACTORY,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_FACTORY, param_spec);
+
+ signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[NEW_SESSION_HANDLER] =
+ g_signal_new ("new-session-handler",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_channel_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING);
+
+ signals[STREAM_ADDED] =
+ g_signal_new ("stream-added",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_channel_marshal_VOID__UINT_UINT_UINT,
+ G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+
+ signals[STREAM_DIRECTION_CHANGED] =
+ g_signal_new ("stream-direction-changed",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_channel_marshal_VOID__UINT_UINT_UINT,
+ G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+
+ signals[STREAM_ERROR] =
+ g_signal_new ("stream-error",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_channel_marshal_VOID__UINT_UINT_STRING,
+ G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
+
+ signals[STREAM_REMOVED] =
+ g_signal_new ("stream-removed",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+
+ signals[STREAM_STATE_CHANGED] =
+ g_signal_new ("stream-state-changed",
+ G_OBJECT_CLASS_TYPE (gabble_media_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_channel_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_media_channel_class), &dbus_glib_gabble_media_channel_object_info);
+}
+
+void
+gabble_media_channel_dispose (GObject *object)
+{
+ GabbleMediaChannel *self = GABBLE_MEDIA_CHANNEL (object);
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ /** In this we set the state to ENDED, then the callback unrefs
+ * the session
+ */
+
+ if (!priv->closed)
+ gabble_media_channel_close (self, NULL);
+
+ g_assert (priv->closed);
+ g_assert (priv->session == NULL);
+ g_assert (priv->streams == NULL);
+
+ if (G_OBJECT_CLASS (gabble_media_channel_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_media_channel_parent_class)->dispose (object);
+}
+
+void
+gabble_media_channel_finalize (GObject *object)
+{
+ GabbleMediaChannel *self = GABBLE_MEDIA_CHANNEL (object);
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ g_free (priv->object_path);
+
+ gabble_group_mixin_finalize (object);
+
+ G_OBJECT_CLASS (gabble_media_channel_parent_class)->finalize (object);
+}
+
+
+
+/**
+ * gabble_media_channel_add_members
+ *
+ * Implements D-Bus method AddMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_add_members (GabbleMediaChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error)
+{
+ return gabble_group_mixin_add_members (G_OBJECT (self), contacts, message,
+ error);
+}
+
+
+/**
+ * gabble_media_channel_close
+ *
+ * Implements D-Bus method Close
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_close (GabbleMediaChannel *self,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+
+ gabble_debug (DEBUG_FLAG, "called on %p", self);
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (self));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->closed)
+ return TRUE;
+
+ priv->closed = TRUE;
+
+ if (priv->session)
+ {
+ _gabble_media_session_terminate (priv->session, INITIATOR_LOCAL, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+ }
+
+ g_signal_emit (self, signals[CLOSED], 0);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_channel_get_all_members
+ *
+ * Implements D-Bus method GetAllMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_all_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GArray **ret1,
+ GArray **ret2,
+ GError **error)
+{
+ return gabble_group_mixin_get_all_members (G_OBJECT (self), ret, ret1, ret2,
+ error);
+}
+
+
+/**
+ * gabble_media_channel_get_channel_type
+ *
+ * Implements D-Bus method GetChannelType
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_channel_type (GabbleMediaChannel *self,
+ gchar **ret,
+ GError **error)
+{
+ *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_channel_get_group_flags
+ *
+ * Implements D-Bus method GetGroupFlags
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_group_flags (GabbleMediaChannel *self,
+ guint *ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_group_flags (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_media_channel_get_handle
+ *
+ * Implements D-Bus method GetHandle
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_handle (GabbleMediaChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (self));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ *ret = 0;
+ *ret1 = 0;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_channel_get_handle_owners
+ *
+ * Implements D-Bus method GetHandleOwners
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_handle_owners (GabbleMediaChannel *self,
+ const GArray *handles,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_handle_owners (G_OBJECT (self), handles, ret,
+ error);
+}
+
+
+/**
+ * gabble_media_channel_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_interfaces (GabbleMediaChannel *self,
+ gchar ***ret,
+ GError **error)
+{
+ const gchar *interfaces[] = {
+ TP_IFACE_CHANNEL_INTERFACE_GROUP,
+ TP_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING,
+ NULL
+ };
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_channel_get_local_pending_members
+ *
+ * Implements D-Bus method GetLocalPendingMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_local_pending_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_local_pending_members (G_OBJECT (self), ret,
+ error);
+}
+
+
+/**
+ * gabble_media_channel_get_members
+ *
+ * Implements D-Bus method GetMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_members (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_media_channel_get_remote_pending_members
+ *
+ * Implements D-Bus method GetRemotePendingMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_remote_pending_members (GabbleMediaChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_remote_pending_members (G_OBJECT (self), ret,
+ error);
+}
+
+
+/**
+ * gabble_media_channel_get_self_handle
+ *
+ * Implements D-Bus method GetSelfHandle
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_self_handle (GabbleMediaChannel *self,
+ guint *ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_self_handle (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_media_channel_get_session_handlers
+ *
+ * Implements D-Bus method GetSessionHandlers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.MediaSignalling
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_get_session_handlers (GabbleMediaChannel *self,
+ GPtrArray **ret,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (self));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->session)
+ {
+ GValue handler = { 0, };
+ GabbleHandle member;
+ gchar *path;
+
+ g_value_init (&handler, TP_SESSION_HANDLER_SET_TYPE);
+ g_value_take_boxed (&handler,
+ dbus_g_type_specialized_construct (TP_SESSION_HANDLER_SET_TYPE));
+
+ g_object_get (priv->session,
+ "peer", &member,
+ "object-path", &path,
+ NULL);
+
+ dbus_g_type_struct_set (&handler,
+ 0, path,
+ 1, "rtp",
+ G_MAXUINT);
+
+ g_free (path);
+
+ *ret = g_ptr_array_sized_new (1);
+ g_ptr_array_add (*ret, g_value_get_boxed (&handler));
+ }
+ else
+ {
+ *ret = g_ptr_array_sized_new (0);
+ }
+
+ return TRUE;
+}
+
+
+static GPtrArray *
+make_stream_list (GabbleMediaChannel *self,
+ GPtrArray *streams)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+ GPtrArray *ret;
+ guint i;
+
+ ret = g_ptr_array_sized_new (streams->len);
+
+ for (i = 0; i < streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (streams, i);
+ GValue entry = { 0, };
+ guint id;
+ GabbleHandle peer;
+ TpCodecMediaType type;
+ TpMediaStreamState connection_state;
+ CombinedStreamDirection combined_direction;
+
+ g_object_get (stream,
+ "id", &id,
+ "media-type", &type,
+ "connection-state", &connection_state,
+ "combined-direction", &combined_direction,
+ NULL);
+
+ g_object_get (priv->session, "peer", &peer, NULL);
+
+ g_value_init (&entry, TP_CHANNEL_STREAM_TYPE);
+ g_value_take_boxed (&entry,
+ dbus_g_type_specialized_construct (TP_CHANNEL_STREAM_TYPE));
+
+ dbus_g_type_struct_set (&entry,
+ 0, id,
+ 1, peer,
+ 2, type,
+ 3, connection_state,
+ 4, COMBINED_DIRECTION_GET_DIRECTION (combined_direction),
+ 5, COMBINED_DIRECTION_GET_PENDING_SEND (combined_direction),
+ G_MAXUINT);
+
+ g_ptr_array_add (ret, g_value_get_boxed (&entry));
+ }
+
+ return ret;
+}
+
+/**
+ * gabble_media_channel_list_streams
+ *
+ * Implements D-Bus method ListStreams
+ * on interface org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_list_streams (GabbleMediaChannel *self,
+ GPtrArray **ret,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (self));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ /* no session yet? return an empty array */
+ if (priv->session == NULL)
+ {
+ *ret = g_ptr_array_new ();
+
+ return TRUE;
+ }
+
+ *ret = make_stream_list (self, priv->streams);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_channel_remove_members
+ *
+ * Implements D-Bus method RemoveMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_remove_members (GabbleMediaChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error)
+{
+ return gabble_group_mixin_remove_members (G_OBJECT (self), contacts, message,
+ error);
+}
+
+
+static GabbleMediaStream *
+_find_stream_by_id (GabbleMediaChannel *chan, guint stream_id)
+{
+ GabbleMediaChannelPrivate *priv;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (chan));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+ guint id;
+
+ g_object_get (stream, "id", &id, NULL);
+ if (id == stream_id)
+ return stream;
+ }
+
+ return NULL;
+}
+
+/**
+ * gabble_media_channel_remove_streams
+ *
+ * Implements DBus method RemoveStreams
+ * on interface org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occured, DBus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean gabble_media_channel_remove_streams (GabbleMediaChannel *obj, const GArray * streams, GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+ GPtrArray *stream_objs;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (obj));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (obj);
+
+ *error = NULL;
+
+ stream_objs = g_ptr_array_sized_new (streams->len);
+
+ /* check that all stream ids are valid and at the same time build an array
+ * of stream objects so we don't have to look them up again after verifying
+ * all stream identifiers. */
+ for (i = 0; i < streams->len; i++)
+ {
+ guint id = g_array_index (streams, guint, i);
+ GabbleMediaStream *stream;
+ guint j;
+
+ stream = _find_stream_by_id (obj, id);
+ if (stream == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "given stream id %u does not exist", id);
+ goto OUT;
+ }
+
+ /* make sure we don't allow the client to repeatedly remove the same stream */
+ for (j = 0; j < stream_objs->len; j++)
+ {
+ GabbleMediaStream *tmp = g_ptr_array_index (stream_objs, j);
+
+ if (tmp == stream)
+ {
+ stream = NULL;
+ break;
+ }
+ }
+
+ if (stream != NULL)
+ g_ptr_array_add (stream_objs, stream);
+ }
+
+ /* groovy, it's all good dude, let's remove them */
+ if (stream_objs->len > 0)
+ _gabble_media_session_remove_streams (priv->session, (GabbleMediaStream **)
+ stream_objs->pdata, stream_objs->len);
+
+OUT:
+ g_ptr_array_free (stream_objs, TRUE);
+
+ return (*error == NULL);
+}
+
+
+/**
+ * gabble_media_channel_request_stream_direction
+ *
+ * Implements D-Bus method RequestStreamDirection
+ * on interface org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_request_stream_direction (GabbleMediaChannel *self,
+ guint stream_id,
+ guint stream_direction,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+ GabbleMediaStream *stream;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (self));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ if (stream_direction > TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "given stream direction %u is not valid", stream_direction);
+ return FALSE;
+ }
+
+ stream = _find_stream_by_id (self, stream_id);
+ if (stream == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "given stream id %u does not exist", stream_id);
+ return FALSE;
+ }
+
+ /* streams with no session? I think not... */
+ g_assert (priv->session != NULL);
+
+ return _gabble_media_session_request_stream_direction (priv->session, stream,
+ stream_direction, error);
+}
+
+
+/**
+ * gabble_media_channel_request_streams
+ *
+ * Implements D-Bus method RequestStreams
+ * on interface org.freedesktop.Telepathy.Channel.Type.StreamedMedia
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_channel_request_streams (GabbleMediaChannel *self,
+ guint contact_handle,
+ const GArray *types,
+ GPtrArray **ret,
+ GError **error)
+{
+ GabbleMediaChannelPrivate *priv;
+ GPtrArray *streams;
+
+ g_assert (GABBLE_IS_MEDIA_CHANNEL (self));
+
+ priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (self);
+
+ if (!gabble_handle_is_valid (priv->conn->handles, TP_HANDLE_TYPE_CONTACT,
+ contact_handle, error))
+ return FALSE;
+
+ if (!handle_set_is_member (self->group.members, contact_handle) &&
+ !handle_set_is_member (self->group.remote_pending, contact_handle))
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "given handle %u is not a member of the channel", contact_handle);
+ return FALSE;
+ }
+
+ /* if the person is a channel member, we should have a session */
+ g_assert (priv->session != NULL);
+
+ if (!_gabble_media_session_request_streams (priv->session, types, &streams,
+ error))
+ return FALSE;
+
+ *ret = make_stream_list (self, streams);
+
+ g_ptr_array_free (streams, TRUE);
+
+ return TRUE;
+}
+
+
+gboolean
+_gabble_media_channel_add_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error)
+{
+ GabbleMediaChannel *chan = GABBLE_MEDIA_CHANNEL (obj);
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ /* did we create this channel? */
+ if (priv->creator == mixin->self_handle)
+ {
+ GabblePresence *presence;
+ GIntSet *set;
+
+ /* yes: check the peer's capabilities */
+
+ presence = gabble_presence_cache_get (priv->conn->presence_cache, handle);
+
+ if (presence == NULL ||
+ !(presence->caps & PRESENCE_CAP_GOOGLE_VOICE ||
+ presence->caps & PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO ||
+ presence->caps & PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO))
+ {
+ if (presence == NULL)
+ gabble_debug (DEBUG_FLAG, "failed to add contact %d (%s) to media channel: "
+ "no presence available", handle,
+ gabble_handle_inspect (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle));
+ else
+ gabble_debug (DEBUG_FLAG, "failed to add contact %d (%s) to media channel: "
+ "caps %x aren't sufficient", handle,
+ gabble_handle_inspect (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle),
+ presence->caps);
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "handle %u has no media capabilities", handle);
+ return FALSE;
+ }
+
+ /* yes: invite the peer */
+
+
+ /* create a new session */
+ create_session (chan, handle, NULL, NULL);
+
+ /* make the peer remote pending */
+ set = g_intset_new ();
+ g_intset_add (set, handle);
+
+ gabble_group_mixin_change_members (obj, "", NULL, NULL, NULL, set, 0, 0);
+
+ g_intset_destroy (set);
+
+ /* and update flags accordingly */
+ gabble_group_mixin_change_flags (obj,
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_CAN_RESCIND,
+ TP_CHANNEL_GROUP_FLAG_CAN_ADD);
+
+ return TRUE;
+ }
+ else
+ {
+ /* no: has a session been created, is the handle being added ours,
+ * and are we in local pending? */
+
+ if (priv->session &&
+ handle == mixin->self_handle &&
+ handle_set_is_member (mixin->local_pending, handle))
+ {
+ /* yes: accept the request */
+
+ GIntSet *set;
+
+ /* make us a member */
+ set = g_intset_new ();
+ g_intset_add (set, handle);
+
+ gabble_group_mixin_change_members (obj, "", set, NULL, NULL, NULL, 0, 0);
+
+ g_intset_destroy (set);
+
+ /* update flags */
+ gabble_group_mixin_change_flags (obj, 0, TP_CHANNEL_GROUP_FLAG_CAN_ADD);
+
+ /* signal acceptance */
+ _gabble_media_session_accept (priv->session);
+
+ return TRUE;
+ }
+ }
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "handle %u cannot be added in the current state", handle);
+ return FALSE;
+}
+
+static gboolean
+gabble_media_channel_remove_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error)
+{
+ GabbleMediaChannel *chan = GABBLE_MEDIA_CHANNEL (obj);
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ GIntSet *set;
+
+ if (priv->session == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "handle %u cannot be removed in the current state", handle);
+
+ return FALSE;
+ }
+
+ if (priv->creator != mixin->self_handle &&
+ handle != mixin->self_handle)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, PermissionDenied,
+ "handle %u cannot be removed because you are not the creator of the"
+ " channel", handle);
+
+ return FALSE;
+ }
+
+ _gabble_media_session_terminate (priv->session, INITIATOR_LOCAL, TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+ /* remove the member */
+ set = g_intset_new ();
+ g_intset_add (set, handle);
+
+ gabble_group_mixin_change_members (obj, "", NULL, set, NULL, NULL, 0, 0);
+
+ g_intset_destroy (set);
+
+ /* and update flags accordingly */
+ gabble_group_mixin_change_flags (obj, TP_CHANNEL_GROUP_FLAG_CAN_ADD,
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_CAN_RESCIND);
+
+ return TRUE;
+}
+
+static void
+session_terminated_cb (GabbleMediaSession *session,
+ guint terminator,
+ guint reason,
+ gpointer user_data)
+{
+ GabbleMediaChannel *channel = (GabbleMediaChannel *) user_data;
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (channel);
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (channel);
+ GError *error = NULL;
+ gchar *sid;
+ JingleSessionState state;
+ GabbleHandle peer;
+ GIntSet *set;
+
+ g_object_get (session,
+ "state", &state,
+ "peer", &peer,
+ NULL);
+
+ set = g_intset_new ();
+
+ /* remove us and the peer from the member list */
+ g_intset_add (set, mixin->self_handle);
+ g_intset_add (set, peer);
+
+ gabble_group_mixin_change_members (G_OBJECT (channel), "", NULL, set, NULL, NULL, terminator, reason);
+
+ /* update flags accordingly -- allow adding, deny removal */
+ gabble_group_mixin_change_flags (G_OBJECT (channel), TP_CHANNEL_GROUP_FLAG_CAN_ADD,
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE);
+
+ /* free the session ID */
+ g_object_get (priv->session, "session-id", &sid, NULL);
+ _gabble_media_factory_free_sid (priv->factory, sid);
+ g_free (sid);
+
+ /* unref streams */
+ if (priv->streams != NULL)
+ {
+ GPtrArray *tmp = priv->streams;
+
+ /* move priv->streams aside so that the stream_close_cb
+ * doesn't double unref */
+ priv->streams = NULL;
+ g_ptr_array_foreach (tmp, (GFunc) g_object_unref, NULL);
+ g_ptr_array_free (tmp, TRUE);
+ }
+
+ /* remove the session */
+ g_object_unref (priv->session);
+ priv->session = NULL;
+
+ /* close the channel */
+ if (!gabble_media_channel_close (channel, &error))
+ {
+ g_warning ("%s: failed to close media channel: %s", G_STRFUNC,
+ error->message);
+ }
+}
+
+
+static void
+session_state_changed_cb (GabbleMediaSession *session,
+ GParamSpec *arg1,
+ GabbleMediaChannel *channel)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (channel);
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (channel);
+ JingleSessionState state;
+ GabbleHandle peer;
+ GIntSet *set;
+
+ g_object_get (session,
+ "state", &state,
+ "peer", &peer,
+ NULL);
+
+ if (state != JS_STATE_ACTIVE)
+ return;
+
+ if (priv->creator != mixin->self_handle)
+ return;
+
+ set = g_intset_new ();
+
+ /* add the peer to the member list */
+ g_intset_add (set, peer);
+
+ gabble_group_mixin_change_members (G_OBJECT (channel), "", set, NULL, NULL, NULL, 0, 0);
+
+ /* update flags accordingly -- allow removal, deny adding and rescinding */
+ gabble_group_mixin_change_flags (G_OBJECT (channel),
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE,
+ TP_CHANNEL_GROUP_FLAG_CAN_ADD |
+ TP_CHANNEL_GROUP_FLAG_CAN_RESCIND);
+
+ g_intset_destroy (set);
+}
+
+static void
+stream_close_cb (GabbleMediaStream *stream,
+ GabbleMediaChannel *chan)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+ guint id;
+
+ g_object_get (stream, "id", &id, NULL);
+
+ g_signal_emit (chan, signals[STREAM_REMOVED], 0, id);
+
+ if (priv->streams != NULL)
+ {
+ g_ptr_array_remove (priv->streams, stream);
+ g_object_unref (stream);
+ }
+}
+
+static void
+stream_error_cb (GabbleMediaStream *stream,
+ TpMediaStreamError errno,
+ const gchar *message,
+ GabbleMediaChannel *chan)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+ guint id;
+
+ /* emit signal */
+ g_object_get (stream, "id", &id, NULL);
+ g_signal_emit (chan, signals[STREAM_ERROR], 0, id, errno, message);
+
+ /* remove stream from session */
+ _gabble_media_session_remove_streams (priv->session, &stream, 1);
+}
+
+static void
+stream_state_changed_cb (GabbleMediaStream *stream,
+ GParamSpec *pspec,
+ GabbleMediaChannel *chan)
+{
+ guint id;
+ TpMediaStreamState connection_state;
+
+ g_object_get (stream, "id", &id, "connection-state", &connection_state, NULL);
+
+ g_signal_emit (chan, signals[STREAM_STATE_CHANGED], 0, id, connection_state);
+}
+
+static void
+stream_direction_changed_cb (GabbleMediaStream *stream,
+ GParamSpec *pspec,
+ GabbleMediaChannel *chan)
+{
+ guint id;
+ CombinedStreamDirection combined;
+ TpMediaStreamDirection direction;
+ TpMediaStreamPendingSend pending_send;
+
+ g_object_get (stream,
+ "id", &id,
+ "combined-direction", &combined,
+ NULL);
+
+ direction = COMBINED_DIRECTION_GET_DIRECTION (combined);
+ pending_send = COMBINED_DIRECTION_GET_PENDING_SEND (combined);
+
+ g_signal_emit (chan, signals[STREAM_DIRECTION_CHANGED], 0, id, direction,
+ pending_send);
+}
+
+static void
+session_stream_added_cb (GabbleMediaSession *session,
+ GabbleMediaStream *stream,
+ GabbleMediaChannel *chan)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+
+ guint id, handle, type;
+
+ /* keep track of the stream */
+ g_object_ref (stream);
+ g_ptr_array_add (priv->streams, stream);
+
+ g_signal_connect (stream, "close",
+ (GCallback) stream_close_cb, chan);
+ g_signal_connect (stream, "error",
+ (GCallback) stream_error_cb, chan);
+ g_signal_connect (stream, "notify::connection-state",
+ (GCallback) stream_state_changed_cb, chan);
+ g_signal_connect (stream, "notify::combined-direction",
+ (GCallback) stream_direction_changed_cb, chan);
+
+ /* emit StreamAdded */
+ g_object_get (session, "peer", &handle, NULL);
+ g_object_get (stream, "id", &id, "media-type", &type, NULL);
+
+ g_signal_emit (chan, signals[STREAM_ADDED], 0, id, handle, type);
+}
+
+guint
+_gabble_media_channel_get_stream_id (GabbleMediaChannel *chan)
+{
+ GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
+
+ return priv->next_stream_id++;
+}
+
+#define AUDIO_CAPS \
+ ( PRESENCE_CAP_GOOGLE_VOICE | PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO )
+
+#define VIDEO_CAPS \
+ ( PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO )
+
+GabblePresenceCapabilities
+_gabble_media_channel_typeflags_to_caps (TpChannelMediaCapabilities flags)
+{
+ GabblePresenceCapabilities caps = 0;
+
+ if (flags & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO)
+ caps |= AUDIO_CAPS;
+
+ if (flags & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO)
+ caps |= VIDEO_CAPS;
+
+ return caps;
+}
+
+TpChannelMediaCapabilities
+_gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps)
+{
+ TpChannelMediaCapabilities typeflags = 0;
+
+ if (caps & AUDIO_CAPS)
+ typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
+
+ if (caps & VIDEO_CAPS)
+ typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
+
+ return typeflags;
+}
+
+//Added to avoid type casting error in winscw
+GabblePresenceCapabilities
+_gabble_media_channel_typeflags_to_caps_tmp (guint flags)
+{
+return _gabble_media_channel_typeflags_to_caps( (TpChannelMediaCapabilities) flags);
+}
+
+//Added to avoid type casting error in winscw
+guint
+_gabble_media_channel_caps_to_typeflags_tmp (GabblePresenceCapabilities caps)
+{
+return (guint) _gabble_media_channel_caps_to_typeflags(caps);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-session-enumtypes.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,104 @@
+/*
+ * gabble-media-session-enumtypes.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ */
+/* Generated data (by glib-mkenums) */
+//vinod: changed system path to local
+#include "gabble-media-session.h"
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(etype,gabble_media_session_enum_types,GType)
+ #define etype (*GET_WSD_VAR_NAME(etype,gabble_media_session_enum_types,s)())
+
+ GET_STATIC_VAR_FROM_TLS(etype1,gabble_media_session_enum_types,GType)
+ #define etype1 (*GET_WSD_VAR_NAME(etype1,gabble_media_session_enum_types,s)())
+
+ GET_STATIC_VAR_FROM_TLS(etype2,gabble_media_session_enum_types,GType)
+ #define etype2 (*GET_WSD_VAR_NAME(etype2,gabble_media_session_enum_types,s)())
+
+#endif
+
+
+/* enumerations from "gabble-media-session.h" */
+GType
+gabble_media_session_mode_get_type (void)
+{
+#ifndef EMULATOR
+ static GType etype = 0;
+#endif
+
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { MODE_GOOGLE, "MODE_GOOGLE", "MODE_GOOGLE" },
+ { MODE_JINGLE, "MODE_JINGLE", "MODE_JINGLE" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GabbleMediaSessionMode", values);
+ }
+ return etype;
+}
+GType
+jingle_session_state_get_type (void)
+{
+#ifndef EMULATOR
+ static GType etype1 = 0;
+#endif
+
+ if (etype1 == 0) {
+ static const GEnumValue values[] = {
+ { JS_STATE_INVALID, "JS_STATE_INVALID", "JS_STATE_INVALID" },
+ { JS_STATE_PENDING_CREATED, "JS_STATE_PENDING_CREATED", "JS_STATE_PENDING_CREATED" },
+ { JS_STATE_PENDING_INITIATE_SENT, "JS_STATE_PENDING_INITIATE_SENT", "JS_STATE_PENDING_INITIATE_SENT" },
+ { JS_STATE_PENDING_INITIATED, "JS_STATE_PENDING_INITIATED", "JS_STATE_PENDING_INITIATED" },
+ { JS_STATE_PENDING_ACCEPT_SENT, "JS_STATE_PENDING_ACCEPT_SENT", "JS_STATE_PENDING_ACCEPT_SENT" },
+ { JS_STATE_ACTIVE, "JS_STATE_ACTIVE", "JS_STATE_ACTIVE" },
+ { JS_STATE_ENDED, "JS_STATE_ENDED", "JS_STATE_ENDED" },
+ { 0, NULL, NULL }
+ };
+ etype1 = g_enum_register_static ("JingleSessionState", values);
+ }
+ return etype1;
+}
+GType
+debug_message_type_get_type (void)
+{
+#ifndef EMULATOR
+ static GType etype2 = 0;
+#endif
+
+ if (etype2 == 0) {
+ static const GEnumValue values[] = {
+ { DEBUG_MSG_INFO, "DEBUG_MSG_INFO", "DEBUG_MSG_INFO" },
+ { DEBUG_MSG_DUMP, "DEBUG_MSG_DUMP", "DEBUG_MSG_DUMP" },
+ { DEBUG_MSG_WARNING, "DEBUG_MSG_WARNING", "DEBUG_MSG_WARNING" },
+ { DEBUG_MSG_ERROR, "DEBUG_MSG_ERROR", "DEBUG_MSG_ERROR" },
+ { DEBUG_MSG_EVENT, "DEBUG_MSG_EVENT", "DEBUG_MSG_EVENT" },
+ { 0, NULL, NULL }
+ };
+ etype2 = g_enum_register_static ("DebugMessageType", values);
+ }
+ return etype2;
+}
+
+/* Generated data ends here */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-session-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,148 @@
+/*
+ * gabble-media-session-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:STRING,UINT,UINT,UINT (gabble-media-session-signals-marshal.list:1) */
+void
+gabble_media_session_marshal_VOID__STRING_UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_UINT_UINT_UINT) (gpointer data1,
+ gpointer arg_1,
+ guint arg_2,
+ guint arg_3,
+ guint arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_UINT_UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_UINT_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_uint (param_values + 4),
+ data2);
+}
+
+/* VOID:UINT,UINT (gabble-media-session-signals-marshal.list:2) */
+void
+gabble_media_session_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-session.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3026 @@
+/*
+ * gabble-media-session.c - Source for GabbleMediaSession
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "debug.h"
+#include "ansi.h"
+#include "handles.h"
+#include "namespaces.h"
+#include "util.h"
+
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+
+#include "gabble-connection.h"
+#include "gabble-media-channel.h"
+#include "gabble-media-stream.h"
+#include "gabble-presence-cache.h"
+#include "gabble-presence.h"
+
+#include "gabble-media-session.h"
+#include "gabble-media-session-signals-marshal.h"
+#include "gabble-media-session-glue.h"
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleMediaSession, gabble_media_session, G_TYPE_OBJECT)
+#endif
+
+
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+//vinod
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+//#define NODE_DEBUG(n, s);
+#endif /* DEBUG_FLAG */
+
+#define DEFAULT_SESSION_TIMEOUT 50000
+
+#define GTALK_STREAM_NAME "gtalk"
+
+/* 99 streams gives us a max name length of 8 (videoXX\0 or audioXX\0) */
+#define MAX_STREAMS 99
+
+#ifndef EMULATOR
+#define MAX_STREAM_NAME_LEN 8
+#endif
+
+//#define DEBUGGING 0
+
+/* signal enum */
+enum
+{
+ NEW_STREAM_HANDLER,
+ STREAM_ADDED,
+ TERMINATED,
+ LAST_SIGNAL
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_med_sess,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_med_sess, s)())
+
+
+ GET_STATIC_VAR_FROM_TLS(google_audio_caps,gabble_med_sess,GabblePresenceCapabilities)
+ #define google_audio_caps (*GET_WSD_VAR_NAME(google_audio_caps,gabble_med_sess, s)())
+
+ GET_STATIC_VAR_FROM_TLS(jingle_audio_caps,gabble_med_sess,GabblePresenceCapabilities)
+ #define jingle_audio_caps (*GET_WSD_VAR_NAME(jingle_audio_caps,gabble_med_sess, s)())
+
+ GET_STATIC_VAR_FROM_TLS(jingle_video_caps,gabble_med_sess,GabblePresenceCapabilities)
+ #define jingle_video_caps (*GET_WSD_VAR_NAME(jingle_video_caps,gabble_med_sess, s)())
+
+ GET_STATIC_ARRAY_FROM_TLS(ret_sess,gabble_med_sess,gchar)
+ #define ret_sess (GET_WSD_VAR_NAME(ret_sess,gabble_med_sess, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_media_session_parent_class,gabble_med_sess,gpointer)
+ #define gabble_media_session_parent_class (*GET_WSD_VAR_NAME(gabble_media_session_parent_class,gabble_med_sess,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_med_sess,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_med_sess,s)())
+
+
+ static void gabble_media_session_init (GabbleMediaSession *self);
+ static void gabble_media_session_class_init (GabbleMediaSessionClass *klass);
+ static void gabble_media_session_class_intern_init (gpointer klass)
+ {
+ gabble_media_session_parent_class = g_type_class_peek_parent (klass);
+ gabble_media_session_class_init ((GabbleMediaSessionClass*) klass); }
+
+ EXPORT_C GType gabble_media_session_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleMediaSessionClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_media_session_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleMediaSession), 0, (GInstanceInitFunc) gabble_media_session_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleMediaSession"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ }
+
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ PROP_MEDIA_CHANNEL,
+ PROP_OBJECT_PATH,
+ PROP_SESSION_ID,
+ PROP_INITIATOR,
+ PROP_PEER,
+ PROP_PEER_RESOURCE,
+ PROP_STATE,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleMediaSessionPrivate GabbleMediaSessionPrivate;
+
+struct _GabbleMediaSessionPrivate
+{
+ GabbleConnection *conn;
+ GabbleMediaChannel *channel;
+ GabbleMediaSessionMode mode;
+ gchar *object_path;
+
+ GPtrArray *streams;
+ GPtrArray *remove_requests;
+
+ gchar *id;
+ GabbleHandle peer;
+ gchar *peer_resource;
+
+ JingleSessionState state;
+ gboolean ready;
+ gboolean locally_accepted;
+ gboolean terminated;
+
+ guint timer_id;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_MEDIA_SESSION_GET_PRIVATE(obj) \
+ ((GabbleMediaSessionPrivate *)obj->priv)
+
+typedef struct {
+ gchar *name;
+ gchar *attributes;
+} SessionStateDescription;
+
+static const SessionStateDescription session_states[] =
+{
+ { "JS_STATE_PENDING_CREATED", ANSI_BOLD_ON ANSI_FG_BLACK ANSI_BG_WHITE },
+ { "JS_STATE_PENDING_INITIATE_SENT", ANSI_BOLD_ON ANSI_BG_CYAN },
+ { "JS_STATE_PENDING_INITIATED", ANSI_BOLD_ON ANSI_BG_MAGENTA },
+ { "JS_STATE_PENDING_ACCEPT_SENT", ANSI_BOLD_ON ANSI_BG_CYAN },
+ { "JS_STATE_ACTIVE", ANSI_BOLD_ON ANSI_BG_BLUE },
+ { "JS_STATE_ENDED", ANSI_BG_RED }
+};
+
+static void
+gabble_media_session_init (GabbleMediaSession *self)
+{
+ GabbleMediaSessionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSessionPrivate);
+
+ self->priv = priv;
+
+ priv->mode = MODE_JINGLE;
+ priv->state = JS_STATE_PENDING_CREATED;
+ priv->streams = g_ptr_array_new ();
+ priv->remove_requests = g_ptr_array_new ();
+}
+
+static void stream_connection_state_changed_cb (GabbleMediaStream *stream,
+ GParamSpec *param,
+ GabbleMediaSession *session);
+static void stream_got_local_codecs_changed_cb (GabbleMediaStream *stream,
+ GParamSpec *param,
+ GabbleMediaSession *session);
+
+static void
+_emit_new_stream (GabbleMediaSession *session,
+ GabbleMediaStream *stream)
+{
+ gchar *object_path;
+ guint id, media_type;
+
+ g_object_get (stream,
+ "object-path", &object_path,
+ "id", &id,
+ "media-type", &media_type,
+ NULL);
+
+ /* all of the streams are bidirectional from farsight's point of view, it's
+ * just in the signalling they change */
+ g_signal_emit (session, signals[NEW_STREAM_HANDLER], 0, object_path, id,
+ media_type, TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);
+
+ g_free (object_path);
+}
+
+
+static GabbleMediaStream *
+_lookup_stream_by_name_and_initiator (GabbleMediaSession *session,
+ const gchar *stream_name,
+ JingleInitiator stream_initiator)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (g_strdiff (stream->name, stream_name))
+ continue;
+
+ if (stream_initiator != INITIATOR_INVALID &&
+ stream_initiator != stream->initiator)
+ continue;
+
+ return stream;
+ }
+
+ return NULL;
+}
+
+
+static GabbleMediaStream *
+create_media_stream (GabbleMediaSession *session,
+ const gchar *name,
+ JingleInitiator initiator,
+ guint media_type)
+{
+ GabbleMediaSessionPrivate *priv;
+ gchar *object_path;
+ GabbleMediaStream *stream;
+ guint id;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+ g_assert (name != NULL);
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ /* assert that if we're in google mode:
+ * - we only try to make one stream
+ * - it's an audio stream
+ * - it's called GTALK_STREAM_NAME */
+ if (priv->mode == MODE_GOOGLE)
+ {
+ g_assert (priv->streams->len == 0);
+ g_assert (media_type == TP_MEDIA_STREAM_TYPE_AUDIO);
+ g_assert (!g_strdiff (name, GTALK_STREAM_NAME));
+ }
+
+ g_assert (priv->streams->len < MAX_STREAMS);
+ g_assert (_lookup_stream_by_name_and_initiator (session, name, initiator) ==
+ NULL);
+
+ id = _gabble_media_channel_get_stream_id (priv->channel);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "creating new %s %s stream called \"%s\" with id %u",
+ priv->mode == MODE_GOOGLE ? "google" : "jingle",
+ media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video",
+ name, id);
+
+ object_path = g_strdup_printf ("%s/MediaStream%u", priv->object_path, id);
+
+ stream = g_object_new (GABBLE_TYPE_MEDIA_STREAM,
+ "connection", priv->conn,
+ "media-session", session,
+ "object-path", object_path,
+ "mode", priv->mode,
+ "name", name,
+ "id", id,
+ "initiator", initiator,
+ "media-type", media_type,
+ NULL);
+
+ g_signal_connect (stream, "notify::connection-state",
+ (GCallback) stream_connection_state_changed_cb,
+ session);
+ g_signal_connect (stream, "notify::got-local-codecs",
+ (GCallback) stream_got_local_codecs_changed_cb,
+ session);
+
+ g_ptr_array_add (priv->streams, stream);
+
+ g_free (object_path);
+
+ if (priv->ready)
+ _emit_new_stream (session, stream);
+
+ g_signal_emit (session, signals[STREAM_ADDED], 0, stream);
+
+ return stream;
+}
+
+static void
+destroy_media_stream (GabbleMediaSession *session,
+ GabbleMediaStream *stream)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ _gabble_media_stream_close (stream);
+ g_ptr_array_remove_fast (priv->streams, stream);
+ g_object_unref (stream);
+}
+
+static GObject *
+gabble_media_session_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleMediaSessionPrivate *priv;
+ DBusGConnection *bus;
+
+ obj = G_OBJECT_CLASS (gabble_media_session_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (GABBLE_MEDIA_SESSION (obj));
+
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ return obj;
+}
+
+static void
+gabble_media_session_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (object);
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ case PROP_MEDIA_CHANNEL:
+ g_value_set_object (value, priv->channel);
+ break;
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_SESSION_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_INITIATOR:
+ g_value_set_uint (value, session->initiator);
+ break;
+ case PROP_PEER:
+ g_value_set_uint (value, priv->peer);
+ break;
+ case PROP_PEER_RESOURCE:
+ g_value_set_string (value, priv->peer_resource);
+ break;
+ case PROP_STATE:
+ g_value_set_uint (value, priv->state);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void session_state_changed (GabbleMediaSession *session,
+ JingleSessionState prev_state,
+ JingleSessionState new_state);
+
+static void
+gabble_media_session_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (object);
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ JingleSessionState prev_state;
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ case PROP_MEDIA_CHANNEL:
+ priv->channel = g_value_get_object (value);
+ break;
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_SESSION_ID:
+ g_free (priv->id);
+ priv->id = g_value_dup_string (value);
+ break;
+ case PROP_INITIATOR:
+ session->initiator = g_value_get_uint (value);
+ break;
+ case PROP_PEER:
+ priv->peer = g_value_get_uint (value);
+ break;
+ case PROP_PEER_RESOURCE:
+ g_free (priv->peer_resource);
+ priv->peer_resource = g_value_dup_string (value);
+ break;
+ case PROP_STATE:
+ prev_state = priv->state;
+ priv->state = g_value_get_uint (value);
+
+ if (priv->state == JS_STATE_ENDED)
+ g_assert (priv->terminated);
+
+ if (priv->state != prev_state)
+ session_state_changed (session, prev_state, priv->state);
+
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_media_session_dispose (GObject *object);
+static void gabble_media_session_finalize (GObject *object);
+
+static void
+gabble_media_session_class_init (GabbleMediaSessionClass *gabble_media_session_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_media_session_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_media_session_class, sizeof (GabbleMediaSessionPrivate));
+
+ object_class->constructor = gabble_media_session_constructor;
+
+ object_class->get_property = gabble_media_session_get_property;
+ object_class->set_property = gabble_media_session_set_property;
+
+ object_class->dispose = gabble_media_session_dispose;
+ object_class->finalize = gabble_media_session_finalize;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "media session's channel.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ param_spec = g_param_spec_object ("media-channel", "GabbleMediaChannel object",
+ "Gabble media channel object that owns this "
+ "media session object.",
+ GABBLE_TYPE_MEDIA_CHANNEL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_MEDIA_CHANNEL, param_spec);
+
+ param_spec = g_param_spec_string ("object-path", "D-Bus object path",
+ "The D-Bus object path used for this "
+ "object on the bus.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_OBJECT_PATH, param_spec);
+
+ param_spec = g_param_spec_string ("session-id", "Session ID",
+ "A unique session identifier used "
+ "throughout all communication.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_SESSION_ID, param_spec);
+
+ param_spec = g_param_spec_uint ("initiator", "Session initiator",
+ "An enum signifying which end initiated "
+ "the session.",
+ INITIATOR_LOCAL,
+ INITIATOR_REMOTE,
+ INITIATOR_LOCAL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_INITIATOR, param_spec);
+
+ param_spec = g_param_spec_uint ("peer", "Session peer",
+ "The GabbleHandle representing the contact "
+ "with whom this session communicates.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PEER, param_spec);
+
+ param_spec = g_param_spec_string ("peer-resource",
+ "Session peer's resource",
+ "The resource of the contact "
+ "with whom this session communicates, "
+ "if applicable",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PEER_RESOURCE,
+ param_spec);
+
+ param_spec = g_param_spec_uint ("state", "Session state",
+ "The current state that the session is in.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STATE, param_spec);
+
+ signals[NEW_STREAM_HANDLER] =
+ g_signal_new ("new-stream-handler",
+ G_OBJECT_CLASS_TYPE (gabble_media_session_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_session_marshal_VOID__STRING_UINT_UINT_UINT,
+ G_TYPE_NONE, 4, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+
+ signals[STREAM_ADDED] =
+ g_signal_new ("stream-added",
+ G_OBJECT_CLASS_TYPE (gabble_media_session_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+ signals[TERMINATED] =
+ g_signal_new ("terminated",
+ G_OBJECT_CLASS_TYPE (gabble_media_session_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_session_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_media_session_class), &dbus_glib_gabble_media_session_object_info);
+}
+
+static void
+gabble_media_session_dispose (GObject *object)
+{
+ GabbleMediaSession *self = GABBLE_MEDIA_SESSION (object);
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (self);
+ guint i;
+
+ gabble_debug (DEBUG_FLAG, "called");
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ _gabble_media_session_terminate (self, INITIATOR_LOCAL,
+ TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+ if (priv->timer_id != 0)
+ g_source_remove (priv->timer_id);
+
+ if (priv->streams != NULL)
+ {
+ for (i = 0; i < priv->streams->len; i++)
+ g_object_unref (g_ptr_array_index (priv->streams, i));
+ g_ptr_array_free (priv->streams, TRUE);
+ priv->streams = NULL;
+ }
+
+ for (i = 0; i < priv->remove_requests->len; i++)
+ g_ptr_array_free (g_ptr_array_index (priv->remove_requests, i), TRUE);
+ g_ptr_array_free (priv->remove_requests, TRUE);
+ priv->remove_requests = NULL;
+
+ if (G_OBJECT_CLASS (gabble_media_session_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_media_session_parent_class)->dispose (object);
+}
+
+static void
+gabble_media_session_finalize (GObject *object)
+{
+ GabbleMediaSession *self = GABBLE_MEDIA_SESSION (object);
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (self);
+
+ g_free (priv->id);
+ g_free (priv->object_path);
+ g_free (priv->peer_resource);
+ G_OBJECT_CLASS (gabble_media_session_parent_class)->finalize (object);
+}
+
+
+/**
+ * gabble_media_session_error
+ *
+ * Implements D-Bus method Error
+ * on interface org.freedesktop.Telepathy.Media.SessionHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_session_error (GabbleMediaSession *self,
+ guint errno,
+ const gchar *message,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv;
+ GPtrArray *tmp;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (self));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (self);
+
+ _gabble_media_session_debug (self, DEBUG_MSG_INFO, "Media.SessionHandler::Error called, error %u (%s) -- "
+ "emitting error on each stream", errno, message);
+
+ if (priv->state == JS_STATE_ENDED)
+ {
+ return TRUE;
+ }
+ else if (priv->state == JS_STATE_PENDING_CREATED)
+ {
+ /* shortcut to prevent sending remove actions if we haven't sent an
+ * initiate yet */
+ g_object_set (self, "state", JS_STATE_ENDED, NULL);
+ return TRUE;
+ }
+
+ g_assert (priv->streams != NULL);
+
+ tmp = priv->streams;
+ priv->streams = NULL;
+
+ for (i = 0; i < tmp->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+ //FIXME: Temporary fix to comment "errno" to resolve the mecevo integration build break, fix me when this method is being used.
+ gabble_media_stream_error (stream, /*errno*/0, message, NULL);
+ }
+
+ g_ptr_array_free (tmp, TRUE);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_session_ready
+ *
+ * Implements D-Bus method Ready
+ * on interface org.freedesktop.Telepathy.Media.SessionHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_session_ready (GabbleMediaSession *self,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (self));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (self);
+
+ priv->ready = TRUE;
+
+ for (i = 0; i < priv->streams->len; i++)
+ _emit_new_stream (self, g_ptr_array_index (priv->streams, i));
+
+ return TRUE;
+}
+
+
+static gboolean
+_handle_create (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ GabbleMediaSessionMode session_mode;
+ TpMediaStreamType stream_type;
+ gboolean override_existing = FALSE;
+
+ if ((priv->state == JS_STATE_PENDING_CREATED) &&
+ (session->initiator == INITIATOR_LOCAL))
+ {
+ gabble_debug (DEBUG_FLAG, "we're trying to call ourselves, rejecting with busy");
+ _gabble_media_session_terminate (session, INITIATOR_REMOTE,
+ TP_CHANNEL_GROUP_CHANGE_REASON_BUSY);
+ return FALSE;
+ }
+
+
+ if (stream != NULL)
+ {
+ /* streams added by the session initiator may replace similarly-named
+ * streams which we are trying to add (but havn't had acknowledged) */
+ if (stream->signalling_state < STREAM_SIG_STATE_ACKNOWLEDGED)
+ {
+ if (session->initiator == INITIATOR_REMOTE)
+ {
+ override_existing = TRUE;
+ }
+ else
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_CONFLICT,
+ "session initiator is creating a stream named \"%s\" already",
+ stream_name);
+ return FALSE;
+ }
+ }
+ else
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_CONFLICT,
+ "can't create new stream called \"%s\", it already exists, "
+ "rejecting", stream_name);
+ return FALSE;
+ }
+ }
+
+ if (desc_node == NULL)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "unable to create stream without a content description");
+ return FALSE;
+ }
+
+ if (lm_message_node_has_namespace (desc_node,
+ NS_GOOGLE_SESSION_PHONE, NULL))
+ {
+ session_mode = MODE_GOOGLE;
+ stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
+ }
+ else if (lm_message_node_has_namespace (desc_node,
+ NS_JINGLE_DESCRIPTION_AUDIO, NULL))
+ {
+ session_mode = MODE_JINGLE;
+ stream_type = TP_MEDIA_STREAM_TYPE_AUDIO;
+ }
+ else if (lm_message_node_has_namespace (desc_node,
+ NS_JINGLE_DESCRIPTION_VIDEO, NULL))
+ {
+ session_mode = MODE_JINGLE;
+ stream_type = TP_MEDIA_STREAM_TYPE_VIDEO;
+ }
+ else
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR,
+ XMPP_ERROR_JINGLE_UNSUPPORTED_CONTENT,
+ "refusing to create stream for unsupported content description");
+ return FALSE;
+ }
+
+ /* MODE_GOOGLE is allowed to have a null transport node */
+ if (session_mode == MODE_JINGLE && trans_node == NULL)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR,
+ XMPP_ERROR_JINGLE_UNSUPPORTED_TRANSPORT,
+ "refusing to create stream for unsupported transport");
+ return FALSE;
+ }
+
+ if (session_mode != priv->mode)
+ {
+ if (priv->streams->len > 0)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_UNEXPECTED_REQUEST,
+ "refusing to change mode because streams already exist");
+ return FALSE;
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "setting session mode to %s",
+ session_mode == MODE_GOOGLE ? "google" : "jingle");
+ priv->mode = session_mode;
+ }
+ }
+
+ if (override_existing)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "removing our unacknowledged stream \"%s\" "
+ "in favour of the session initiator's", stream_name);
+
+ /* disappear this stream */
+ destroy_media_stream (session, stream);
+
+ stream = NULL;
+ }
+
+ if (priv->streams->len == MAX_STREAMS)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_RESOURCE_CONSTRAINT,
+ "refusing to create more than " G_STRINGIFY (MAX_STREAMS)
+ " streams");
+ return FALSE;
+ }
+
+ stream = create_media_stream (session, stream_name, INITIATOR_REMOTE,
+ stream_type);
+
+ /* set the signalling state to ACKNOWLEDGED */
+ g_object_set (stream,
+ "signalling-state", STREAM_SIG_STATE_ACKNOWLEDGED,
+ NULL);
+
+ /* for jingle streams, set the direction to none, so that the
+ * direction handler adds the right flags */
+ if (priv->mode == MODE_JINGLE)
+ g_object_set (stream,
+ "combined-direction", TP_MEDIA_STREAM_DIRECTION_NONE,
+ NULL);
+
+ return TRUE;
+}
+
+
+static TpMediaStreamDirection
+_senders_to_direction (GabbleMediaSession *session,
+ const gchar *senders)
+{
+ TpMediaStreamDirection ret = TP_MEDIA_STREAM_DIRECTION_NONE;
+
+ if (!g_strdiff (senders, "initiator"))
+ {
+ if (session->initiator == INITIATOR_LOCAL)
+ ret = TP_MEDIA_STREAM_DIRECTION_SEND;
+ else
+ ret = TP_MEDIA_STREAM_DIRECTION_RECEIVE;
+ }
+ else if (!g_strdiff (senders, "responder"))
+ {
+ if (session->initiator == INITIATOR_REMOTE)
+ ret = TP_MEDIA_STREAM_DIRECTION_SEND;
+ else
+ ret = TP_MEDIA_STREAM_DIRECTION_RECEIVE;
+ }
+ else if (!g_strdiff (senders, "both"))
+ {
+ ret = TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL;
+ }
+
+ return ret;
+}
+
+static gboolean
+_handle_direction (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ const gchar *senders;
+ CombinedStreamDirection new_combined_dir;
+ TpMediaStreamDirection requested_dir, current_dir;
+ TpMediaStreamPendingSend pending_send;
+
+ if (priv->mode == MODE_GOOGLE)
+ return TRUE;
+
+ requested_dir = TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL;
+
+ senders = lm_message_node_get_attribute (content_node, "senders");
+ if (senders != NULL)
+ requested_dir = _senders_to_direction (session, senders);
+
+ if (requested_dir == TP_MEDIA_STREAM_DIRECTION_NONE)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "received invalid content senders value \"%s\" on stream \"%s\"; "
+ "rejecting", senders, stream_name);
+ return FALSE;
+ }
+
+ current_dir = COMBINED_DIRECTION_GET_DIRECTION (stream->combined_direction);
+ pending_send = COMBINED_DIRECTION_GET_PENDING_SEND
+ (stream->combined_direction);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "received request for senders \"%s\" on stream "
+ "\"%s\"", senders, stream_name);
+
+ /* if local sending has been added, remove it,
+ * and set the pending local send flag */
+ if (((current_dir & TP_MEDIA_STREAM_DIRECTION_SEND) == 0) &&
+ ((requested_dir & TP_MEDIA_STREAM_DIRECTION_SEND) != 0))
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "setting pending local send flag");
+ requested_dir &= ~TP_MEDIA_STREAM_DIRECTION_SEND;
+ pending_send |= TP_MEDIA_STREAM_PENDING_LOCAL_SEND;
+ }
+
+#if 0
+ /* clear any pending remote send */
+ if ((pending_send & TP_MEDIA_STREAM_PENDING_REMOTE_SEND) != 0)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "setting pending local send flag");
+ pending_send &= ~TP_MEDIA_STREAM_PENDING_REMOTE_SEND;
+ }
+#endif
+
+ /* make any necessary changes */
+ new_combined_dir = MAKE_COMBINED_DIRECTION (requested_dir, pending_send);
+ if (new_combined_dir != stream->combined_direction)
+ {
+ g_object_set (stream, "combined-direction", new_combined_dir, NULL);
+ _gabble_media_stream_update_sending (stream, FALSE);
+ }
+
+ return TRUE;
+}
+
+
+static gboolean
+_handle_accept (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ g_object_set (stream, "playing", TRUE, NULL);
+
+ _gabble_media_stream_update_sending (stream, TRUE);
+
+ return TRUE;
+}
+
+
+static gboolean
+_handle_codecs (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ if (desc_node == NULL)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "unable to handle codecs without a content description node");
+ return FALSE;
+ }
+
+ if (!_gabble_media_stream_post_remote_codecs (stream, message, desc_node,
+ error))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static gboolean
+_handle_candidates (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ if (trans_node == NULL)
+ {
+ if (priv->mode == MODE_GOOGLE)
+ {
+ trans_node = content_node;
+ }
+ else
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "unable to handle candidates without a transport node");
+ return FALSE;
+ }
+ }
+
+ if (!_gabble_media_stream_post_remote_candidates (stream, message,
+ trans_node, error))
+ return FALSE;
+
+ return TRUE;
+}
+
+static guint
+_count_non_removing_streams (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i, ret = 0;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (stream->signalling_state < STREAM_SIG_STATE_REMOVING)
+ ret++;
+ }
+
+ return ret;
+}
+
+static gboolean
+_handle_remove (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ /* reducing a session to contain 0 streams is invalid; instead the peer
+ * should terminate the session. I guess we'll do it for them... */
+ if (_count_non_removing_streams (session) == 1)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "unable to remove the last stream in a Jingle call");
+ return FALSE;
+ }
+
+ /* close the stream */
+ destroy_media_stream (session, stream);
+
+ return TRUE;
+}
+
+
+static gboolean
+_handle_terminate (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error)
+{
+ gabble_debug (DEBUG_FLAG, "called for %s", stream_name);
+
+ _gabble_media_session_terminate (session, INITIATOR_REMOTE,
+ TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+ return TRUE;
+}
+
+
+#ifndef EMULATOR
+
+typedef gboolean (*StreamHandlerFunc)(GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ GabbleMediaStream *stream,
+ LmMessageNode *desc_node,
+ LmMessageNode *trans_node,
+ GError **error);
+
+typedef struct _Handler Handler;
+
+struct _Handler {
+ const gchar *actions[3];
+ JingleSessionState min_allowed_state;
+ JingleSessionState max_allowed_state;
+ StreamHandlerFunc stream_handlers[4];
+ JingleSessionState new_state;
+};
+
+static Handler handlers[] = {
+ {
+ { "initiate", "session-initiate", NULL },
+ JS_STATE_PENDING_CREATED,
+ JS_STATE_PENDING_CREATED,
+ { _handle_create, _handle_direction, _handle_codecs, NULL },
+ JS_STATE_PENDING_INITIATED
+ },
+ {
+ { "accept", "session-accept", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_PENDING_INITIATED,
+ { _handle_direction, _handle_codecs, _handle_accept, NULL },
+ JS_STATE_ACTIVE
+ },
+ {
+ { "reject", NULL },
+ JS_STATE_PENDING_INITIATE_SENT,
+ JS_STATE_PENDING_INITIATED,
+ { _handle_terminate, NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "terminate", "session-terminate", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ENDED,
+ { _handle_terminate, NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "candidates", "transport-info", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { _handle_candidates, NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "content-add", NULL },
+ JS_STATE_ACTIVE,
+ JS_STATE_ACTIVE,
+ { _handle_create, _handle_direction, _handle_codecs, NULL },
+ JS_STATE_INVALID,
+ },
+ {
+ { "content-modify", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { _handle_direction, NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "content-accept", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { _handle_direction, _handle_codecs, _handle_accept, NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "content-remove", "content-decline", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { _handle_remove, NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { NULL },
+ JS_STATE_INVALID,
+ JS_STATE_INVALID,
+ { NULL },
+ JS_STATE_INVALID
+ }
+};
+#else
+
+Handler *_s_gabble_med_sess_handlers()
+ {
+ Handler* handler = libgabble_ImpurePtr()->_s_gabble_med_sess_handlers;
+ handler[0].stream_handlers[0] = _handle_create;
+ handler[0].stream_handlers[1] = _handle_direction;
+ handler[0].stream_handlers[2] = _handle_codecs;
+
+ handler[1].stream_handlers[0] = _handle_direction;
+ handler[1].stream_handlers[1] = _handle_codecs;
+ handler[1].stream_handlers[2] = _handle_accept;
+
+ handler[2].stream_handlers[0] = _handle_terminate;
+
+ handler[3].stream_handlers[0] = _handle_terminate;
+
+ handler[4].stream_handlers[0] = _handle_candidates;
+
+ handler[5].stream_handlers[0] = _handle_create;
+ handler[5].stream_handlers[0] = _handle_direction;
+ handler[5].stream_handlers[0] = _handle_codecs;
+
+ handler[6].stream_handlers[0] = _handle_direction;
+
+ handler[7].stream_handlers[0] = _handle_direction;
+ handler[7].stream_handlers[2] = _handle_codecs;
+ handler[7].stream_handlers[3] = _handle_accept;
+
+ handler[8].stream_handlers[0] = _handle_remove;
+
+
+ return handler;
+
+
+
+
+ }
+ #define handlers (GET_WSD_VAR_NAME(handlers,gabble_med_sess, s)())
+
+
+
+#endif
+
+
+static gboolean
+_call_handlers_on_stream (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *content_node,
+ const gchar *stream_name,
+ JingleInitiator stream_creator,
+ StreamHandlerFunc *func,
+ GError **error)
+{
+ GabbleMediaStream *stream = NULL;
+ LmMessageNode *desc_node = NULL, *trans_node = NULL;
+ StreamHandlerFunc *tmp;
+ gboolean stream_created = FALSE;
+
+ if (content_node != NULL)
+ {
+ desc_node = lm_message_node_get_child (content_node, "description");
+
+ trans_node = lm_message_node_get_child_with_namespace (content_node,
+ "transport", NS_GOOGLE_TRANSPORT_P2P);
+ }
+
+ for (tmp = func; *tmp != NULL; tmp++)
+ {
+ /* handlers may create the stream */
+ if (stream == NULL && stream_name != NULL)
+ stream = _lookup_stream_by_name_and_initiator (session, stream_name,
+ stream_creator);
+
+ /* the create handler is able to check whether or not the stream
+ * exists, and act accordingly (sometimes it will replace an existing
+ * stream, sometimes it will reject). the termination handler
+ * also requires no stream to do it's job. */
+ if (*tmp != _handle_create && *tmp != _handle_terminate)
+ {
+ /* all other handlers require the stream to exist */
+ if (stream == NULL)
+ {
+ const gchar *created = "";
+
+ if (stream_creator == INITIATOR_LOCAL)
+ created = "locally-created ";
+ else if (stream_creator == INITIATOR_REMOTE)
+ created = "remotely-created ";
+
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_ITEM_NOT_FOUND,
+ "unable to handle action for unknown %sstream \"%s\" ",
+ created, stream_name);
+
+ return FALSE;
+ }
+ else
+ {
+ /* don't do anything with actions on streams which have not been
+ * acknowledged, or that we're trying to remove, to deal with
+ * adding/removing race conditions (actions sent by the other end
+ * before they're aware that we've added or removed a stream) */
+ if (stream->signalling_state != STREAM_SIG_STATE_ACKNOWLEDGED)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_WARNING, "ignoring action because stream "
+ "%s is in state %d, not ACKNOWLEDGED", stream->name,
+ stream->signalling_state);
+ return TRUE;
+ }
+ }
+ }
+
+ if (!(*tmp) (session, message, content_node, stream_name, stream,
+ desc_node, trans_node, error))
+ {
+ /* if we successfully created the stream but failed to do something
+ * with it later, remove it */
+ if (stream_created)
+ destroy_media_stream (session, stream);
+
+ return FALSE;
+ }
+
+ if (*tmp == _handle_create)
+ {
+ stream_created = TRUE;
+ /* force a stream lookup after the create handler, even if we
+ * already had one (it has replacement semantics in certain
+ * situations) */
+ stream = NULL;
+ }
+ }
+
+ return TRUE;
+}
+
+
+static JingleInitiator
+_creator_to_initiator (GabbleMediaSession *session, const gchar *creator)
+{
+ if (!g_strdiff (creator, "initiator"))
+ {
+ if (session->initiator == INITIATOR_LOCAL)
+ return INITIATOR_LOCAL;
+ else
+ return INITIATOR_REMOTE;
+ }
+ else if (!g_strdiff (creator, "responder"))
+ {
+ if (session->initiator == INITIATOR_LOCAL)
+ return INITIATOR_REMOTE;
+ else
+ return INITIATOR_LOCAL;
+ }
+ else
+ return INITIATOR_INVALID;
+}
+
+
+static gboolean
+_call_handlers_on_streams (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *session_node,
+ StreamHandlerFunc *func,
+ GError **error)
+{
+ LmMessageNode *content_node;
+
+ if (lm_message_node_has_namespace (session_node, NS_GOOGLE_SESSION, NULL))
+ return _call_handlers_on_stream (session, message, session_node,
+ GTALK_STREAM_NAME, INITIATOR_INVALID, func, error);
+
+ if (session_node->children == NULL)
+ return _call_handlers_on_stream (session, message, NULL, NULL,
+ INITIATOR_INVALID, func, error);
+
+ for (content_node = session_node->children;
+ NULL != content_node;
+ content_node = content_node->next)
+ {
+ const gchar *stream_name, *stream_creator;
+ JingleInitiator stream_initiator;
+
+ if (g_strdiff (content_node->name, "content"))
+ continue;
+
+ stream_name = lm_message_node_get_attribute (content_node, "name");
+
+ if (stream_name == NULL)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "rejecting content node with no name");
+ return FALSE;
+ }
+
+ stream_creator = lm_message_node_get_attribute (content_node, "creator");
+ stream_initiator = _creator_to_initiator (session, stream_creator);
+
+ /* we allow NULL creator to mean INITIATOR_INVALID for backwards
+ * compatibility with clients that don't put a creator attribute in */
+ if (stream_creator != NULL && stream_initiator == INITIATOR_INVALID)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "rejecting content node with invalid creators value");
+ return FALSE;
+ }
+
+ if (!_call_handlers_on_stream (session, message, content_node,
+ stream_name, stream_initiator, func, error))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+gboolean
+_gabble_media_session_handle_action (GabbleMediaSession *session,
+ LmMessage *message,
+ LmMessageNode *session_node,
+ const gchar *action,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv;
+ StreamHandlerFunc *funcs = NULL;
+ JingleSessionState new_state = JS_STATE_INVALID;
+ Handler *i;
+
+#ifdef EMULATOR
+ gchar **tmp;
+#else
+ const gchar **tmp;
+#endif
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "got jingle session action \"%s\" from peer",
+ action);
+
+ /* do the state machine dance */
+
+ /* search the table of handlers for the action */
+ for (i = handlers; NULL != i->actions[0]; i++)
+ {
+ for (tmp = (char**)i->actions; NULL != *tmp; tmp++)
+ if (0 == strcmp (*tmp, action))
+ break;
+
+ if (NULL == *tmp)
+ continue;
+
+ /* if we're outside the allowable states for this action, return an error
+ * immediately */
+ if (priv->state < i->min_allowed_state ||
+ priv->state > i->max_allowed_state)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR,
+ XMPP_ERROR_JINGLE_OUT_OF_ORDER,
+ "action \"%s\" not allowed in current state", action);
+ goto ERROR;
+ }
+
+ funcs = i->stream_handlers;
+ new_state = i->new_state;
+
+ break;
+ }
+
+ /* pointer is not NULL if we found a matching action */
+ if (NULL == funcs)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR,
+ XMPP_ERROR_FEATURE_NOT_IMPLEMENTED, "action \"%s\" not implemented",
+ action);
+ goto ERROR;
+ }
+
+ /* call handlers if there are any (NULL-terminated array) */
+ if (NULL != *funcs)
+ {
+ if (!_call_handlers_on_streams (session, message, session_node, funcs,
+ error))
+ {
+ if (*error == NULL)
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "unknown error encountered with action \"%s\"",
+ action);
+
+ goto ERROR;
+ }
+ }
+
+ /* acknowledge the IQ before changing the state because the new state
+ * could perform some actions which the other end will only accept
+ * if this action has been acknowledged */
+ _gabble_connection_acknowledge_set_iq (priv->conn, message);
+
+ /* if the action specified a new state to go to, set it */
+ if (JS_STATE_INVALID != new_state)
+ g_object_set (session, "state", new_state, NULL);
+
+ return TRUE;
+
+ERROR:
+ g_assert (error != NULL);
+ _gabble_media_session_debug (session, DEBUG_MSG_ERROR, (*error)->message);
+ return FALSE;
+}
+
+static gboolean
+timeout_session (gpointer data)
+{
+ GabbleMediaSession *session = data;
+
+ gabble_debug (DEBUG_FLAG, "session timed out");
+
+ _gabble_media_session_terminate (session, INITIATOR_LOCAL,
+ TP_CHANNEL_GROUP_CHANGE_REASON_ERROR);
+
+ return FALSE;
+}
+
+static void do_content_add (GabbleMediaSession *, GabbleMediaStream *);
+
+void
+_add_ready_new_streams (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_DUMP, "pondering accept-time add for stream: %s, got "
+ "local codecs: %s, initiator: %s, signalling state: %d", stream->name,
+ stream->got_local_codecs ? "true" : "false",
+ stream->initiator == INITIATOR_LOCAL ? "local" : "remote",
+ stream->signalling_state);
+
+ if (stream->got_local_codecs == FALSE)
+ continue;
+
+ if (stream->initiator == INITIATOR_REMOTE)
+ continue;
+
+ if (stream->signalling_state > STREAM_SIG_STATE_NEW)
+ continue;
+
+ do_content_add (session, stream);
+ }
+}
+
+static void
+session_state_changed (GabbleMediaSession *session,
+ JingleSessionState prev_state,
+ JingleSessionState new_state)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_EVENT, "state changed from %s to %s",
+ session_states[prev_state].name,
+ session_states[new_state].name);
+
+ /*
+ * If the state goes from CREATED to INITIATED (which means the remote
+ * end initiated), set the timer. If, OTOH, we're the end which just sent an
+ * initiate, set the timer.
+ */
+ if ((prev_state == JS_STATE_PENDING_CREATED &&
+ new_state == JS_STATE_PENDING_INITIATED) ||
+ (new_state == JS_STATE_PENDING_INITIATE_SENT))
+ {
+ priv->timer_id =
+ g_timeout_add (DEFAULT_SESSION_TIMEOUT, timeout_session, session);
+ }
+ else if (new_state == JS_STATE_ACTIVE)
+ {
+ g_source_remove (priv->timer_id);
+ priv->timer_id = 0;
+
+ /* signal any streams to the remote end which were added locally & became
+ * ready before the session was accepted, so haven't been mentioned yet */
+ _add_ready_new_streams (session);
+ }
+}
+
+static void
+_mark_local_streams_sent (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (stream->initiator == INITIATOR_REMOTE)
+ continue;
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "marking local stream %s as signalled", stream->name);
+
+ g_object_set (stream, "signalling-state", STREAM_SIG_STATE_SENT, NULL);
+ }
+}
+
+static void
+_mark_local_streams_acked (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (stream->initiator == INITIATOR_REMOTE)
+ continue;
+
+ if (stream->signalling_state != STREAM_SIG_STATE_SENT)
+ continue;
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "marking local stream %s as acknowledged", stream->name);
+
+ g_object_set (stream,
+ "signalling-state", STREAM_SIG_STATE_ACKNOWLEDGED,
+ NULL);
+ }
+}
+
+static void
+_set_remote_streams_playing (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (stream->initiator == INITIATOR_LOCAL)
+ continue;
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "setting remote stream %s as playing", stream->name);
+
+ g_object_set (stream, "playing", TRUE, NULL);
+ }
+}
+
+static const gchar *_direction_to_senders (GabbleMediaSession *,
+ TpMediaStreamDirection);
+
+static void
+_add_content_descriptions_one (GabbleMediaSession *session,
+ GabbleMediaStream *stream,
+ LmMessageNode *session_node)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ LmMessageNode *content_node;
+
+ if (priv->mode == MODE_GOOGLE)
+ {
+ content_node = session_node;
+ }
+ else
+ {
+ TpMediaStreamDirection direction;
+ TpMediaStreamPendingSend pending_send;
+
+ content_node = _gabble_media_stream_add_content_node (stream,
+ session_node);
+
+ direction = COMBINED_DIRECTION_GET_DIRECTION (stream->combined_direction);
+ pending_send = COMBINED_DIRECTION_GET_PENDING_SEND
+ (stream->combined_direction);
+
+ /* if we have a pending local send flag set, the signalled (ie understood
+ * by both ends) direction of the stream is assuming that we are actually
+ * sending, so we should OR that into the direction before deciding what
+ * to signal the stream with. we don't need to consider pending remote
+ * send because it doesn't happen in Jingle */
+
+ if ((pending_send & TP_MEDIA_STREAM_PENDING_LOCAL_SEND) != 0)
+ direction |= TP_MEDIA_STREAM_DIRECTION_SEND;
+
+ if (direction != TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL)
+ {
+ const gchar *senders;
+ senders = _direction_to_senders (session, direction);
+ lm_message_node_set_attribute (content_node, "senders", senders);
+ }
+ }
+
+ _gabble_media_stream_content_node_add_description (stream, content_node);
+
+ _gabble_media_stream_content_node_add_transport (stream, content_node);
+}
+
+static void
+_add_content_descriptions (GabbleMediaSession *session,
+ LmMessageNode *session_node,
+ JingleInitiator stream_initiator)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (stream->initiator != stream_initiator)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "not adding content description for %s stream %s",
+ stream->initiator == INITIATOR_LOCAL ? "local" : "remote",
+ stream->name);
+ continue;
+ }
+
+ _add_content_descriptions_one (session, stream, session_node);
+ }
+}
+
+static LmHandlerResult
+accept_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (object);
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL (session, "accept failed");
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (stream->initiator == INITIATOR_LOCAL)
+ continue;
+
+ _gabble_media_stream_update_sending (stream, TRUE);
+ }
+
+ g_object_set (session, "state", JS_STATE_ACTIVE, NULL);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static gboolean
+_stream_not_ready_for_accept (GabbleMediaSession *session,
+ GabbleMediaStream *stream)
+{
+ /* locally initiated streams shouldn't delay acceptance */
+ if (stream->initiator == INITIATOR_LOCAL)
+ return FALSE;
+
+ if (!stream->got_local_codecs)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream %s does not yet have local codecs",
+ stream->name);
+
+ return TRUE;
+ }
+
+ if (stream->connection_state != TP_MEDIA_STREAM_STATE_CONNECTED)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream %s is not yet connected", stream->name);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+try_session_accept (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ LmMessage *msg;
+ LmMessageNode *session_node;
+ const gchar *action;
+ guint i;
+
+ if (priv->state < JS_STATE_ACTIVE && !priv->locally_accepted)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "not sending accept yet, waiting for local "
+ "user to accept call");
+ return;
+ }
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (_stream_not_ready_for_accept (session, stream))
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "not sending accept yet, found a stream "
+ "which was not yet connected or was missing local codecs");
+ return;
+ }
+ }
+
+ if (priv->mode == MODE_GOOGLE)
+ action = "accept";
+ else
+ action = "session-accept";
+
+ /* construct a session acceptance message */
+ msg = _gabble_media_session_message_new (session, action, &session_node);
+
+ /* only accept REMOTE streams; any LOCAL streams were added by the local
+ * user before accepting and should be signalled after the accept */
+ _add_content_descriptions (session, session_node, INITIATOR_REMOTE);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle session action \"%s\" to peer",
+ action);
+
+ /* send the final acceptance message */
+ _gabble_connection_send_with_reply (priv->conn, msg, accept_msg_reply_cb,
+ G_OBJECT (session), NULL, NULL);
+
+ lm_message_unref (msg);
+
+ /* set remote streams playing */
+ _set_remote_streams_playing (session);
+
+ g_object_set (session, "state", JS_STATE_PENDING_ACCEPT_SENT, NULL);
+}
+
+static LmHandlerResult
+content_accept_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (user_data);
+ GabbleMediaStream *stream = GABBLE_MEDIA_STREAM (object);
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_ERROR, "content-accept failed; removing stream");
+ NODE_DEBUG (sent_msg->node, "message sent");
+ NODE_DEBUG (reply_msg->node, "message reply");
+
+ _gabble_media_session_remove_streams (session, &stream, 1);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ _gabble_media_stream_update_sending (stream, TRUE);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+try_content_accept (GabbleMediaSession *session,
+ GabbleMediaStream *stream)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ LmMessage *msg;
+ LmMessageNode *session_node;
+
+ g_assert (priv->state == JS_STATE_ACTIVE);
+ g_assert (priv->mode == MODE_JINGLE);
+
+ if (_stream_not_ready_for_accept (session, stream))
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "not sending content-accept yet, stream %s "
+ "is disconnected or missing local codecs", stream->name);
+ return;
+ }
+
+ /* send a content acceptance message */
+ msg = _gabble_media_session_message_new (session, "content-accept",
+ &session_node);
+
+ _add_content_descriptions_one (session, stream, session_node);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle session action \"content-accept\" "
+ "to peer for stream %s", stream->name);
+
+ _gabble_connection_send_with_reply (priv->conn, msg,
+ content_accept_msg_reply_cb, G_OBJECT (stream), session, NULL);
+
+ lm_message_unref (msg);
+
+ /* set stream playing */
+ g_object_set (stream, "playing", TRUE, NULL);
+}
+
+static LmHandlerResult
+initiate_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (object);
+
+ MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL (session, "initiate failed");
+
+ g_object_set (session, "state", JS_STATE_PENDING_INITIATED, NULL);
+
+ /* mark all of the streams that we sent in the initiate as acknowledged */
+ _mark_local_streams_acked (session);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static gboolean
+_stream_not_ready_for_initiate (GabbleMediaSession *session,
+ GabbleMediaStream *stream)
+{
+ if (!stream->got_local_codecs)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream %s does not yet have local codecs",
+ stream->name);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+try_session_initiate (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ LmMessage *msg;
+ LmMessageNode *session_node;
+ const gchar *action;
+ guint i;
+
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+
+ if (_stream_not_ready_for_initiate (session, stream))
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "not sending initiate yet, found a stream "
+ "which was missing local codecs");
+ return;
+ }
+ }
+
+ if (priv->mode == MODE_GOOGLE)
+ action = "initiate";
+ else
+ action = "session-initiate";
+
+ msg = _gabble_media_session_message_new (session, action, &session_node);
+
+ _add_content_descriptions (session, session_node, INITIATOR_LOCAL);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle action \"%s\" to peer", action);
+
+ _gabble_connection_send_with_reply (priv->conn, msg, initiate_msg_reply_cb,
+ G_OBJECT (session), NULL, NULL);
+
+ lm_message_unref (msg);
+
+ /* mark local streams as sent (so that eg candidates will be sent) */
+ _mark_local_streams_sent (session);
+
+ g_object_set (session, "state", JS_STATE_PENDING_INITIATE_SENT, NULL);
+}
+
+static LmHandlerResult
+content_add_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (user_data);
+ GabbleMediaStream *stream = GABBLE_MEDIA_STREAM (object);
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ if (session->initiator == INITIATOR_REMOTE &&
+ stream->signalling_state == STREAM_SIG_STATE_ACKNOWLEDGED)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "ignoring content-add failure, stream has "
+ "been successfully created by the session initiator");
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_ERROR, "content-add failed; removing stream");
+ NODE_DEBUG (sent_msg->node, "message sent");
+ NODE_DEBUG (reply_msg->node, "message reply");
+
+ _gabble_media_stream_close (stream);
+ }
+ }
+ else
+ {
+ if (stream->signalling_state == STREAM_SIG_STATE_SENT)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "content-add succeeded, marking stream as "
+ "ACKNOWLEDGED");
+
+ g_object_set (stream,
+ "signalling-state", STREAM_SIG_STATE_ACKNOWLEDGED,
+ NULL);
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "content-add succeeded, but not marking"
+ "stream as ACKNOWLEDGED, it's in state %d",
+ stream->signalling_state);
+ }
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+do_content_add (GabbleMediaSession *session,
+ GabbleMediaStream *stream)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ LmMessage *msg;
+ LmMessageNode *session_node;
+
+ g_assert (priv->state == JS_STATE_ACTIVE);
+ g_assert (priv->mode == MODE_JINGLE);
+
+ if (_stream_not_ready_for_initiate (session, stream))
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_ERROR, "trying to send content-add for stream %s "
+ "but we have no local codecs. what?!", stream->name);
+ g_assert_not_reached ();
+ return;
+ }
+
+ msg = _gabble_media_session_message_new (session, "content-add",
+ &session_node);
+
+ _add_content_descriptions_one (session, stream, session_node);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle action \"content-add\" to peer for "
+ "stream %s", stream->name);
+
+ _gabble_connection_send_with_reply (priv->conn, msg,
+ content_add_msg_reply_cb, G_OBJECT (stream), session, NULL);
+
+ lm_message_unref (msg);
+
+ /* mark stream as sent */
+ g_object_set (stream, "signalling-state", STREAM_SIG_STATE_SENT, NULL);
+}
+
+static void
+stream_connection_state_changed_cb (GabbleMediaStream *stream,
+ GParamSpec *param,
+ GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ if (stream->connection_state != TP_MEDIA_STREAM_STATE_CONNECTED)
+ return;
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream %s has gone connected", stream->name);
+
+ if (stream->playing)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "doing nothing, stream is already playing");
+ return;
+ }
+
+ /* after session is active, we do things per-stream with content-* actions */
+ if (priv->state < JS_STATE_ACTIVE)
+ {
+ /* send a session accept if the session was initiated by the peer */
+ if (session->initiator == INITIATOR_REMOTE)
+ {
+ try_session_accept (session);
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "session initiated by us, so we're not "
+ "going to consider sending an accept");
+ }
+ }
+ else
+ {
+ /* send a content accept if the stream was added by the peer */
+ if (stream->initiator == INITIATOR_REMOTE)
+ {
+ try_content_accept (session, stream);
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream added by us, so we're not going "
+ "to send an accept");
+ }
+ }
+}
+
+static void
+stream_got_local_codecs_changed_cb (GabbleMediaStream *stream,
+ GParamSpec *param,
+ GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ if (!stream->got_local_codecs)
+ return;
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream %s has got local codecs", stream->name);
+
+ if (stream->playing)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_ERROR, "stream was already playing and we got local "
+ "codecs. what?!");
+ g_assert_not_reached ();
+ return;
+ }
+
+ /* after session is active, we do things per-stream with content-* actions */
+ if (priv->state < JS_STATE_ACTIVE)
+ {
+ if (session->initiator == INITIATOR_REMOTE)
+ {
+ if (priv->state < JS_STATE_PENDING_ACCEPT_SENT)
+ {
+ try_session_accept (session);
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream added after sending accept; "
+ "not doing content-add until remote end acknowledges");
+ }
+ }
+ else
+ {
+ if (priv->state < JS_STATE_PENDING_INITIATE_SENT)
+ {
+ try_session_initiate (session);
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "stream added after sending initiate; "
+ "not doing content-add until remote end accepts");
+ }
+ }
+ }
+ else
+ {
+ if (stream->initiator == INITIATOR_REMOTE)
+ {
+ try_content_accept (session, stream);
+ }
+ else
+ {
+ do_content_add (session, stream);
+ }
+ }
+}
+
+static gchar *
+get_jid_for_contact (GabbleMediaSession *session,
+ GabbleHandle handle)
+{
+ GabbleMediaSessionPrivate *priv;
+ const gchar *base_jid;
+ GabbleHandle self;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ self = priv->conn->self_handle;
+
+ base_jid = gabble_handle_inspect (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle);
+ g_assert (base_jid != NULL);
+
+ if (handle == self)
+ {
+ gchar *resource, *ret;
+ g_object_get (priv->conn, "resource", &resource, NULL);
+ g_assert (resource != NULL);
+ ret = g_strdup_printf ("%s/%s", base_jid, resource);
+ g_free (resource);
+ return ret;
+ }
+ else
+ {
+ g_assert (priv->peer_resource != NULL);
+ return g_strdup_printf ("%s/%s", base_jid, priv->peer_resource);
+ }
+}
+
+LmMessage *
+_gabble_media_session_message_new (GabbleMediaSession *session,
+ const gchar *action,
+ LmMessageNode **session_node)
+{
+ GabbleMediaSessionPrivate *priv;
+ LmMessage *msg;
+ LmMessageNode *iq_node, *node;
+ gchar *peer_jid, *initiator_jid;
+ GabbleHandle initiator_handle;
+ const gchar *element, *xmlns;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ peer_jid = get_jid_for_contact (session, priv->peer);
+
+ msg = lm_message_new_with_sub_type (
+ peer_jid,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ g_free (peer_jid);
+
+ iq_node = lm_message_get_node (msg);
+
+ if (priv->mode == MODE_GOOGLE)
+ element = "session";
+ else
+ element = "jingle";
+
+ if (session->initiator == INITIATOR_LOCAL)
+ initiator_handle = priv->conn->self_handle;
+ else
+ initiator_handle = priv->peer;
+
+ node = lm_message_node_add_child (iq_node, element, NULL);
+ initiator_jid = get_jid_for_contact (session, initiator_handle);
+
+ lm_message_node_set_attributes (node,
+ (priv->mode == MODE_GOOGLE) ? "id" : "sid", priv->id,
+ (priv->mode == MODE_GOOGLE) ? "type" : "action", action,
+ "initiator", initiator_jid,
+ NULL);
+
+ if (priv->mode == MODE_GOOGLE)
+ xmlns = NS_GOOGLE_SESSION;
+ else
+ xmlns = NS_JINGLE;
+
+ lm_message_node_set_attribute (node, "xmlns", xmlns);
+ g_free (initiator_jid);
+
+ if (session_node)
+ *session_node = node;
+
+ return msg;
+}
+
+void
+_gabble_media_session_accept (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ guint i;
+
+ priv->locally_accepted = TRUE;
+
+ /* accept any local pending sends */
+ for (i = 0; i < priv->streams->len; i++)
+ {
+ GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
+ CombinedStreamDirection combined_dir = stream->combined_direction;
+ TpMediaStreamDirection current_dir;
+ TpMediaStreamPendingSend pending_send;
+
+ current_dir = COMBINED_DIRECTION_GET_DIRECTION (combined_dir);
+ pending_send = COMBINED_DIRECTION_GET_PENDING_SEND (combined_dir);
+
+ if ((pending_send & TP_MEDIA_STREAM_PENDING_LOCAL_SEND) != 0)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "accepting pending local send on stream %s",
+ stream->name);
+
+ current_dir |= TP_MEDIA_STREAM_DIRECTION_SEND;
+ pending_send &= ~TP_MEDIA_STREAM_PENDING_LOCAL_SEND;
+ combined_dir = MAKE_COMBINED_DIRECTION (current_dir, pending_send);
+ g_object_set (stream, "combined-direction", combined_dir, NULL);
+ _gabble_media_stream_update_sending (stream, FALSE);
+ }
+ }
+
+ try_session_accept (session);
+}
+
+static LmHandlerResult
+content_remove_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (object);
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ GPtrArray *removing = (GPtrArray *) user_data;
+ guint i;
+
+ MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL (session, "stream removal failed");
+
+ for (i = 0; i < removing->len; i++)
+ destroy_media_stream (session,
+ GABBLE_MEDIA_STREAM (g_ptr_array_index (removing, i)));
+
+ g_ptr_array_remove_fast (priv->remove_requests, removing);
+ g_ptr_array_free (removing, TRUE);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+void
+_gabble_media_session_remove_streams (GabbleMediaSession *session,
+ GabbleMediaStream **streams,
+ guint len)
+{
+ GabbleMediaSessionPrivate *priv;
+ LmMessage *msg = NULL;
+ LmMessageNode *session_node;
+ GPtrArray *removing = NULL;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ /* end the session if there'd be no streams left after reducing it */
+ if (_count_non_removing_streams (session) == len)
+ {
+ _gabble_media_session_terminate (session, INITIATOR_LOCAL,
+ TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+ return;
+ }
+
+ /* construct a remove message if we're in a state greater than CREATED (ie
+ * something has been sent/received about this session) */
+ if (priv->state > JS_STATE_PENDING_CREATED)
+ {
+ msg = _gabble_media_session_message_new (session, "content-remove",
+ &session_node);
+ removing = g_ptr_array_sized_new (len);
+ }
+
+ /* right, remove them */
+ for (i = 0; i < len; i++)
+ {
+ GabbleMediaStream *stream = streams[i];
+
+ switch (stream->signalling_state)
+ {
+ case STREAM_SIG_STATE_NEW:
+ destroy_media_stream (session, stream);
+ break;
+ case STREAM_SIG_STATE_SENT:
+ case STREAM_SIG_STATE_ACKNOWLEDGED:
+ {
+ LmMessageNode *content_node;
+
+ g_assert (msg != NULL);
+ g_assert (removing != NULL);
+
+ content_node = _gabble_media_stream_add_content_node (stream,
+ session_node);
+
+ g_object_set (stream,
+ "playing", FALSE,
+ "signalling-state", STREAM_SIG_STATE_REMOVING,
+ NULL);
+
+ /* close the stream now, but don't forget about it until the
+ * removal message is acknowledged, since we need to be able to
+ * detect content-remove cross-talk */
+ _gabble_media_stream_close (stream);
+ g_ptr_array_add (removing, stream);
+ }
+ break;
+ case STREAM_SIG_STATE_REMOVING:
+ break;
+ }
+ }
+
+ /* send the remove message if necessary */
+ if (msg != NULL)
+ {
+ if (removing->len > 0)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle session action "
+ "\"content-remove\" to peer");
+
+ _gabble_connection_send_with_reply (priv->conn, msg,
+ content_remove_msg_reply_cb, G_OBJECT (session), removing, NULL);
+
+ g_ptr_array_add (priv->remove_requests, removing);
+ }
+ else
+ {
+ g_ptr_array_free (removing, TRUE);
+ }
+
+ lm_message_unref (msg);
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "not sending jingle session action "
+ "\"content-remove\" to peer, no initiates or adds sent for "
+ "these streams");
+ }
+}
+
+/* for when you want the reply to be removed from
+ * the handler chain, but don't care what it is */
+static LmHandlerResult
+ignore_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+send_reject_message (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ LmMessage *msg;
+ LmMessageNode *session_node;
+
+ /* this should only happen in google mode, and we should only arrive in that
+ * mode when we've ended up talking to a resource that doesn't support
+ * jingle */
+ g_assert (priv->mode == MODE_GOOGLE);
+ g_assert (priv->peer_resource != NULL);
+
+ /* construct a session terminate message */
+ msg = _gabble_media_session_message_new (session, "reject", &session_node);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle session action \"reject\" to peer");
+
+ /* send it */
+ _gabble_connection_send_with_reply (priv->conn, msg, ignore_reply_cb,
+ G_OBJECT (session), NULL, NULL);
+
+ lm_message_unref (msg);
+}
+
+static void
+send_terminate_message (GabbleMediaSession *session)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ const gchar *action;
+ LmMessage *msg;
+ LmMessageNode *session_node;
+
+ /* construct a session terminate message */
+ if (priv->mode == MODE_GOOGLE)
+ action = "terminate";
+ else
+ action = "session-terminate";
+
+ msg = _gabble_media_session_message_new (session, action, &session_node);
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle session action \"%s\" to peer",
+ action);
+
+ /* send it */
+ _gabble_connection_send_with_reply (priv->conn, msg, ignore_reply_cb,
+ G_OBJECT (session), NULL, NULL);
+
+ lm_message_unref (msg);
+}
+
+void
+_gabble_media_session_terminate (GabbleMediaSession *session,
+ JingleInitiator who,
+ TpChannelGroupChangeReason why)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ GabbleHandle actor;
+
+ if (priv->state == JS_STATE_ENDED)
+ return;
+
+ if (who == INITIATOR_REMOTE)
+ {
+ actor = priv->peer;
+ }
+ else
+ {
+ actor = priv->conn->self_handle;
+
+ /* Need to tell them that it's all over. */
+
+ /* Jingle doesn't have a "reject" action; a termination before an
+ * acceptance indicates that the call has been declined */
+
+ if (session->initiator == INITIATOR_REMOTE &&
+ priv->state == JS_STATE_PENDING_INITIATED &&
+ priv->mode == MODE_GOOGLE)
+ {
+ send_reject_message (session);
+ }
+
+ /* if we're still in CREATED, then we've not sent or received any
+ * messages about this session yet, so no terminate is necessary */
+ else if (priv->state > JS_STATE_PENDING_CREATED)
+ {
+ send_terminate_message (session);
+ }
+
+ while (priv->streams->len > 0)
+ destroy_media_stream (session, g_ptr_array_index (priv->streams, 0));
+ }
+
+ priv->terminated = TRUE;
+ g_object_set (session, "state", JS_STATE_ENDED, NULL);
+ g_signal_emit (session, signals[TERMINATED], 0, actor, why);
+}
+
+#if _GMS_DEBUG_LEVEL
+void
+_gabble_media_session_debug (GabbleMediaSession *session,
+ DebugMessageType type,
+ const gchar *format, ...)
+{
+ if (DEBUGGING)
+ {
+ va_list list;
+ gchar buf[512];
+ GabbleMediaSessionPrivate *priv;
+ time_t curtime;
+ struct tm *loctime;
+ gchar stamp[10];
+ const gchar *type_str;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ curtime = time (NULL);
+ loctime = localtime (&curtime);
+
+ strftime (stamp, sizeof (stamp), "%T", loctime);
+
+ va_start (list, format);
+
+ vsnprintf (buf, sizeof (buf), format, list);
+
+ va_end (list);
+
+ switch (type) {
+ case DEBUG_MSG_INFO:
+ type_str = ANSI_BOLD_ON ANSI_FG_WHITE;
+ break;
+ case DEBUG_MSG_DUMP:
+ type_str = ANSI_BOLD_ON ANSI_FG_GREEN;
+ break;
+ case DEBUG_MSG_WARNING:
+ type_str = ANSI_BOLD_ON ANSI_FG_YELLOW;
+ break;
+ case DEBUG_MSG_ERROR:
+ type_str = ANSI_BOLD_ON ANSI_FG_WHITE ANSI_BG_RED;
+ break;
+ case DEBUG_MSG_EVENT:
+ type_str = ANSI_BOLD_ON ANSI_FG_CYAN;
+ break;
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+
+ g_message ("[%s%s%s] %s%-26s%s %s%s%s\n",
+ ANSI_BOLD_ON ANSI_FG_WHITE,
+ stamp,
+ ANSI_RESET,
+ session_states[priv->state].attributes,
+ session_states[priv->state].name,
+ ANSI_RESET,
+ type_str,
+ buf,
+ ANSI_RESET);
+
+ fflush (stdout);
+ }
+}
+
+#endif /* _GMS_DEBUG_LEVEL */
+
+static const gchar *
+_name_stream (GabbleMediaSession *session,
+ TpMediaStreamType media_type)
+{
+ GabbleMediaSessionPrivate *priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+#ifndef EMULATOR
+ static gchar ret_sess[MAX_STREAM_NAME_LEN] = GTALK_STREAM_NAME;
+#endif
+
+ if (priv->mode != MODE_GOOGLE)
+ {
+ guint i = 1;
+
+ do {
+ g_snprintf (ret_sess, MAX_STREAM_NAME_LEN, "%s%u",
+ media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video",
+ i++);
+
+ /* even though we now have seperate namespaces for local and remote,
+ * actually check in both so that we can still support clients which
+ * have 1 namespace (such as our older selves :D) */
+ if (_lookup_stream_by_name_and_initiator (session, ret_sess,
+ INITIATOR_INVALID) != NULL)
+ {
+ ret_sess[0] = '\0';
+ }
+ } while (ret_sess[0] == '\0');
+ }
+
+ return ret_sess;
+}
+
+
+gboolean
+_gabble_media_session_request_streams (GabbleMediaSession *session,
+ const GArray *media_types,
+ GPtrArray **ret,
+ GError **error)
+{
+
+#ifndef EMULATOR
+ static GabblePresenceCapabilities google_audio_caps =
+ PRESENCE_CAP_GOOGLE_VOICE;
+ static GabblePresenceCapabilities jingle_audio_caps =
+ PRESENCE_CAP_JINGLE | PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO |
+ PRESENCE_CAP_GOOGLE_TRANSPORT_P2P;
+ static GabblePresenceCapabilities jingle_video_caps =
+ PRESENCE_CAP_JINGLE | PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO |
+ PRESENCE_CAP_GOOGLE_TRANSPORT_P2P;
+#endif
+
+ GabbleMediaSessionPrivate *priv;
+ GabblePresence *presence;
+ gboolean want_audio, want_video;
+ GabblePresenceCapabilities jingle_desired_caps;
+ guint idx;
+ gchar *dump;
+
+ g_assert (GABBLE_IS_MEDIA_SESSION (session));
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ presence = gabble_presence_cache_get (priv->conn->presence_cache,
+ priv->peer);
+
+ if (presence == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "member has no audio/video capabilities");
+
+ return FALSE;
+ }
+
+ dump = gabble_presence_dump (presence);
+ _gabble_media_session_debug (session, DEBUG_MSG_DUMP, "presence for peer %d:\n%s", priv->peer, dump);
+ g_free (dump);
+
+ want_audio = want_video = FALSE;
+
+ for (idx = 0; idx < media_types->len; idx++)
+ {
+ guint media_type = g_array_index (media_types, guint, idx);
+
+ if (media_type == TP_MEDIA_STREAM_TYPE_AUDIO)
+ {
+ want_audio = TRUE;
+ }
+ else if (media_type == TP_MEDIA_STREAM_TYPE_VIDEO)
+ {
+ want_video = TRUE;
+ }
+ else
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "given media type %u is invalid", media_type);
+ return FALSE;
+ }
+ }
+
+ /* work out what we'd need to do these streams with jingle */
+ jingle_desired_caps = 0;
+
+ if (want_audio)
+ jingle_desired_caps |= jingle_audio_caps;
+
+ if (want_video)
+ jingle_desired_caps |= jingle_video_caps;
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "want audio: %s; want video: %s",
+ want_audio ? "yes" : "no", want_video ? "yes" : "no");
+
+ /* existing call; the recipient and the mode has already been decided */
+ if (priv->peer_resource)
+ {
+ /* is a google call... we have no other option */
+ if (priv->mode == MODE_GOOGLE)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "already in Google mode; can't add new "
+ "stream");
+
+ g_assert (priv->streams->len == 1);
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Google Talk calls may only contain one stream");
+
+ return FALSE;
+ }
+
+ if (!gabble_presence_resource_has_caps (presence, priv->peer_resource,
+ jingle_desired_caps))
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "in Jingle mode but have insufficient caps for requested streams");
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "existing call member doesn't support all requested media"
+ " types");
+
+ return FALSE;
+ }
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "in Jingle mode, and have necessary caps");
+ }
+
+ /* no existing call; we should choose a recipient and a mode */
+ else
+ {
+ const gchar *resource;
+
+ g_assert (priv->streams->len == 0);
+
+ /* see if we have a fully-capable jingle resource; regardless of the
+ * desired media type it's best if we can add/remove the others later */
+ resource = gabble_presence_pick_resource_by_caps (presence,
+ jingle_audio_caps | jingle_video_caps);
+
+ if (resource == NULL)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "contact is not fully jingle-capable");
+
+ /* ok, no problem. see if we can do just what's wanted with jingle */
+ resource = gabble_presence_pick_resource_by_caps (presence,
+ jingle_desired_caps);
+
+ if (resource == NULL && want_audio && !want_video)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "contact doesn't have desired Jingle capabilities");
+
+ /* last ditch... if we want only audio and not video, we can make
+ * do with google talk */
+ resource = gabble_presence_pick_resource_by_caps (presence,
+ google_audio_caps);
+
+ if (resource != NULL)
+ {
+ /* only one stream possible with google */
+ if (media_types->len == 1)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "contact has no Jingle capabilities; "
+ "falling back to Google audio call");
+ priv->mode = MODE_GOOGLE;
+ }
+ else
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Google Talk calls may only contain one stream");
+
+ return FALSE;
+ }
+ }
+ else
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "contact doesn't have desired Google capabilities");
+ }
+ }
+ }
+
+ if (resource == NULL)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO,
+ "contact doesn't have a resource with suitable capabilities");
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "member does not have the desired audio/video capabilities");
+
+ return FALSE;
+ }
+
+ priv->peer_resource = g_strdup (resource);
+ }
+
+ /* check it's not a ridiculous number of streams */
+ if ((priv->streams->len + media_types->len) > MAX_STREAMS)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "I think that's quite enough streams already");
+ return FALSE;
+ }
+
+ /* if we've got here, we're good to make the streams */
+
+ *ret = g_ptr_array_sized_new (media_types->len);
+
+ for (idx = 0; idx < media_types->len; idx++)
+ {
+ guint media_type = g_array_index (media_types, guint, idx);
+ GabbleMediaStream *stream;
+ const gchar *stream_name;
+
+ if (priv->mode == MODE_GOOGLE)
+ stream_name = GTALK_STREAM_NAME;
+ else
+ stream_name = _name_stream (session, media_type);
+
+ stream = create_media_stream (session, stream_name, INITIATOR_LOCAL,
+ media_type);
+
+ g_ptr_array_add (*ret, stream);
+ }
+
+ return TRUE;
+}
+
+static const gchar *
+_direction_to_senders (GabbleMediaSession *session,
+ TpMediaStreamDirection dir)
+{
+ const gchar *ret = NULL;
+
+ switch (dir)
+ {
+ case TP_MEDIA_STREAM_DIRECTION_NONE:
+ g_assert_not_reached ();
+ break;
+ case TP_MEDIA_STREAM_DIRECTION_SEND:
+ if (session->initiator == INITIATOR_LOCAL)
+ ret = "initiator";
+ else
+ ret = "responder";
+ break;
+ case TP_MEDIA_STREAM_DIRECTION_RECEIVE:
+ if (session->initiator == INITIATOR_REMOTE)
+ ret = "initiator";
+ else
+ ret = "responder";
+ break;
+ case TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL:
+ ret = "both";
+ break;
+ }
+
+ g_assert (ret != NULL);
+
+ return ret;
+}
+
+static LmHandlerResult
+direction_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaSession *session = GABBLE_MEDIA_SESSION (user_data);
+ GabbleMediaStream *stream = GABBLE_MEDIA_STREAM (object);
+
+ MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL (session, "direction change failed");
+
+ if (stream->playing)
+ {
+ _gabble_media_stream_update_sending (stream, TRUE);
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static gboolean
+send_direction_change (GabbleMediaSession *session,
+ GabbleMediaStream *stream,
+ TpMediaStreamDirection dir,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv;
+ const gchar *senders;
+ LmMessage *msg;
+ LmMessageNode *session_node, *content_node;
+ gboolean ret;
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+ senders = _direction_to_senders (session, dir);
+
+ if (stream->signalling_state == STREAM_SIG_STATE_NEW ||
+ stream->signalling_state == STREAM_SIG_STATE_REMOVING)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "not sending content-modify for %s stream %s",
+ stream->signalling_state == STREAM_SIG_STATE_NEW ? "new" : "removing",
+ stream->name);
+ return TRUE;
+ }
+
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "sending jingle session action \"content-modify\" "
+ "to peer for stream %s (senders=%s)", stream->name, senders);
+
+ msg = _gabble_media_session_message_new (session, "content-modify",
+ &session_node);
+ content_node = _gabble_media_stream_add_content_node (stream, session_node);
+
+ lm_message_node_set_attribute (content_node, "senders", senders);
+
+ ret = _gabble_connection_send_with_reply (priv->conn, msg,
+ direction_msg_reply_cb, G_OBJECT (stream), session, error);
+
+ lm_message_unref (msg);
+
+ return ret;
+}
+
+gboolean
+_gabble_media_session_request_stream_direction (GabbleMediaSession *session,
+ GabbleMediaStream *stream,
+ TpMediaStreamDirection requested_dir,
+ GError **error)
+{
+ GabbleMediaSessionPrivate *priv;
+ CombinedStreamDirection new_combined_dir;
+ TpMediaStreamDirection current_dir; //, new_dir;
+ TpMediaStreamPendingSend pending_send;
+
+ priv = GABBLE_MEDIA_SESSION_GET_PRIVATE (session);
+
+ current_dir = COMBINED_DIRECTION_GET_DIRECTION (stream->combined_direction);
+ pending_send = COMBINED_DIRECTION_GET_PENDING_SEND
+ (stream->combined_direction);
+
+ if (priv->mode == MODE_GOOGLE)
+ {
+ g_assert (current_dir == TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);
+
+ if (requested_dir == TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL)
+ return TRUE;
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Google Talk calls can only be bi-directional");
+ return FALSE;
+ }
+
+ if (requested_dir == TP_MEDIA_STREAM_DIRECTION_NONE)
+ {
+ _gabble_media_session_debug (session, DEBUG_MSG_INFO, "request for NONE direction; removing stream");
+
+ _gabble_media_session_remove_streams (session, &stream, 1);
+
+ return TRUE;
+ }
+
+ /* if we're awaiting a local decision on sending... */
+ if ((pending_send & TP_MEDIA_STREAM_PENDING_LOCAL_SEND) != 0)
+ {
+ /* clear the flag */
+ pending_send &= ~TP_MEDIA_STREAM_PENDING_LOCAL_SEND;
+
+ /* make our current_dir match what other end thinks (he thinks we're
+ * bidirectional) so that we send the correct transitions */
+ current_dir ^= TP_MEDIA_STREAM_DIRECTION_SEND;
+ }
+
+#if 0
+ /* if we're asking the remote end to start sending, set the pending flag and
+ * don't change our directionality just yet */
+ new_dir = requested_dir;
+ if (((current_dir & TP_MEDIA_STREAM_DIRECTION_RECEIVE) == 0) &&
+ ((new_dir & TP_MEDIA_STREAM_DIRECTION_RECEIVE) != 0))
+ {
+ pending_send ^= TP_MEDIA_STREAM_PENDING_REMOTE_SEND;
+ new_dir &= ~TP_MEDIA_STREAM_DIRECTION_RECEIVE;
+ }
+#endif
+
+ /* make any necessary changes */
+ new_combined_dir = MAKE_COMBINED_DIRECTION (requested_dir, pending_send);
+ if (new_combined_dir != stream->combined_direction)
+ {
+ g_object_set (stream, "combined-direction", new_combined_dir, NULL);
+ _gabble_media_stream_update_sending (stream, FALSE);
+ }
+
+ /* short-circuit sending a request if we're not asking for anything new */
+ if (current_dir == requested_dir)
+ return TRUE;
+
+ /* send request */
+ return send_direction_change (session, stream, requested_dir, error);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-stream-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,180 @@
+/*
+ * gabble-media-stream-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:STRING,BOXED (gabble-media-stream-signals-marshal.list:1) */
+void
+gabble_media_stream_marshal_VOID__STRING_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_BOXED) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_BOXED callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ data2);
+}
+
+/* VOID:STRING,STRING (gabble-media-stream-signals-marshal.list:2) */
+void
+gabble_media_stream_marshal_VOID__STRING_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+}
+
+/* VOID:UINT,STRING (gabble-media-stream-signals-marshal.list:3) */
+void
+gabble_media_stream_marshal_VOID__UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_STRING) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_string (param_values + 2),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-media-stream.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1836 @@
+/*
+ * gabble-media-stream.c - Source for GabbleMediaStream
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#include "ansi.h"
+#include "debug.h"
+#include "handles.h"
+#include "namespaces.h"
+
+#include "gabble-connection.h"
+#include "gabble-media-channel.h"
+#include "gabble-media-session.h"
+#include "gabble-media-session-enumtypes.h"
+
+#include "telepathy-helpers.h"
+#include "telepathy-constants.h"
+
+#include "gabble-media-stream.h"
+#include "gabble-media-stream-signals-marshal.h"
+#include "gabble-media-stream-glue.h"
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleMediaStream, gabble_media_stream, G_TYPE_OBJECT)
+#endif
+
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+//#define NODE_DEBUG(n, s) ;
+#endif /* DEBUG_FLAG */
+
+/* signal enum */
+enum
+{
+ DESTROY,
+
+ ADD_REMOTE_CANDIDATE,
+ CLOSE,
+ REMOVE_REMOTE_CANDIDATE,
+ SET_ACTIVE_CANDIDATE_PAIR,
+ SET_REMOTE_CANDIDATE_LIST,
+ SET_REMOTE_CODECS,
+ SET_STREAM_PLAYING,
+ SET_STREAM_SENDING,
+
+ NEW_ACTIVE_CANDIDATE_PAIR,
+ NEW_NATIVE_CANDIDATE,
+ SUPPORTED_CODECS,
+ ERROR,
+
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_MED_STREAM
+#endif
+
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_med_stream,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_med_stream, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_media_stream_parent_class,gabble_med_stream,gpointer)
+ #define gabble_media_stream_parent_class (*GET_WSD_VAR_NAME(gabble_media_stream_parent_class,gabble_med_stream,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_med_stream,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_med_stream,s)())
+
+ /*gchar** _s_gabble_med_stream_video_codec_params() { return (gchar**)((libgabble_ImpurePtr()->_s_gabble_med_stream_video_codec_params)); }
+
+ #define video_codec_params (GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream, s)())*/
+
+
+static void gabble_media_stream_init (GabbleMediaStream *self);
+static void gabble_media_stream_class_init (GabbleMediaStreamClass *klass);
+static void gabble_media_stream_class_intern_init (gpointer klass)
+{
+gabble_media_stream_parent_class = g_type_class_peek_parent (klass);
+ gabble_media_stream_class_init ((GabbleMediaStreamClass*) klass);
+}
+ EXPORT_C GType gabble_media_stream_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ {
+ static const GTypeInfo g_define_type_info = { sizeof (GabbleMediaStreamClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_media_stream_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleMediaStream), 0, (GInstanceInitFunc) gabble_media_stream_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleMediaStream"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ };
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ PROP_MEDIA_SESSION,
+ PROP_OBJECT_PATH,
+ PROP_MODE,
+ PROP_NAME,
+ PROP_ID,
+ PROP_INITIATOR,
+ PROP_MEDIA_TYPE,
+ PROP_CONNECTION_STATE,
+ PROP_READY,
+ PROP_GOT_LOCAL_CODECS,
+ PROP_SIGNALLING_STATE,
+ PROP_PLAYING,
+ PROP_COMBINED_DIRECTION,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleMediaStreamPrivate GabbleMediaStreamPrivate;
+
+struct _GabbleMediaStreamPrivate
+{
+ GabbleConnection *conn;
+ GabbleMediaSession *session;
+ GabbleMediaSessionMode mode;
+ gchar *object_path;
+ guint id;
+ guint media_type;
+
+ gboolean ready;
+ gboolean sending;
+
+ GValue native_codecs; /* intersected codec list */
+ GValue native_candidates;
+
+ GValue remote_codecs;
+ GValue remote_candidates;
+
+ guint remote_candidate_count;
+
+ gboolean closed;
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_MEDIA_STREAM_GET_PRIVATE(obj) \
+ ((GabbleMediaStreamPrivate *)obj->priv)
+//Vinod: add below definition
+#define ENABLE_DEBUG
+
+#ifdef ENABLE_DEBUG
+#if _GMS_DEBUG_LEVEL > 1
+static const char *tp_protocols[] = {
+ "TP_MEDIA_STREAM_PROTO_UDP (0)",
+ "TP_MEDIA_STREAM_PROTO_TCP (1)"
+};
+
+static const char *tp_transports[] = {
+ "TP_MEDIA_STREAM_TRANSPORT_TYPE_LOCAL (0)",
+ "TP_MEDIA_STREAM_TRANSPORT_TYPE_DERIVED (1)",
+ "TP_MEDIA_STREAM_TRANSPORT_TYPE_RELAY (2)"
+};
+#endif
+#endif
+
+static void push_native_candidates (GabbleMediaStream *stream);
+static void push_remote_codecs (GabbleMediaStream *stream);
+static void push_remote_candidates (GabbleMediaStream *stream);
+static void push_playing (GabbleMediaStream *stream);
+static void push_sending (GabbleMediaStream *stream);
+
+static void
+gabble_media_stream_init (GabbleMediaStream *self)
+{
+ GabbleMediaStreamPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_MEDIA_STREAM, GabbleMediaStreamPrivate);
+
+ self->priv = priv;
+
+ g_value_init (&priv->native_codecs, TP_TYPE_CODEC_LIST);
+ g_value_take_boxed (&priv->native_codecs,
+ dbus_g_type_specialized_construct (TP_TYPE_CODEC_LIST));
+
+ g_value_init (&priv->native_candidates, TP_TYPE_CANDIDATE_LIST);
+ g_value_take_boxed (&priv->native_candidates,
+ dbus_g_type_specialized_construct (TP_TYPE_CANDIDATE_LIST));
+
+ g_value_init (&priv->remote_codecs, TP_TYPE_CODEC_LIST);
+ g_value_take_boxed (&priv->remote_codecs,
+ dbus_g_type_specialized_construct (TP_TYPE_CODEC_LIST));
+
+ g_value_init (&priv->remote_candidates, TP_TYPE_CANDIDATE_LIST);
+ g_value_take_boxed (&priv->remote_candidates,
+ dbus_g_type_specialized_construct (TP_TYPE_CANDIDATE_LIST));
+}
+
+static GObject *
+gabble_media_stream_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleMediaStreamPrivate *priv;
+ DBusGConnection *bus;
+
+ /* call base class constructor */
+ obj = G_OBJECT_CLASS (gabble_media_stream_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (GABBLE_MEDIA_STREAM (obj));
+
+ /* go for the bus */
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ return obj;
+}
+
+static void
+gabble_media_stream_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaStream *stream = GABBLE_MEDIA_STREAM (object);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ case PROP_MEDIA_SESSION:
+ g_value_set_object (value, priv->session);
+ break;
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_MODE:
+ g_value_set_enum (value, priv->mode);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value, stream->name);
+ break;
+ case PROP_ID:
+ g_value_set_uint (value, priv->id);
+ break;
+ case PROP_INITIATOR:
+ g_value_set_uint (value, stream->initiator);
+ break;
+ case PROP_MEDIA_TYPE:
+ g_value_set_uint (value, priv->media_type);
+ break;
+ case PROP_CONNECTION_STATE:
+ g_value_set_uint (value, stream->connection_state);
+ break;
+ case PROP_READY:
+ g_value_set_boolean (value, priv->ready);
+ break;
+ case PROP_GOT_LOCAL_CODECS:
+ g_value_set_boolean (value, stream->got_local_codecs);
+ break;
+ case PROP_SIGNALLING_STATE:
+ g_value_set_uint (value, stream->signalling_state);
+ break;
+ case PROP_PLAYING:
+ g_value_set_boolean (value, stream->playing);
+ break;
+ case PROP_COMBINED_DIRECTION:
+ g_value_set_uint (value, stream->combined_direction);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_media_stream_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaStream *stream = GABBLE_MEDIA_STREAM (object);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ case PROP_MEDIA_SESSION:
+ priv->session = g_value_get_object (value);
+ break;
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_MODE:
+ priv->mode = g_value_get_enum (value);
+ break;
+ case PROP_NAME:
+ g_free (stream->name);
+ stream->name = g_value_dup_string (value);
+ break;
+ case PROP_ID:
+ priv->id = g_value_get_uint (value);
+ break;
+ case PROP_INITIATOR:
+ stream->initiator = g_value_get_uint (value);
+ break;
+ case PROP_MEDIA_TYPE:
+ priv->media_type = g_value_get_uint (value);
+ break;
+ case PROP_CONNECTION_STATE:
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "stream %s connection state %d",
+ stream->name, stream->connection_state);
+ stream->connection_state = g_value_get_uint (value);
+ break;
+ case PROP_READY:
+ priv->ready = g_value_get_boolean (value);
+ break;
+ case PROP_GOT_LOCAL_CODECS:
+ stream->got_local_codecs = g_value_get_boolean (value);
+ break;
+ case PROP_SIGNALLING_STATE:
+ {
+ StreamSignallingState old = stream->signalling_state;
+ stream->signalling_state = g_value_get_uint (value);
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "stream %s sig_state %d->%d",
+ stream->name, old, stream->signalling_state);
+ if (stream->signalling_state != old)
+ push_native_candidates (stream);
+ }
+ break;
+ case PROP_PLAYING:
+ {
+ gboolean old = stream->playing;
+ stream->playing = g_value_get_boolean (value);
+ if (stream->playing != old)
+ push_playing (stream);
+ }
+ break;
+ case PROP_COMBINED_DIRECTION:
+ stream->combined_direction = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_media_stream_dispose (GObject *object);
+static void gabble_media_stream_finalize (GObject *object);
+
+static void
+gabble_media_stream_class_init (GabbleMediaStreamClass *gabble_media_stream_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_media_stream_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_media_stream_class, sizeof (GabbleMediaStreamPrivate));
+
+ object_class->constructor = gabble_media_stream_constructor;
+
+ object_class->get_property = gabble_media_stream_get_property;
+ object_class->set_property = gabble_media_stream_set_property;
+
+ object_class->dispose = gabble_media_stream_dispose;
+ object_class->finalize = gabble_media_stream_finalize;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "media stream's channel.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ param_spec = g_param_spec_object ("media-session", "GabbleMediaSession object",
+ "Gabble media session object that owns this "
+ "media stream object.",
+ GABBLE_TYPE_MEDIA_SESSION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_MEDIA_SESSION, param_spec);
+
+ param_spec = g_param_spec_string ("object-path", "D-Bus object path",
+ "The D-Bus object path used for this "
+ "object on the bus.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_OBJECT_PATH, param_spec);
+
+ param_spec = g_param_spec_enum ("mode", "Signalling mode",
+ "Which signalling mode used to control the "
+ "stream.",
+ gabble_media_session_mode_get_type(),
+ MODE_JINGLE,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_MODE, param_spec);
+
+ param_spec = g_param_spec_string ("name", "Stream name",
+ "An opaque name for the stream used in the "
+ "signalling.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_NAME, param_spec);
+
+ param_spec = g_param_spec_uint ("id", "Stream ID",
+ "A stream number for the stream used in the "
+ "D-Bus API.",
+ 0, G_MAXUINT, 0,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_ID, param_spec);
+
+ param_spec = g_param_spec_uint ("initiator", "Stream initiator",
+ "An enum signifying which end initiated "
+ "the stream.",
+ INITIATOR_LOCAL,
+ INITIATOR_REMOTE,
+ INITIATOR_LOCAL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_INITIATOR, param_spec);
+
+ param_spec = g_param_spec_uint ("media-type", "Stream media type",
+ "A constant indicating which media type the "
+ "stream carries.",
+ TP_MEDIA_STREAM_TYPE_AUDIO,
+ TP_MEDIA_STREAM_TYPE_VIDEO,
+ TP_MEDIA_STREAM_TYPE_AUDIO,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_MEDIA_TYPE, param_spec);
+
+ param_spec = g_param_spec_uint ("connection-state", "Stream connection state",
+ "An integer indicating the state of the"
+ "stream's connection.",
+ TP_MEDIA_STREAM_STATE_DISCONNECTED,
+ TP_MEDIA_STREAM_STATE_CONNECTED,
+ TP_MEDIA_STREAM_STATE_DISCONNECTED,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION_STATE, param_spec);
+
+ param_spec = g_param_spec_boolean ("ready", "Ready?",
+ "A boolean signifying whether the user "
+ "is ready to handle signals from this "
+ "object.",
+ FALSE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_READY, param_spec);
+
+ param_spec = g_param_spec_boolean ("got-local-codecs", "Got local codecs?",
+ "A boolean signifying whether we've got "
+ "the locally supported codecs from the user.",
+ FALSE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_GOT_LOCAL_CODECS, param_spec);
+
+ param_spec = g_param_spec_uint ("signalling-state", "Signalling state",
+ "Whether the stream is newly created, "
+ "sent to the peer, or acknowledged.",
+ STREAM_SIG_STATE_NEW,
+ STREAM_SIG_STATE_REMOVING,
+ STREAM_SIG_STATE_NEW,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_SIGNALLING_STATE, param_spec);
+
+ param_spec = g_param_spec_boolean ("playing", "Set playing",
+ "A boolean signifying whether the stream "
+ "has been set playing yet.",
+ FALSE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_PLAYING, param_spec);
+
+ param_spec = g_param_spec_uint ("combined-direction",
+ "Combined direction",
+ "An integer indicating the directions the stream currently sends in, "
+ "and the peers who have been asked to send.",
+ TP_MEDIA_STREAM_DIRECTION_NONE,
+ MAKE_COMBINED_DIRECTION (TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL,
+ TP_MEDIA_STREAM_PENDING_LOCAL_SEND |
+ TP_MEDIA_STREAM_PENDING_REMOTE_SEND),
+ TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_COMBINED_DIRECTION,
+ param_spec);
+
+ /* signals exported by D-Bus interface */
+ signals[DESTROY] =
+ g_signal_new ("destroy",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[ADD_REMOTE_CANDIDATE] =
+ g_signal_new ("add-remote-candidate",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_stream_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE, 2, G_TYPE_STRING, TP_TYPE_TRANSPORT_LIST);
+
+ signals[CLOSE] =
+ g_signal_new ("close",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[REMOVE_REMOTE_CANDIDATE] =
+ g_signal_new ("remove-remote-candidate",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ signals[SET_ACTIVE_CANDIDATE_PAIR] =
+ g_signal_new ("set-active-candidate-pair",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_stream_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+
+ signals[SET_REMOTE_CANDIDATE_LIST] =
+ g_signal_new ("set-remote-candidate-list",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, TP_TYPE_CANDIDATE_LIST);
+
+ signals[SET_REMOTE_CODECS] =
+ g_signal_new ("set-remote-codecs",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, TP_TYPE_CODEC_LIST);
+
+ /* signals not exported by D-Bus interface */
+ signals[NEW_ACTIVE_CANDIDATE_PAIR] =
+ g_signal_new ("new-active-candidate-pair",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_stream_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+
+ signals[NEW_NATIVE_CANDIDATE] =
+ g_signal_new ("new-native-candidate",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_stream_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE, 2, G_TYPE_STRING, TP_TYPE_TRANSPORT_LIST);
+
+ signals[SUPPORTED_CODECS] =
+ g_signal_new ("supported-codecs",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, TP_TYPE_CODEC_LIST);
+
+ signals[SET_STREAM_PLAYING] =
+ g_signal_new ("set-stream-playing",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+ signals[SET_STREAM_SENDING] =
+ g_signal_new ("set-stream-sending",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+ signals[ERROR] =
+ g_signal_new ("error",
+ G_OBJECT_CLASS_TYPE (gabble_media_stream_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_media_stream_marshal_VOID__UINT_STRING,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_media_stream_class), &dbus_glib_gabble_media_stream_object_info);
+}
+
+void
+gabble_media_stream_dispose (GObject *object)
+{
+ GabbleMediaStream *self = GABBLE_MEDIA_STREAM (object);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ _gabble_media_stream_close (self);
+
+ g_signal_emit (self, signals[DESTROY], 0);
+
+ priv->dispose_has_run = TRUE;
+
+ if (G_OBJECT_CLASS (gabble_media_stream_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_media_stream_parent_class)->dispose (object);
+}
+
+void
+gabble_media_stream_finalize (GObject *object)
+{
+ GabbleMediaStream *self = GABBLE_MEDIA_STREAM (object);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ g_free (priv->object_path);
+
+ g_value_unset (&priv->native_codecs);
+ g_value_unset (&priv->native_candidates);
+
+ g_value_unset (&priv->remote_codecs);
+ g_value_unset (&priv->remote_candidates);
+
+ G_OBJECT_CLASS (gabble_media_stream_parent_class)->finalize (object);
+}
+
+/**
+ * gabble_media_stream_codec_choice
+ *
+ * Implements D-Bus method CodecChoice
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_codec_choice (GabbleMediaStream *self,
+ guint codec_id,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_error
+ *
+ * Implements D-Bus method Error
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_error (GabbleMediaStream *self,
+ guint errno,
+ const gchar *message,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_WARNING, "Media.StreamHandler::Error called, error %u (%s) -- emitting signal", errno, message);
+
+ g_signal_emit (self, signals[ERROR], 0, errno, message);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_native_candidates_prepared
+ *
+ * Implements D-Bus method NativeCandidatesPrepared
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_native_candidates_prepared (GabbleMediaStream *self,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_new_active_candidate_pair
+ *
+ * Implements D-Bus method NewActiveCandidatePair
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_new_active_candidate_pair (GabbleMediaStream *self,
+ const gchar *native_candidate_id,
+ const gchar *remote_candidate_id,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ g_signal_emit (self, signals[NEW_ACTIVE_CANDIDATE_PAIR], 0,
+ native_candidate_id, remote_candidate_id);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_new_native_candidate
+ *
+ * Implements D-Bus method NewNativeCandidate
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_new_native_candidate (GabbleMediaStream *self,
+ const gchar *candidate_id,
+ const GPtrArray *transports,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+ JingleSessionState state;
+ GPtrArray *candidates;
+ GValue candidate = { 0, };
+ GValueArray *transport;
+ const gchar *addr;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ g_object_get (priv->session, "state", &state, NULL);
+
+ /* FIXME: maybe this should be an assertion in case the channel
+ * isn't closed early enough right now? */
+ if (state > JS_STATE_ACTIVE)
+ {
+ gabble_debug (DEBUG_FLAG, "state > JS_STATE_ACTIVE, doing nothing");
+ return TRUE;
+ }
+
+ candidates = g_value_get_boxed (&priv->native_candidates);
+
+ g_value_init (&candidate, TP_TYPE_CANDIDATE_STRUCT);
+ g_value_take_boxed (&candidate,
+ dbus_g_type_specialized_construct (TP_TYPE_CANDIDATE_STRUCT));
+
+ dbus_g_type_struct_set (&candidate,
+ 0, candidate_id,
+ 1, transports,
+ G_MAXUINT);
+
+ transport = g_ptr_array_index (transports, 0);
+ addr = g_value_get_string (g_value_array_get_nth (transport, 1));
+ if (!strcmp (addr, "127.0.0.1"))
+ {
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_WARNING, "%s: ignoring native localhost candidate",
+ G_STRFUNC);
+ return TRUE;
+ }
+
+ g_ptr_array_add (candidates, g_value_get_boxed (&candidate));
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "put 1 native candidate from stream-engine into cache");
+
+ push_native_candidates (self);
+
+ g_signal_emit (self, signals[NEW_NATIVE_CANDIDATE], 0,
+ candidate_id, transports);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_ready
+ *
+ * Implements D-Bus method Ready
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_ready (GabbleMediaStream *self,
+ const GPtrArray *codecs,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "ready called");
+
+ g_object_set (self, "ready", TRUE, NULL);
+
+ push_remote_codecs (self);
+ push_remote_candidates (self);
+ push_playing (self);
+ push_sending (self);
+
+ return gabble_media_stream_set_local_codecs (self, codecs, error);
+}
+
+
+/**
+ * gabble_media_stream_set_local_codecs
+ *
+ * Implements D-Bus method SetLocalCodecs
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_set_local_codecs (GabbleMediaStream *self,
+ const GPtrArray *codecs,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "putting list of all %d locally supported "
+ "codecs from stream-engine into cache", codecs->len);
+
+ g_value_set_boxed (&priv->native_codecs, codecs);
+
+ g_object_set (self, "got-local-codecs", TRUE, NULL);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_stream_state
+ *
+ * Implements D-Bus method StreamState
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_stream_state (GabbleMediaStream *self,
+ guint connection_state,
+ GError **error)
+{
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ g_object_set (self, "connection-state", connection_state, NULL);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_media_stream_supported_codecs
+ *
+ * Implements D-Bus method SupportedCodecs
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_media_stream_supported_codecs (GabbleMediaStream *self,
+ const GPtrArray *codecs,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (self));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "got codec intersection containing %d "
+ "codecs from stream-engine", codecs->len);
+
+ /* store the intersection for later on */
+ g_value_set_boxed (&priv->native_codecs, codecs);
+
+ g_signal_emit (self, signals[SUPPORTED_CODECS], 0, codecs);
+
+ return TRUE;
+}
+
+static LmHandlerResult
+candidates_msg_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleMediaStream *stream = GABBLE_MEDIA_STREAM (object);
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL (priv->session, "candidates failed");
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+_add_rtp_candidate_node (GabbleMediaSession *session, LmMessageNode *parent,
+ GValueArray *candidate)
+{
+ gchar *addr;
+ gchar *user;
+ gchar *pass;
+ gchar *port_str;
+ gchar *pref_str;
+ gchar *xml;
+ const gchar *type_str;
+ const gchar *candidate_id;
+ guint port;
+ gdouble pref;
+ TpMediaStreamProto proto;
+ TpMediaStreamTransportType type;
+ const GPtrArray *transports;
+ GValue transport = { 0, };
+ LmMessageNode *cand_node;
+
+ candidate_id = g_value_get_string (g_value_array_get_nth (candidate, 0));
+ transports = g_value_get_boxed (g_value_array_get_nth (candidate, 1));
+
+ /* jingle audio only supports the concept of one transport per candidate */
+ g_assert (transports->len == 1);
+
+ g_value_init (&transport, TP_TYPE_TRANSPORT_STRUCT);
+ g_value_set_static_boxed (&transport, g_ptr_array_index (transports, 0));
+
+ dbus_g_type_struct_get (&transport,
+ 1, &addr,
+ 2, &port,
+ 3, &proto,
+ 6, &pref,
+ 7, &type,
+ 8, &user,
+ 9, &pass,
+ G_MAXUINT);
+
+ port_str = g_strdup_printf ("%d", port);
+ pref_str = g_strdup_printf ("%f", pref);
+
+ switch (type) {
+ case TP_MEDIA_STREAM_TRANSPORT_TYPE_LOCAL:
+ type_str = "local";
+ break;
+ case TP_MEDIA_STREAM_TRANSPORT_TYPE_DERIVED:
+ type_str = "stun";
+ break;
+ case TP_MEDIA_STREAM_TRANSPORT_TYPE_RELAY:
+ type_str = "relay";
+ break;
+ default:
+ g_error ("%s: TpMediaStreamTransportType has an invalid value",
+ G_STRFUNC);
+ return;
+ }
+
+ cand_node = lm_message_node_add_child (parent, "candidate", NULL);
+ lm_message_node_set_attributes (cand_node,
+ "name", "rtp",
+ "address", addr,
+ "port", port_str,
+ "username", user,
+ "password", pass,
+ "preference", pref_str,
+ "protocol", (proto == TP_MEDIA_STREAM_PROTO_UDP) ? "udp" : "tcp",
+ "type", type_str,
+ "network", "0",
+ "generation", "0",
+ NULL);
+
+ xml = lm_message_node_to_string (cand_node);
+ _gabble_media_session_debug (session, DEBUG_MSG_DUMP,
+ " from Telepathy D-Bus struct: [%s\"%s\", %s[%s1, \"%s\", %d, %s, "
+ "\"%s\", \"%s\", %f, %s, \"%s\", \"%s\"%s]]",
+ ANSI_BOLD_OFF, candidate_id, ANSI_BOLD_ON, ANSI_BOLD_OFF, addr, port,
+ tp_protocols[proto], "RTP", "AVP", pref, tp_transports[type], user, pass,
+ ANSI_BOLD_ON);
+ _gabble_media_session_debug (session, DEBUG_MSG_DUMP,
+ " to Jingle XML: [%s%s%s]", ANSI_BOLD_OFF, xml, ANSI_BOLD_ON);
+ g_free (xml);
+
+ g_free (addr);
+ g_free (user);
+ g_free (pass);
+ g_free (port_str);
+ g_free (pref_str);
+}
+
+static LmMessage *
+_gabble_media_stream_message_new (GabbleMediaStream *stream,
+ const gchar *action,
+ LmMessageNode **content_node)
+{
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+ LmMessage *msg;
+ LmMessageNode *session_node = NULL;
+
+ /* construct a session message */
+ msg = _gabble_media_session_message_new (priv->session, action,
+ &session_node);
+
+ /* add our content node to it if necessary */
+ *content_node = _gabble_media_stream_add_content_node (stream, session_node);
+
+ return msg;
+}
+
+
+static void
+push_candidate (GabbleMediaStream *stream, GValueArray *candidate)
+{
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+ LmMessage *msg;
+ LmMessageNode *content_node, *transport_node;
+ const gchar *action;
+
+ if (priv->mode == MODE_GOOGLE)
+ action = "candidates";
+ else
+ action = "transport-info";
+
+ /* construct a base message */
+ msg = _gabble_media_stream_message_new (stream, action, &content_node);
+
+ /* for jingle, add a transport */
+ transport_node = _gabble_media_stream_content_node_add_transport (stream,
+ content_node);
+
+ /* add transport info to it */
+ _add_rtp_candidate_node (priv->session, transport_node, candidate);
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "sending jingle session action \"%s\" to "
+ "peer", action);
+
+ /* send it */
+ _gabble_connection_send_with_reply (priv->conn, msg, candidates_msg_reply_cb,
+ G_OBJECT (stream), NULL, NULL);
+
+ /* clean up */
+ lm_message_unref (msg);
+}
+
+static void
+push_native_candidates (GabbleMediaStream *stream)
+{
+ GabbleMediaStreamPrivate *priv;
+ GPtrArray *candidates;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ if (stream->signalling_state == STREAM_SIG_STATE_NEW ||
+ stream->signalling_state == STREAM_SIG_STATE_REMOVING)
+ return;
+
+ candidates = g_value_get_boxed (&priv->native_candidates);
+
+ for (i = 0; i < candidates->len; i++)
+ push_candidate (stream, g_ptr_array_index (candidates, i));
+
+ g_value_take_boxed (&priv->native_candidates,
+ dbus_g_type_specialized_construct (TP_TYPE_CANDIDATE_LIST));
+}
+
+void
+_gabble_media_stream_close (GabbleMediaStream *stream)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ if (!priv->closed)
+ {
+ priv->closed = TRUE;
+ g_signal_emit (stream, signals[CLOSE], 0);
+ }
+}
+
+gboolean
+_gabble_media_stream_post_remote_codecs (GabbleMediaStream *stream,
+ LmMessage *message,
+ LmMessageNode *desc_node,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+ LmMessageNode *node;
+ GPtrArray *codecs;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ codecs = g_value_get_boxed (&priv->remote_codecs);
+
+ g_assert (codecs->len == 0);
+
+ for (node = desc_node->children; node; node = node->next)
+ {
+ guchar id;
+ const gchar *name, *str;
+ guint clockrate, channels;
+ GHashTable *params;
+ GValue codec = { 0, };
+
+ if (g_strdiff (node->name, "payload-type"))
+ continue;
+
+ /* id of codec */
+ str = lm_message_node_get_attribute (node, "id");
+ if (str == NULL)
+ {
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "description has no ID");
+ return FALSE;
+ }
+
+ id = atoi(str);
+
+ /* codec name */
+ name = lm_message_node_get_attribute (node, "name");
+ if (name == NULL)
+ {
+ name = "";
+ }
+
+ /* clock rate: jingle and newer GTalk */
+ str = lm_message_node_get_attribute (node, "clockrate"); /* google */
+ if (str == NULL)
+ str = lm_message_node_get_attribute (node, "rate"); /* jingle */
+
+ if (str != NULL)
+ {
+ clockrate = atoi (str);
+ }
+ else
+ {
+ clockrate = 0;
+ }
+
+ /* number of channels: jingle only */
+ str = lm_message_node_get_attribute (node, "channels");
+ if (str != NULL)
+ {
+ channels = atoi (str);
+ }
+ else
+ {
+ channels = 1;
+ }
+
+ params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
+
+ /* bitrate: newer GTalk only */
+ str = lm_message_node_get_attribute (node, "bitrate");
+ if (str != NULL)
+ {
+ g_hash_table_insert (params, "bitrate", g_strdup (str));
+ }
+
+ g_value_init (&codec, TP_TYPE_CODEC_STRUCT);
+ g_value_take_boxed (&codec,
+ dbus_g_type_specialized_construct (TP_TYPE_CODEC_STRUCT));
+
+ dbus_g_type_struct_set (&codec,
+ 0, id,
+ 1, name,
+ 2, TP_CODEC_MEDIA_TYPE_AUDIO,
+ 3, clockrate,
+ 4, channels,
+ 5, params,
+ G_MAXUINT);
+
+ g_ptr_array_add (codecs, g_value_get_boxed (&codec));
+ }
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "put %d remote codecs from peer into cache",
+ codecs->len);
+
+ push_remote_codecs (stream);
+
+ return TRUE;
+}
+
+static void
+push_remote_codecs (GabbleMediaStream *stream)
+{
+ GabbleMediaStreamPrivate *priv;
+ GPtrArray *codecs;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ if (!priv->ready)
+ return;
+
+ codecs = g_value_get_boxed (&priv->remote_codecs);
+ if (codecs->len == 0)
+ return;
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_EVENT, "passing %d remote codecs to stream-engine",
+ codecs->len);
+
+ g_signal_emit (stream, signals[SET_REMOTE_CODECS], 0, codecs);
+
+ g_value_take_boxed (&priv->remote_codecs,
+ dbus_g_type_specialized_construct (TP_TYPE_CODEC_LIST));
+}
+
+gboolean
+_gabble_media_stream_post_remote_candidates (GabbleMediaStream *stream,
+ LmMessage *message,
+ LmMessageNode *transport_node,
+ GError **error)
+{
+ GabbleMediaStreamPrivate *priv;
+ LmMessageNode *node;
+ const gchar *str;
+ GPtrArray *candidates;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ candidates = g_value_get_boxed (&priv->remote_candidates);
+
+ for (node = transport_node->children; node; node = node->next)
+ {
+ gchar *candidate_id;
+ const gchar *name, *addr;
+ guint16 port;
+ TpMediaStreamProto proto;
+ gdouble pref;
+ TpMediaStreamTransportType type;
+ const gchar *user, *pass;
+ guchar net, gen;
+ GValue candidate = { 0, };
+ GPtrArray *transports;
+ GValue transport = { 0, };
+ gchar *xml;
+
+ if (g_strdiff (node->name, "candidate"))
+ continue;
+
+ /*
+ * Candidate
+ */
+
+ /* stream name */
+ name = lm_message_node_get_attribute (node, "name");
+ if (name == NULL || strcmp (name, "rtp") != 0)
+ goto FAILURE;
+
+
+ /*
+ * Transport
+ */
+
+ /* ip address */
+ addr = lm_message_node_get_attribute (node, "address");
+ if (addr == NULL)
+ goto FAILURE;
+
+ /* port */
+ str = lm_message_node_get_attribute (node, "port");
+ if (str == NULL)
+ goto FAILURE;
+ port = atoi (str);
+
+ /* protocol */
+ str = lm_message_node_get_attribute (node, "protocol");
+ if (str == NULL)
+ goto FAILURE;
+
+ if (strcmp (str, "udp") == 0)
+ {
+ proto = TP_MEDIA_STREAM_PROTO_UDP;
+ }
+ else if (strcmp (str, "tcp") == 0)
+ {
+ proto = TP_MEDIA_STREAM_PROTO_TCP;
+ }
+ else if (strcmp (str, "ssltcp") == 0)
+ {
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_WARNING, "%s: ssltcp candidates "
+ "not yet supported", G_STRFUNC);
+ continue;
+ }
+ else
+ goto FAILURE;
+
+ /* protocol profile: hardcoded to "AVP" for now */
+
+ /* preference */
+ str = lm_message_node_get_attribute (node, "preference");
+ if (str == NULL)
+ goto FAILURE;
+ pref = g_ascii_strtod (str, NULL);
+
+ /* type */
+ str = lm_message_node_get_attribute (node, "type");
+ if (str == NULL)
+ goto FAILURE;
+
+ if (strcmp (str, "local") == 0)
+ {
+ type = TP_MEDIA_STREAM_TRANSPORT_TYPE_LOCAL;
+ }
+ else if (strcmp (str, "stun") == 0)
+ {
+ type = TP_MEDIA_STREAM_TRANSPORT_TYPE_DERIVED;
+ }
+ else if (strcmp (str, "relay") == 0)
+ {
+ type = TP_MEDIA_STREAM_TRANSPORT_TYPE_RELAY;
+ }
+ else
+ goto FAILURE;
+
+ /* username */
+ user = lm_message_node_get_attribute (node, "username");
+ if (user == NULL)
+ goto FAILURE;
+
+ /* password */
+ pass = lm_message_node_get_attribute (node, "password");
+ if (pass == NULL)
+ goto FAILURE;
+
+ /* unknown */
+ str = lm_message_node_get_attribute (node, "network");
+ if (str == NULL)
+ goto FAILURE;
+ net = atoi (str);
+
+ /* unknown */
+ str = lm_message_node_get_attribute (node, "generation");
+ if (str == NULL)
+ goto FAILURE;
+ gen = atoi (str);
+
+
+ g_value_init (&transport, TP_TYPE_TRANSPORT_STRUCT);
+ g_value_take_boxed (&transport,
+ dbus_g_type_specialized_construct (TP_TYPE_TRANSPORT_STRUCT));
+
+ dbus_g_type_struct_set (&transport,
+ 0, 1, /* component number */
+ 1, addr,
+ 2, port,
+ 3, proto,
+ 4, "RTP",
+ 5, "AVP",
+ 6, pref,
+ 7, type,
+ 8, user,
+ 9, pass,
+ G_MAXUINT);
+
+ transports = g_ptr_array_sized_new (1);
+ g_ptr_array_add (transports, g_value_get_boxed (&transport));
+
+
+ g_value_init (&candidate, TP_TYPE_CANDIDATE_STRUCT);
+ g_value_take_boxed (&candidate,
+ dbus_g_type_specialized_construct (TP_TYPE_CANDIDATE_STRUCT));
+
+ /* FIXME: is this naming scheme sensible? */
+ candidate_id = g_strdup_printf ("R%d", ++priv->remote_candidate_count);
+
+ dbus_g_type_struct_set (&candidate,
+ 0, candidate_id,
+ 1, transports,
+ G_MAXUINT);
+
+ g_ptr_array_add (candidates, g_value_get_boxed (&candidate));
+
+ xml = lm_message_node_to_string (node);
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "put 1 remote candidate from peer into cache");
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_DUMP, " from Jingle XML: [%s%s%s]",
+ ANSI_BOLD_OFF, xml, ANSI_BOLD_ON);
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_DUMP, " to Telepathy D-Bus struct: [%s\"%s\", %s[%s1, \"%s\", %d, %s, \"%s\", \"%s\", %f, %s, \"%s\", \"%s\"%s]]",
+ ANSI_BOLD_OFF, candidate_id, ANSI_BOLD_ON,
+ ANSI_BOLD_OFF, addr, port, tp_protocols[proto], "RTP", "AVP", pref, tp_transports[type], user, pass, ANSI_BOLD_ON);
+ g_free (xml);
+
+ g_free (candidate_id);
+ }
+
+/*SUCCESS:*/
+ push_remote_candidates (stream);
+
+ return TRUE;
+
+FAILURE:
+ g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_BAD_REQUEST,
+ "unable to parse candidate");
+
+ return FALSE;
+}
+
+static void
+push_remote_candidates (GabbleMediaStream *stream)
+{
+ GabbleMediaStreamPrivate *priv;
+ GPtrArray *candidates;
+ guint i;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ candidates = g_value_get_boxed (&priv->remote_candidates);
+
+ if (candidates->len == 0)
+ return;
+
+ if (!priv->ready)
+ return;
+
+ for (i = 0; i < candidates->len; i++)
+ {
+ GValueArray *candidate = g_ptr_array_index (candidates, i);
+ const gchar *candidate_id;
+ const GPtrArray *transports;
+
+ candidate_id = g_value_get_string (g_value_array_get_nth (candidate, 0));
+ transports = g_value_get_boxed (g_value_array_get_nth (candidate, 1));
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_EVENT, "passing 1 remote candidate "
+ "to stream-engine");
+
+ g_signal_emit (stream, signals[ADD_REMOTE_CANDIDATE], 0,
+ candidate_id, transports);
+ }
+
+ g_value_take_boxed (&priv->remote_candidates,
+ dbus_g_type_specialized_construct (TP_TYPE_CANDIDATE_LIST));
+}
+
+static void
+push_playing (GabbleMediaStream *stream)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ if (!priv->ready)
+ return;
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "stream %s emitting SetStreamPlaying(%s)",
+ stream->name, stream->playing ? "true" : "false");
+
+ g_signal_emit (stream, signals[SET_STREAM_PLAYING], 0, stream->playing);
+}
+
+static void
+push_sending (GabbleMediaStream *stream)
+{
+ GabbleMediaStreamPrivate *priv;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ if (!priv->ready)
+ return;
+
+ _gabble_media_session_debug (priv->session, DEBUG_MSG_INFO, DEBUG_MSG_INFO, "stream %s emitting SetStreamSending(%s)",
+ stream->name, priv->sending ? "true" : "false");
+
+ g_signal_emit (stream, signals[SET_STREAM_SENDING], 0, priv->sending);
+}
+
+/*
+ * oh sweet g_hash_table_foreach how beautiful thou be'st
+ *
+ * _\ / ^/
+ * \/ \// 7_ __
+ * ( 7 ) (__) (__)
+ * ^\\ |/__/___/
+ * \\/_/ | <-- TP-cable kindly provided by Mika N.
+ * \ / O
+ * || /|\
+ * || / \
+ * ||
+ * ____||_____________
+ */
+
+typedef struct {
+ GabbleMediaStreamPrivate *priv;
+ LmMessageNode *pt_node;
+} CodecParamsFromTpContext;
+
+//#ifndef EMULATOR
+static const gchar *video_codec_params[] = {
+ "x", "y", "width", "height", "layer", "transparent",
+};
+//#endif
+
+static void
+codec_params_from_tp_foreach (gpointer key, gpointer value, gpointer user_data)
+{
+ CodecParamsFromTpContext *ctx = user_data;
+ GabbleMediaStreamPrivate *priv = ctx->priv;
+ const gchar *pname = key, *pvalue = value;
+
+ if (priv->media_type == TP_CODEC_MEDIA_TYPE_AUDIO)
+ {
+ if (priv->mode == MODE_GOOGLE && strcmp (pname, "bitrate") == 0)
+ {
+ lm_message_node_set_attribute (ctx->pt_node, pname, pvalue);
+ return;
+ }
+ }
+ else if (priv->mode == MODE_JINGLE)
+ {
+ gint i;
+
+ for (i = 0; video_codec_params[i] != NULL; i++)
+ {
+ if (strcmp (pname, video_codec_params[i]) == 0)
+ {
+ lm_message_node_set_attribute (ctx->pt_node, pname, pvalue);
+ return;
+ }
+ }
+ }
+
+ gabble_debug (DEBUG_FLAG, "ignoring %s=%s for %s %s stream", pname, pvalue,
+ (priv->mode == MODE_JINGLE) ? "jingle" : "google",
+ (priv->media_type == TP_CODEC_MEDIA_TYPE_AUDIO) ? "audio" : "video");
+}
+
+LmMessageNode *
+_gabble_media_stream_add_content_node (GabbleMediaStream *stream,
+ LmMessageNode *session_node)
+{
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+ LmMessageNode *node = session_node;
+
+ /* add our content node to it if in jingle mode */
+ if (priv->mode == MODE_JINGLE)
+ {
+ node = lm_message_node_add_child (session_node, "content", NULL);
+ lm_message_node_set_attribute (node, "name", stream->name);
+
+ if (priv->session->initiator == stream->initiator)
+ lm_message_node_set_attribute (node, "creator", "initiator");
+ else
+ lm_message_node_set_attribute (node, "creator", "responder");
+ }
+
+ return node;
+}
+
+void
+_gabble_media_stream_content_node_add_description (GabbleMediaStream *stream,
+ LmMessageNode *content_node)
+{
+ GabbleMediaStreamPrivate *priv;
+ const GPtrArray *codecs;
+ LmMessageNode *desc_node;
+ guint i;
+ const gchar *xmlns;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ codecs = g_value_get_boxed (&priv->native_codecs);
+
+ desc_node = lm_message_node_add_child (content_node, "description", NULL);
+
+ if (priv->mode == MODE_GOOGLE)
+ xmlns = NS_GOOGLE_SESSION_PHONE;
+ else if (priv->media_type == TP_CODEC_MEDIA_TYPE_VIDEO)
+ xmlns = NS_JINGLE_DESCRIPTION_VIDEO;
+ else
+ xmlns = NS_JINGLE_DESCRIPTION_AUDIO;
+
+ lm_message_node_set_attribute (desc_node, "xmlns", xmlns);
+
+ for (i = 0; i < codecs->len; i++)
+ {
+ GValue codec = { 0, };
+ guint id, clock_rate, channels;
+ gchar *name, buf[16];
+ GHashTable *params;
+ LmMessageNode *pt_node;
+ CodecParamsFromTpContext ctx;
+
+ g_value_init (&codec, TP_TYPE_CODEC_STRUCT);
+ g_value_set_static_boxed (&codec, g_ptr_array_index (codecs, i));
+
+ dbus_g_type_struct_get (&codec,
+ 0, &id,
+ 1, &name,
+ 3, &clock_rate,
+ 4, &channels,
+ 5, ¶ms,
+ G_MAXUINT);
+
+ /* create a sub-node called "payload-type" and fill it */
+ pt_node = lm_message_node_add_child (desc_node, "payload-type", NULL);
+
+ /* id: required */
+ sprintf (buf, "%u", id);
+ lm_message_node_set_attribute (pt_node, "id", buf);
+
+ /* name: optional */
+ if (*name != '\0')
+ {
+ lm_message_node_set_attribute (pt_node, "name", name);
+ }
+
+ /* clock rate: optional */
+ if (clock_rate != 0)
+ {
+ sprintf (buf, "%u", clock_rate);
+ lm_message_node_set_attribute (pt_node,
+ (priv->mode == MODE_GOOGLE) ? "clockrate" : "rate", buf);
+ }
+
+ /* number of channels: optional, jingle only */
+ /* FIXME: is it? */
+ if (channels != 0 && priv->mode == MODE_JINGLE)
+ {
+ sprintf (buf, "%u", channels);
+ lm_message_node_set_attribute (pt_node, "channels", buf);
+ }
+
+ /* parse the optional params */
+ ctx.priv = priv;
+ ctx.pt_node = pt_node;
+ g_hash_table_foreach (params, codec_params_from_tp_foreach, &ctx);
+
+ /* clean up */
+ g_free (name);
+ g_hash_table_destroy (params);
+ }
+}
+
+LmMessageNode *
+_gabble_media_stream_content_node_add_transport (GabbleMediaStream *stream,
+ LmMessageNode *content_node)
+{
+ GabbleMediaStreamPrivate *priv;
+ LmMessageNode *node;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ if (priv->mode != MODE_JINGLE)
+ return content_node;
+
+ node = lm_message_node_add_child (content_node, "transport", NULL);
+
+ lm_message_node_set_attribute (node, "xmlns", NS_GOOGLE_TRANSPORT_P2P);
+
+ return node;
+}
+
+void
+_gabble_media_stream_update_sending (GabbleMediaStream *stream,
+ gboolean start_sending)
+{
+ GabbleMediaStreamPrivate *priv;
+ gboolean new_sending;
+
+ g_assert (GABBLE_IS_MEDIA_STREAM (stream));
+
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
+
+ new_sending =
+ ((stream->combined_direction & TP_MEDIA_STREAM_DIRECTION_SEND) != 0);
+
+ if (priv->sending == new_sending)
+ return;
+
+ if (new_sending && !start_sending)
+ return;
+
+ priv->sending = new_sending;
+ push_sending (stream);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-muc-channel-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,106 @@
+/*
+ * gabble-muc-channel-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:UINT,UINT (gabble-muc-channel-signals-marshal.list:1) */
+void
+gabble_muc_channel_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-muc-channel.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,3061 @@
+/*
+ * gabble-muc-channel.c - Source for GabbleMucChannel
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+#include "ansi.h"
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "gabble-error.h"
+#include "namespaces.h"
+#include "util.h"
+
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "telepathy-interfaces.h"
+#include "tp-channel-iface.h"
+
+#include "gabble-muc-channel.h"
+#include "gabble-muc-channel-signals-marshal.h"
+
+#include "gabble-muc-channel-glue.h"
+
+#include "gabble_enums.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_MUC
+#define DEFAULT_JOIN_TIMEOUT (180 * 1000)
+#define MAX_NICK_RETRIES 3
+
+#define PROPS_POLL_INTERVAL_LOW (60 * 1000 * 5)
+#define PROPS_POLL_INTERVAL_HIGH (60 * 1000)
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleMucChannel, gabble_muc_channel,
+ G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+#endif
+/* signal enum */
+enum
+{
+ READY,
+ JOIN_ERROR,
+ CLOSED,
+ PASSWORD_FLAGS_CHANGED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_MUC
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_muc,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_muc, s)())
+
+
+ GET_STATIC_VAR_FROM_TLS(gabble_muc_channel_parent_class,gabble_muc,gpointer)
+ #define gabble_muc_channel_parent_class (*GET_WSD_VAR_NAME(gabble_muc_channel_parent_class,gabble_muc,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_muc,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_muc,s)())
+
+
+ /*gchar** _s_gabble_muc_muc_roles() { return (gchar**)((libgabble_ImpurePtr()->_s_gabble_muc_muc_roles)); }
+
+ #define muc_roles (GET_WSD_VAR_NAME(muc_roles,gabble_muc, s)())
+
+
+ gchar** _s_gabble_muc_muc_affiliations() { return (gchar**)((libgabble_ImpurePtr()->_s_gabble_muc_muc_affiliations)); }
+
+ #define muc_affiliations (GET_WSD_VAR_NAME(muc_affiliations,gabble_muc, s)())*/
+
+
+static void gabble_muc_channel_init (GabbleMucChannel *self);
+static void gabble_muc_channel_class_init (GabbleMucChannelClass *klass);
+static void gabble_muc_channel_class_intern_init (gpointer klass)
+{
+ gabble_muc_channel_parent_class = g_type_class_peek_parent (klass);
+ gabble_muc_channel_class_init ((GabbleMucChannelClass*) klass);
+}
+EXPORT_C GType gabble_muc_channel_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ {
+ static const GTypeInfo g_define_type_info = { sizeof (GabbleMucChannelClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_muc_channel_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleMucChannel), 0, (GInstanceInitFunc) gabble_muc_channel_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleMucChannel"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) ((void *)0) }; g_type_add_interface_static (g_define_type_id, tp_channel_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id;
+ };
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_CHANNEL_TYPE,
+ PROP_HANDLE_TYPE,
+ PROP_HANDLE,
+ PROP_CONNECTION,
+ PROP_STATE,
+ PROP_INVITE_SELF,
+ LAST_PROPERTY
+};
+
+typedef enum {
+ MUC_STATE_CREATED = 0,
+ MUC_STATE_INITIATED,
+ MUC_STATE_AUTH,
+ MUC_STATE_JOINED,
+ MUC_STATE_ENDED,
+} GabbleMucState;
+
+#define ENABLE_DEBUG
+#ifdef ENABLE_DEBUG
+static const gchar *muc_states[] =
+{
+ "MUC_STATE_CREATED",
+ "MUC_STATE_INITIATED",
+ "MUC_STATE_AUTH",
+ "MUC_STATE_JOINED",
+ "MUC_STATE_ENDED",
+};
+#endif
+
+/* role and affiliation enums */
+typedef enum {
+ ROLE_NONE = 0,
+ ROLE_VISITOR,
+ ROLE_PARTICIPANT,
+ ROLE_MODERATOR,
+
+ NUM_ROLES,
+
+ INVALID_ROLE,
+} GabbleMucRole;
+
+typedef enum {
+ AFFILIATION_NONE = 0,
+ AFFILIATION_MEMBER,
+ AFFILIATION_ADMIN,
+ AFFILIATION_OWNER,
+
+ NUM_AFFILIATIONS,
+
+ INVALID_AFFILIATION,
+} GabbleMucAffiliation;
+
+//#ifndef EMULATOR
+
+static const gchar *muc_roles[NUM_ROLES] =
+{
+ "none",
+ "visitor",
+ "participant",
+ "moderator",
+};
+
+static const gchar *muc_affiliations[NUM_AFFILIATIONS] =
+{
+ "none",
+ "member",
+ "admin",
+ "owner",
+};
+
+//#endif
+
+/* room properties */
+enum
+{
+ ROOM_PROP_ANONYMOUS = 0,
+ ROOM_PROP_INVITE_ONLY,
+ ROOM_PROP_MODERATED,
+ ROOM_PROP_NAME,
+ ROOM_PROP_DESCRIPTION,
+ ROOM_PROP_PASSWORD,
+ ROOM_PROP_PASSWORD_REQUIRED,
+ ROOM_PROP_PERSISTENT,
+ ROOM_PROP_PRIVATE,
+ ROOM_PROP_SUBJECT,
+ ROOM_PROP_SUBJECT_CONTACT,
+ ROOM_PROP_SUBJECT_TIMESTAMP,
+
+ NUM_ROOM_PROPS,
+
+ INVALID_ROOM_PROP,
+};
+
+const GabblePropertySignature room_property_signatures[NUM_ROOM_PROPS] = {
+ { "anonymous", G_TYPE_BOOLEAN }, /* impl: READ, WRITE */
+ { "invite-only", G_TYPE_BOOLEAN }, /* impl: READ, WRITE */
+ { "moderated", G_TYPE_BOOLEAN }, /* impl: READ, WRITE */
+ { "name", G_TYPE_STRING }, /* impl: READ, WRITE */
+ { "description", G_TYPE_STRING }, /* impl: READ, WRITE */
+ { "password", G_TYPE_STRING }, /* impl: WRITE */
+ { "password-required", G_TYPE_BOOLEAN }, /* impl: READ, WRITE */
+ { "persistent", G_TYPE_BOOLEAN }, /* impl: READ, WRITE */
+ { "private", G_TYPE_BOOLEAN }, /* impl: READ, WRITE */
+ { "subject", G_TYPE_STRING }, /* impl: READ, WRITE */
+ { "subject-contact", G_TYPE_UINT }, /* impl: READ */
+ { "subject-timestamp", G_TYPE_UINT }, /* impl: READ */
+};
+
+/* private structures */
+
+typedef struct _GabbleMucChannelPrivate GabbleMucChannelPrivate;
+
+struct _GabbleMucChannelPrivate
+{
+ GabbleConnection *conn;
+ gchar *object_path;
+
+ GabbleMucState state;
+
+ guint join_timer_id;
+ guint poll_timer_id;
+
+ TpChannelPasswordFlags password_flags;
+ DBusGMethodInvocation *password_ctx;
+ gchar *password;
+
+ GabbleHandle handle;
+ const gchar *jid;
+
+ guint nick_retry_count;
+ GString *self_jid;
+ GabbleMucRole self_role;
+ GabbleMucAffiliation self_affil;
+
+ guint recv_id;
+
+ GabblePropertiesContext *properties_ctx;
+
+ gboolean ready_emitted;
+
+ gboolean closed;
+ gboolean dispose_has_run;
+
+ gboolean invite_self;
+};
+
+#define GABBLE_MUC_CHANNEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GABBLE_TYPE_MUC_CHANNEL, GabbleMucChannelPrivate))
+
+static void
+gabble_muc_channel_init (GabbleMucChannel *obj)
+{
+ /* do nothing? */
+}
+
+static void contact_handle_to_room_identity (GabbleMucChannel *, GabbleHandle, GabbleHandle *, GString **);
+
+static GObject *
+gabble_muc_channel_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleMucChannelPrivate *priv;
+ DBusGConnection *bus;
+ GabbleHandleRepo *handles;
+ GabbleHandle self_handle;
+ gboolean valid;
+
+ obj = G_OBJECT_CLASS (gabble_muc_channel_parent_class)->
+ constructor (type, n_props, props);
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (obj);
+
+ handles = priv->conn->handles;
+
+ /* ref our room handle */
+ valid = gabble_handle_ref (handles, TP_HANDLE_TYPE_ROOM, priv->handle);
+ g_assert (valid);
+
+ /* get the room's jid */
+ priv->jid = gabble_handle_inspect (handles, TP_HANDLE_TYPE_ROOM, priv->handle);
+
+ /* get our own identity in the room */
+ contact_handle_to_room_identity (GABBLE_MUC_CHANNEL (obj), priv->conn->self_handle,
+ &self_handle, &priv->self_jid);
+
+ valid = gabble_handle_ref (handles, TP_HANDLE_TYPE_CONTACT, self_handle);
+ g_assert (valid);
+
+ /* initialize our own role and affiliation */
+ priv->self_role = ROLE_NONE;
+ priv->self_affil = AFFILIATION_NONE;
+
+ /* register object on the bus */
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ /* initialize group mixin */
+ gabble_group_mixin_init (obj, G_STRUCT_OFFSET (GabbleMucChannel, group),
+ handles, self_handle);
+
+ /* set initial group flags */
+ gabble_group_mixin_change_flags (obj,
+ TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES |
+ TP_CHANNEL_GROUP_FLAG_CAN_ADD,
+ 0);
+
+ /* initialize properties mixin */
+ gabble_properties_mixin_init (obj, G_STRUCT_OFFSET (
+ GabbleMucChannel, properties));
+
+ /* initialize text mixin */
+ gabble_text_mixin_init (obj, G_STRUCT_OFFSET (GabbleMucChannel, text), handles, FALSE);
+
+ gabble_text_mixin_set_message_types (obj,
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
+ G_MAXUINT);
+
+ /* add ourselves to group mixin if needed */
+ if (priv->invite_self)
+ {
+ GError *error = NULL;
+ GArray *members = g_array_sized_new (FALSE, FALSE, sizeof (GabbleHandle), 1);
+ g_array_append_val (members, self_handle);
+ gabble_group_mixin_add_members (obj, members, "", &error);
+ g_assert (error == NULL);
+ g_array_free (members, TRUE);
+ }
+ return obj;
+}
+
+static void
+properties_disco_cb (GabbleDisco *disco,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *query_result,
+ GError *error,
+ gpointer user_data)
+{
+ GabbleMucChannel *chan = user_data;
+ GabbleMucChannelPrivate *priv;
+ GArray *changed_props_val, *changed_props_flags;
+ LmMessageNode *lm_node;
+ const gchar *str;
+ GValue val = { 0, };
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (error)
+ {
+ gabble_debug (DEBUG_FLAG, "got error %s", error->message);
+ return;
+ }
+
+ NODE_DEBUG (query_result, "disco query result");
+
+ changed_props_val = changed_props_flags = NULL;
+
+
+ /*
+ * Update room definition.
+ */
+
+ /* ROOM_PROP_NAME */
+ lm_node = lm_message_node_get_child (query_result, "identity");
+ if (lm_node)
+ {
+ const gchar *type, *category, *name;
+
+ type = lm_message_node_get_attribute (lm_node, "type");
+ category = lm_message_node_get_attribute (lm_node, "category");
+ name = lm_message_node_get_attribute (lm_node, "name");
+
+ if (NULL != type && 0 == strcmp (type, "text") &&
+ NULL != category && 0 == strcmp (category, "conference") &&
+ NULL != name)
+ {
+ g_value_init (&val, G_TYPE_STRING);
+ g_value_set_string (&val, name);
+
+ gabble_properties_mixin_change_value (G_OBJECT (chan), ROOM_PROP_NAME,
+ &val, &changed_props_val);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan), ROOM_PROP_NAME,
+ TP_PROPERTY_FLAG_READ,
+ 0, &changed_props_flags);
+
+ g_value_unset (&val);
+ }
+ }
+
+ for (lm_node = query_result->children; lm_node; lm_node = lm_node->next)
+ {
+ guint prop_id = INVALID_ROOM_PROP;
+
+ if (strcmp (lm_node->name, "feature") == 0)
+ {
+ str = lm_message_node_get_attribute (lm_node, "var");
+ if (str == NULL)
+ continue;
+
+ /* ROOM_PROP_ANONYMOUS */
+ if (strcmp (str, "muc_nonanonymous") == 0)
+ {
+ prop_id = ROOM_PROP_ANONYMOUS;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, FALSE);
+ }
+ else if (strcmp (str, "muc_semianonymous") == 0 ||
+ strcmp (str, "muc_anonymous") == 0)
+ {
+ prop_id = ROOM_PROP_ANONYMOUS;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, TRUE);
+ }
+
+ /* ROOM_PROP_INVITE_ONLY */
+ else if (strcmp (str, "muc_open") == 0)
+ {
+ prop_id = ROOM_PROP_INVITE_ONLY;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, FALSE);
+ }
+ else if (strcmp (str, "muc_membersonly") == 0)
+ {
+ prop_id = ROOM_PROP_INVITE_ONLY;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, TRUE);
+ }
+
+ /* ROOM_PROP_MODERATED */
+ else if (strcmp (str, "muc_unmoderated") == 0)
+ {
+ prop_id = ROOM_PROP_MODERATED;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, FALSE);
+ }
+ else if (strcmp (str, "muc_moderated") == 0)
+ {
+ prop_id = ROOM_PROP_MODERATED;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, TRUE);
+ }
+
+ /* ROOM_PROP_PASSWORD_REQUIRED */
+ else if (strcmp (str, "muc_unsecure") == 0 ||
+ strcmp (str, "muc_unsecured") == 0)
+ {
+ prop_id = ROOM_PROP_PASSWORD_REQUIRED;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, FALSE);
+ }
+ else if (strcmp (str, "muc_passwordprotected") == 0)
+ {
+ prop_id = ROOM_PROP_PASSWORD_REQUIRED;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, TRUE);
+ }
+
+ /* ROOM_PROP_PERSISTENT */
+ else if (strcmp (str, "muc_temporary") == 0)
+ {
+ prop_id = ROOM_PROP_PERSISTENT;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, FALSE);
+ }
+ else if (strcmp (str, "muc_persistent") == 0)
+ {
+ prop_id = ROOM_PROP_PERSISTENT;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, TRUE);
+ }
+
+ /* ROOM_PROP_PRIVATE */
+ else if (strcmp (str, "muc_public") == 0)
+ {
+ prop_id = ROOM_PROP_PRIVATE;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, FALSE);
+ }
+ else if (strcmp (str, "muc_hidden") == 0)
+ {
+ prop_id = ROOM_PROP_PRIVATE;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, TRUE);
+ }
+
+ /* Ignored */
+ else if (strcmp (str, NS_MUC) == 0)
+ {
+ }
+
+ /* Unhandled */
+ else
+ {
+ g_warning ("%s: unhandled feature '%s'", G_STRFUNC, str);
+ }
+ }
+ else if (strcmp (lm_node->name, "x") == 0)
+ {
+ if (lm_message_node_has_namespace (lm_node, NS_X_DATA, NULL))
+ {
+ LmMessageNode *field, *value_node;
+
+ for (field = lm_node->children; field; field = field->next)
+ {
+ if (strcmp (field->name, "field") != 0)
+ continue;
+
+ str = lm_message_node_get_attribute (field, "var");
+ if (str == NULL)
+ continue;
+
+ if (strcmp (str, "muc#roominfo_description") != 0)
+ continue;
+
+ value_node = lm_message_node_get_child (field, "value");
+ if (value_node == NULL)
+ continue;
+
+ str = lm_message_node_get_value (value_node);
+ if (str == NULL)
+ {
+ str = "";
+ }
+
+ prop_id = ROOM_PROP_DESCRIPTION;
+ g_value_init (&val, G_TYPE_STRING);
+ g_value_set_string (&val, str);
+ }
+ }
+ }
+
+ if (prop_id != INVALID_ROOM_PROP)
+ {
+ gabble_properties_mixin_change_value (G_OBJECT (chan), prop_id, &val,
+ &changed_props_val);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan), prop_id,
+ TP_PROPERTY_FLAG_READ,
+ 0, &changed_props_flags);
+
+ g_value_unset (&val);
+ }
+ }
+
+ /*
+ * Emit signals.
+ */
+ gabble_properties_mixin_emit_changed (G_OBJECT (chan), &changed_props_val);
+ gabble_properties_mixin_emit_flags (G_OBJECT (chan), &changed_props_flags);
+}
+
+static void
+room_properties_update (GabbleMucChannel *chan)
+{
+ GabbleMucChannelPrivate *priv;
+ GError *error = NULL;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (gabble_disco_request (priv->conn->disco, GABBLE_DISCO_TYPE_INFO,
+ priv->jid, NULL, properties_disco_cb, chan, G_OBJECT (chan),
+ &error) == NULL)
+ {
+ g_warning ("%s: disco query failed: '%s'", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+contact_handle_to_room_identity (GabbleMucChannel *chan, GabbleHandle main_handle,
+ GabbleHandle *room_handle, GString **room_jid)
+{
+ GabbleMucChannelPrivate *priv;
+ GabbleHandleRepo *handles;
+ const gchar *main_jid;
+ gchar *username, *server;
+ gchar *jid;
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ handles = priv->conn->handles;
+
+ main_jid = gabble_handle_inspect (handles, TP_HANDLE_TYPE_CONTACT,
+ main_handle);
+
+ gabble_decode_jid (main_jid, &username, &server, NULL);
+
+ jid = g_strdup_printf ("%s/%s", priv->jid, username);
+
+ g_free (username);
+ g_free (server);
+
+ if (room_handle)
+ {
+ *room_handle = gabble_handle_for_contact (handles, jid, TRUE);
+ }
+
+ if (room_jid)
+ {
+ *room_jid = g_string_new (jid);
+ }
+
+ g_free (jid);
+}
+
+static gboolean
+send_join_request (GabbleMucChannel *channel,
+ const gchar *password,
+ GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+ LmMessage *msg;
+ LmMessageNode *x_node;
+ gboolean ret;
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (channel);
+
+ /* build the message */
+ msg = lm_message_new (priv->self_jid->str, LM_MESSAGE_TYPE_PRESENCE);
+
+ x_node = lm_message_node_add_child (msg->node, "x", NULL);
+ lm_message_node_set_attribute (x_node, "xmlns", NS_MUC);
+
+ g_free (priv->password);
+
+ if (password != NULL)
+ {
+ priv->password = g_strdup (password);
+ lm_message_node_add_child (x_node, "password", password);
+ }
+
+ /* send it */
+ ret = _gabble_connection_send (priv->conn, msg, error);
+ if (!ret)
+ {
+ g_warning ("%s: _gabble_connection_send_with_reply failed", G_STRFUNC);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "join request sent");
+ }
+
+ lm_message_unref (msg);
+
+ return ret;
+}
+
+static gboolean
+send_leave_message (GabbleMucChannel *channel,
+ const gchar *reason)
+{
+ GabbleMucChannelPrivate *priv;
+ LmMessage *msg;
+ GError *error = NULL;
+ gboolean ret;
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (channel);
+
+ /* build the message */
+ msg = lm_message_new_with_sub_type (priv->self_jid->str,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_MESSAGE_SUB_TYPE_UNAVAILABLE);
+
+ if (reason != NULL)
+ {
+ lm_message_node_add_child (msg->node, "status", reason);
+ }
+
+ /* send it */
+ ret = _gabble_connection_send (priv->conn, msg, &error);
+ if (!ret)
+ {
+ g_warning ("%s: _gabble_connection_send_with_reply failed", G_STRFUNC);
+ g_error_free (error);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "leave message sent");
+ }
+
+ lm_message_unref (msg);
+
+ return ret;
+}
+
+static void
+gabble_muc_channel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMucChannel *chan = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_CHANNEL_TYPE:
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_TEXT);
+ break;
+ case PROP_HANDLE_TYPE:
+ g_value_set_uint (value, TP_HANDLE_TYPE_ROOM);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, priv->handle);
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ case PROP_STATE:
+ g_value_set_uint (value, priv->state);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void channel_state_changed (GabbleMucChannel *chan,
+ GabbleMucState prev_state,
+ GabbleMucState new_state);
+
+static void
+gabble_muc_channel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMucChannel *chan = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+ GabbleMucState prev_state;
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_HANDLE:
+ priv->handle = g_value_get_uint (value);
+ break;
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ case PROP_STATE:
+ prev_state = priv->state;
+ priv->state = g_value_get_uint (value);
+
+ if (priv->state != prev_state)
+ channel_state_changed (chan, prev_state, priv->state);
+
+ break;
+ case PROP_INVITE_SELF:
+ priv->invite_self = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_muc_channel_dispose (GObject *object);
+static void gabble_muc_channel_finalize (GObject *object);
+static gboolean gabble_muc_channel_add_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+static gboolean gabble_muc_channel_remove_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+static gboolean gabble_muc_channel_do_set_properties (GObject *obj, GabblePropertiesContext *ctx, GError **error);
+
+static void
+gabble_muc_channel_class_init (GabbleMucChannelClass *gabble_muc_channel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_muc_channel_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_muc_channel_class, sizeof (GabbleMucChannelPrivate));
+
+ object_class->constructor = gabble_muc_channel_constructor;
+
+ object_class->get_property = gabble_muc_channel_get_property;
+ object_class->set_property = gabble_muc_channel_set_property;
+
+ object_class->dispose = gabble_muc_channel_dispose;
+ object_class->finalize = gabble_muc_channel_finalize;
+
+ g_object_class_override_property (object_class, PROP_OBJECT_PATH, "object-path");
+ g_object_class_override_property (object_class, PROP_CHANNEL_TYPE, "channel-type");
+ g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type");
+ g_object_class_override_property (object_class, PROP_HANDLE, "handle");
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "MUC channel object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ param_spec = g_param_spec_uint ("state", "Channel state",
+ "The current state that the channel is in.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_STATE, param_spec);
+
+ param_spec = g_param_spec_boolean ("invite-self", "Invite self",
+ "Whether the user should be added to members list.",
+ FALSE,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_INVITE_SELF, param_spec);
+
+ signals[READY] =
+ g_signal_new ("ready",
+ G_OBJECT_CLASS_TYPE (gabble_muc_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[JOIN_ERROR] =
+ g_signal_new ("join-error",
+ G_OBJECT_CLASS_TYPE (gabble_muc_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (gabble_muc_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[PASSWORD_FLAGS_CHANGED] =
+ g_signal_new ("password-flags-changed",
+ G_OBJECT_CLASS_TYPE (gabble_muc_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_muc_channel_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ gabble_group_mixin_class_init (object_class,
+ G_STRUCT_OFFSET (GabbleMucChannelClass, group_class),
+ gabble_muc_channel_add_member,
+ gabble_muc_channel_remove_member);
+
+ gabble_properties_mixin_class_init (object_class,
+ G_STRUCT_OFFSET (GabbleMucChannelClass, properties_class),
+ room_property_signatures, NUM_ROOM_PROPS,
+ gabble_muc_channel_do_set_properties);
+
+ gabble_text_mixin_class_init (object_class, G_STRUCT_OFFSET (GabbleMucChannelClass, text_class));
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_muc_channel_class), &dbus_glib_gabble_muc_channel_object_info);
+}
+
+static void clear_join_timer (GabbleMucChannel *chan);
+static void clear_poll_timer (GabbleMucChannel *chan);
+
+void
+gabble_muc_channel_dispose (GObject *object)
+{
+ GabbleMucChannel *self = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "called");
+
+ priv->dispose_has_run = TRUE;
+
+ clear_join_timer (self);
+ clear_poll_timer (self);
+
+ if (G_OBJECT_CLASS (gabble_muc_channel_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_muc_channel_parent_class)->dispose (object);
+}
+
+void
+gabble_muc_channel_finalize (GObject *object)
+{
+ GabbleMucChannel *self = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+ GabbleHandleRepo *handles = priv->conn->handles;
+
+ gabble_debug (DEBUG_FLAG, "called");
+
+ /* free any data held directly by the object here */
+ gabble_handle_unref (handles, TP_HANDLE_TYPE_ROOM, priv->handle);
+
+ g_free (priv->object_path);
+
+ if (priv->self_jid)
+ {
+ g_string_free (priv->self_jid, TRUE);
+ }
+
+ g_free (priv->password);
+
+ gabble_properties_mixin_finalize (object);
+
+ gabble_group_mixin_finalize (object);
+
+ gabble_text_mixin_finalize (object);
+
+ G_OBJECT_CLASS (gabble_muc_channel_parent_class)->finalize (object);
+}
+
+static void clear_join_timer (GabbleMucChannel *chan)
+{
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (priv->join_timer_id != 0)
+ {
+ g_source_remove (priv->join_timer_id);
+ priv->join_timer_id = 0;
+ }
+}
+
+static void clear_poll_timer (GabbleMucChannel *chan)
+{
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (priv->poll_timer_id != 0)
+ {
+ g_source_remove (priv->poll_timer_id);
+ priv->poll_timer_id = 0;
+ }
+}
+
+static void
+change_password_flags (GabbleMucChannel *chan,
+ TpChannelPasswordFlags add,
+ TpChannelPasswordFlags remove)
+{
+ GabbleMucChannelPrivate *priv;
+ TpChannelPasswordFlags added, removed;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ added = add & ~priv->password_flags;
+ priv->password_flags |= added;
+
+ removed = remove & priv->password_flags;
+ priv->password_flags &= ~removed;
+
+ if (add != 0 || remove != 0)
+ {
+ gabble_debug (DEBUG_FLAG, "emitting password flags changed, added 0x%X, removed 0x%X",
+ added, removed);
+
+ g_signal_emit (chan, signals[PASSWORD_FLAGS_CHANGED], 0, added, removed);
+ }
+}
+
+static void
+provide_password_return_if_pending (GabbleMucChannel *chan, gboolean success)
+{
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (priv->password_ctx)
+ {
+ dbus_g_method_return (priv->password_ctx, success);
+ priv->password_ctx = NULL;
+ }
+
+ if (success)
+ {
+ change_password_flags (chan, 0, TP_CHANNEL_PASSWORD_FLAG_PROVIDE);
+ }
+}
+
+static void close_channel (GabbleMucChannel *chan, const gchar *reason, gboolean inform_muc, GabbleHandle actor, guint reason_code);
+
+static gboolean
+timeout_join (gpointer data)
+{
+ GabbleMucChannel *chan = data;
+
+ gabble_debug (DEBUG_FLAG, "join timed out, closing channel");
+
+ provide_password_return_if_pending (chan, FALSE);
+
+ close_channel (chan, NULL, FALSE, 0, 0);
+
+ return FALSE;
+}
+
+static gboolean
+timeout_poll (gpointer data)
+{
+ GabbleMucChannel *chan = data;
+
+ gabble_debug (DEBUG_FLAG, "polling for room properties");
+
+ room_properties_update (chan);
+
+ return TRUE;
+}
+
+static void
+channel_state_changed (GabbleMucChannel *chan,
+ GabbleMucState prev_state,
+ GabbleMucState new_state)
+{
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ gabble_debug (DEBUG_FLAG, "state changed from %s to %s", muc_states[prev_state], muc_states[new_state]);
+
+ if (new_state == MUC_STATE_INITIATED)
+ {
+ priv->join_timer_id =
+ g_timeout_add (DEFAULT_JOIN_TIMEOUT, timeout_join, chan);
+ }
+ else if (new_state == MUC_STATE_JOINED)
+ {
+ gboolean low_bandwidth;
+ gint interval;
+
+ provide_password_return_if_pending (chan, TRUE);
+
+ clear_join_timer (chan);
+
+ g_object_get (priv->conn, "low-bandwidth", &low_bandwidth, NULL);
+
+ if (low_bandwidth)
+ interval = PROPS_POLL_INTERVAL_LOW;
+ else
+ interval = PROPS_POLL_INTERVAL_HIGH;
+
+ priv->poll_timer_id = g_timeout_add (interval, timeout_poll, chan);
+
+ /* no need to keep this around any longer, if it's set */
+ g_free (priv->password);
+ priv->password = NULL;
+ }
+ else if (new_state == MUC_STATE_ENDED)
+ {
+ clear_poll_timer (chan);
+ }
+
+ if (new_state == MUC_STATE_JOINED || new_state == MUC_STATE_AUTH)
+ {
+ if (!priv->ready_emitted)
+ {
+ g_signal_emit (chan, signals[READY], 0);
+
+ priv->ready_emitted = TRUE;
+ }
+ }
+}
+
+
+static void
+close_channel (GabbleMucChannel *chan, const gchar *reason,
+ gboolean inform_muc, GabbleHandle actor, guint reason_code)
+{
+ GabbleMucChannelPrivate *priv;
+ GIntSet *set;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (priv->closed)
+ return;
+
+ priv->closed = TRUE;
+
+ /* Remove us from member list */
+ set = g_intset_new ();
+ g_intset_add (set, GABBLE_GROUP_MIXIN (chan)->self_handle);
+
+ gabble_group_mixin_change_members (G_OBJECT (chan),
+ (reason != NULL) ? reason : "",
+ NULL, set, NULL, NULL, actor,
+ reason_code);
+
+ g_intset_destroy (set);
+
+ /* Inform the MUC if requested */
+ if (inform_muc && priv->state >= MUC_STATE_INITIATED)
+ {
+ send_leave_message (chan, reason);
+ }
+
+ /* Update state and emit Closed signal */
+ g_object_set (chan, "state", MUC_STATE_ENDED, NULL);
+
+ g_signal_emit (chan, signals[CLOSED], 0);
+}
+
+gboolean
+_gabble_muc_channel_is_ready (GabbleMucChannel *chan)
+{
+ GabbleMucChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ return priv->ready_emitted;
+}
+
+/**
+ * _gabble_muc_channel_presence_error
+ */
+void
+_gabble_muc_channel_presence_error (GabbleMucChannel *chan,
+ const gchar *jid,
+ LmMessageNode *pres_node)
+{
+ GabbleMucChannelPrivate *priv;
+ LmMessageNode *error_node;
+ GabbleXmppError error;
+ GabbleHandle actor = 0;
+ guint reason_code = TP_CHANNEL_GROUP_CHANGE_REASON_NONE;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ if (strcmp (jid, priv->self_jid->str) != 0)
+ {
+ g_warning ("%s: presence error from other jids than self not handled",
+ G_STRFUNC);
+ return;
+ }
+
+ error_node = lm_message_node_get_child (pres_node, "error");
+ if (error_node == NULL)
+ {
+ g_warning ("%s: missing required node 'error'", G_STRFUNC);
+ return;
+ }
+
+ error = gabble_xmpp_error_from_node (error_node);
+
+ if (priv->state >= MUC_STATE_JOINED)
+ {
+ g_warning ("%s: presence error while already member of the channel -- NYI",
+ G_STRFUNC);
+ return;
+ }
+
+ /* We're not a member, find out why the join request failed
+ * and act accordingly. */
+ if (error == XMPP_ERROR_NOT_AUTHORIZED)
+ {
+ /* channel can sit requiring a password indefinitely */
+ clear_join_timer (chan);
+
+ /* Password already provided and incorrect? */
+ if (priv->state == MUC_STATE_AUTH)
+ {
+ provide_password_return_if_pending (chan, FALSE);
+
+ return;
+ }
+
+ gabble_debug (DEBUG_FLAG, "password required to join, changing password flags");
+
+ change_password_flags (chan, TP_CHANNEL_PASSWORD_FLAG_PROVIDE, 0);
+
+ g_object_set (chan, "state", MUC_STATE_AUTH, NULL);
+ }
+ else
+ {
+ GError *tp_error;
+
+ switch (error) {
+ case XMPP_ERROR_FORBIDDEN:
+ tp_error = g_error_new (TELEPATHY_ERRORS, ChannelBanned,
+ "banned from room");
+ reason_code = TP_CHANNEL_GROUP_CHANGE_REASON_BANNED;
+ break;
+ case XMPP_ERROR_SERVICE_UNAVAILABLE:
+ tp_error = g_error_new (TELEPATHY_ERRORS, ChannelFull,
+ "room is full");
+ break;
+ case XMPP_ERROR_REGISTRATION_REQUIRED:
+ tp_error = g_error_new (TELEPATHY_ERRORS, ChannelInviteOnly,
+ "room is invite only");
+ break;
+ case XMPP_ERROR_CONFLICT:
+ if (priv->nick_retry_count < MAX_NICK_RETRIES)
+ {
+ g_string_append_c (priv->self_jid, '_');
+
+ if (send_join_request (chan, priv->password, &tp_error))
+ {
+ priv->nick_retry_count++;
+ return;
+ }
+ }
+ else
+ {
+ tp_error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "nickname already in use and retry count exceeded");
+ }
+ break;
+ default:
+ if (error != INVALID_XMPP_ERROR)
+ {
+ tp_error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ gabble_xmpp_error_description (error));
+ }
+ else
+ {
+ tp_error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "unknown error");
+ }
+ break;
+ }
+
+ g_signal_emit (chan, signals[JOIN_ERROR], 0, tp_error);
+
+ close_channel (chan, tp_error->message, FALSE, actor, reason_code);
+
+ g_error_free (tp_error);
+ }
+}
+
+static GabbleMucRole
+get_role_from_string (const gchar *role)
+{
+ guint i;
+
+ if (role == NULL)
+ {
+ return ROLE_VISITOR;
+ }
+
+ for (i = 0; i < NUM_ROLES; i++)
+ {
+ if (strcmp (role, muc_roles[i]) == 0)
+ {
+ return i;
+ }
+ }
+
+ g_warning ("%s: unknown role '%s' -- defaulting to ROLE_VISITOR",
+ G_STRFUNC, role);
+
+ return ROLE_VISITOR;
+}
+
+static GabbleMucAffiliation
+get_affiliation_from_string (const gchar *affil)
+{
+ guint i;
+
+ if (affil == NULL)
+ {
+ return AFFILIATION_NONE;
+ }
+
+ for (i = 0; i < NUM_AFFILIATIONS; i++)
+ {
+ if (strcmp (affil, muc_affiliations[i]) == 0)
+ {
+ return i;
+ }
+ }
+
+ g_warning ("%s: unknown affiliation '%s' -- defaulting to "
+ "AFFILIATION_NONE", G_STRFUNC, affil);
+
+ return AFFILIATION_NONE;
+}
+
+static LmHandlerResult
+room_created_submit_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object,
+ gpointer user_data)
+{
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ g_warning ("%s: failed to submit room config", G_STRFUNC);
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static LmMessageNode *
+config_form_get_form_node (LmMessage *msg)
+{
+ LmMessageNode *node;
+
+ /* find the query node */
+ node = lm_message_node_get_child (msg->node, "query");
+ if (node == NULL)
+ return NULL;
+
+ /* then the form node */
+ for (node = node->children; node; node = node->next)
+ {
+ if (strcmp (node->name, "x") == 0)
+ {
+ if (!lm_message_node_has_namespace (node, NS_X_DATA, NULL))
+ {
+ continue;
+ }
+
+ if (strcmp (lm_message_node_get_attribute (node, "type"),
+ "form") != 0)
+ {
+ continue;
+ }
+
+ return node;
+ }
+ }
+
+ return NULL;
+}
+
+static LmHandlerResult
+perms_config_form_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object,
+ gpointer user_data)
+{
+ GabbleMucChannel *chan = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+ LmMessageNode *form_node, *node;
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ g_warning ("%s: request for config form denied, property permissions "
+ "will be inaccurate", G_STRFUNC);
+ goto OUT;
+ }
+
+ /* just in case our affiliation has changed in the meantime */
+ if (priv->self_affil != AFFILIATION_OWNER)
+ goto OUT;
+
+ form_node = config_form_get_form_node (reply_msg);
+ if (form_node == NULL)
+ {
+ g_warning ("%s: form node node found, property permissions will be "
+ "inaccurate", G_STRFUNC);
+ goto OUT;
+ }
+
+ for (node = form_node->children; node; node = node->next)
+ {
+ const gchar *var;
+
+ if (strcmp (node->name, "field") != 0)
+ continue;
+
+ var = lm_message_node_get_attribute (node, "var");
+ if (var == NULL)
+ continue;
+
+ if (strcmp (var, "muc#roomconfig_roomdesc") == 0 ||
+ strcmp (var, "muc#owner_roomdesc") == 0)
+ {
+ if (gabble_properties_mixin_is_readable (G_OBJECT (chan),
+ ROOM_PROP_DESCRIPTION))
+ {
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_DESCRIPTION, TP_PROPERTY_FLAG_WRITE, 0,
+ NULL);
+
+ goto OUT;
+ }
+ }
+ }
+
+OUT:
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static void
+update_permissions (GabbleMucChannel *chan)
+{
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+ TpChannelGroupFlags grp_flags_add, grp_flags_rem;
+ TpPropertyFlags prop_flags_add, prop_flags_rem;
+ GArray *changed_props_val, *changed_props_flags;
+
+ /*
+ * Update group flags.
+ */
+ grp_flags_add = TP_CHANNEL_GROUP_FLAG_CAN_ADD |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD;
+ grp_flags_rem = 0;
+
+ if (priv->self_role == ROLE_MODERATOR)
+ {
+ grp_flags_add |= TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE;
+ }
+ else
+ {
+ grp_flags_rem |= TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE;
+ }
+
+ gabble_group_mixin_change_flags (G_OBJECT (chan), grp_flags_add,
+ grp_flags_rem);
+
+
+ /*
+ * Update write capabilities based on room configuration
+ * and own role and affiliation.
+ */
+
+ changed_props_val = changed_props_flags = NULL;
+
+ /*
+ * Subject
+ *
+ * FIXME: this might be allowed for participants/moderators only,
+ * so for now just rely on the server making that call.
+ */
+
+ if (priv->self_role >= ROLE_VISITOR)
+ {
+ prop_flags_add = TP_PROPERTY_FLAG_WRITE;
+ prop_flags_rem = 0;
+ }
+ else
+ {
+ prop_flags_add = 0;
+ prop_flags_rem = TP_PROPERTY_FLAG_WRITE;
+ }
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ /* Room definition */
+ if (priv->self_affil == AFFILIATION_OWNER)
+ {
+ prop_flags_add = TP_PROPERTY_FLAG_WRITE;
+ prop_flags_rem = 0;
+ }
+ else
+ {
+ prop_flags_add = 0;
+ prop_flags_rem = TP_PROPERTY_FLAG_WRITE;
+ }
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_ANONYMOUS, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_INVITE_ONLY, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_MODERATED, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_NAME, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_PASSWORD, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_PASSWORD_REQUIRED, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_PERSISTENT, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_PRIVATE, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT, prop_flags_add, prop_flags_rem,
+ &changed_props_flags);
+
+ if (priv->self_affil == AFFILIATION_OWNER)
+ {
+ /* request the configuration form purely to see if the description
+ * is writable by us in this room. sigh. GO MUC!!! */
+ LmMessage *msg;
+ LmMessageNode *node;
+ GError *error = NULL;
+ gboolean success;
+
+ msg = lm_message_new_with_sub_type (priv->jid,
+ LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_GET);
+ node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_MUC_OWNER);
+
+ success = _gabble_connection_send_with_reply (priv->conn, msg,
+ perms_config_form_reply_cb, G_OBJECT (chan), NULL,
+ &error);
+
+ lm_message_unref (msg);
+
+ if (!success)
+ {
+ g_warning ("%s: failed to request config form: %s",
+ G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+ }
+ else
+ {
+ /* mark description unwritable if we're no longer an owner */
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_DESCRIPTION, 0, TP_PROPERTY_FLAG_WRITE,
+ &changed_props_flags);
+ }
+
+ /*
+ * Emit signals.
+ */
+ gabble_properties_mixin_emit_changed (G_OBJECT (chan), &changed_props_val);
+ gabble_properties_mixin_emit_flags (G_OBJECT (chan), &changed_props_flags);
+}
+
+/**
+ * _gabble_muc_channel_member_presence_updated
+ */
+void
+_gabble_muc_channel_member_presence_updated (GabbleMucChannel *chan,
+ GabbleHandle handle,
+ LmMessage *message,
+ LmMessageNode *x_node)
+{
+ GabbleMucChannelPrivate *priv;
+ GIntSet *set;
+ GabbleGroupMixin *mixin;
+ LmMessageNode *item_node, *node;
+ const gchar *affil, *role, *owner_jid, *status_code;
+ GabbleHandle actor = 0;
+ guint reason_code = TP_CHANNEL_GROUP_CHANGE_REASON_NONE;
+
+ gabble_debug (DEBUG_FLAG, "called");
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ mixin = GABBLE_GROUP_MIXIN (chan);
+
+ item_node = lm_message_node_get_child (x_node, "item");
+ if (item_node == NULL)
+ {
+ g_warning ("%s: node missing 'item' child, ignoring", G_STRFUNC);
+ return;
+ }
+
+ node = lm_message_node_get_child (x_node, "status");
+ if (node)
+ {
+ status_code = lm_message_node_get_attribute (node, "code");
+ }
+ else
+ {
+ status_code = NULL;
+ }
+
+ role = lm_message_node_get_attribute (item_node, "role");
+ affil = lm_message_node_get_attribute (item_node, "affiliation");
+ owner_jid = lm_message_node_get_attribute (item_node, "jid");
+
+ /* update channel members according to presence */
+ set = g_intset_new ();
+ g_intset_add (set, handle);
+
+ if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_UNAVAILABLE)
+ {
+ if (!handle_set_is_member (mixin->members, handle))
+ {
+ gabble_group_mixin_change_members (G_OBJECT (chan), "", set, NULL,
+ NULL, NULL, 0, 0);
+
+ if (owner_jid != NULL)
+ {
+ GabbleHandle owner_handle;
+
+ owner_handle = gabble_handle_for_contact (
+ chan->group.handle_repo, owner_jid, FALSE);
+
+ gabble_group_mixin_add_handle_owner (G_OBJECT (chan), handle,
+ owner_handle);
+ }
+
+ if (handle == mixin->self_handle)
+ {
+ g_object_set (chan, "state", MUC_STATE_JOINED, NULL);
+ }
+ }
+
+ if (handle == mixin->self_handle)
+ {
+ GabbleMucRole new_role;
+ GabbleMucAffiliation new_affil;
+
+ /* accept newly-created room settings before we send anything
+ * below which queryies them. */
+ if (status_code && strcmp (status_code, "201") == 0)
+ {
+ LmMessage *msg;
+ GError *error = NULL;
+
+ msg = lm_message_new_with_sub_type (priv->jid, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_MUC_OWNER);
+
+ node = lm_message_node_add_child (node, "x", NULL);
+ lm_message_node_set_attributes (node,
+ "xmlns", NS_X_DATA,
+ "type", "submit",
+ NULL);
+
+ if (!_gabble_connection_send_with_reply (priv->conn, msg,
+ room_created_submit_reply_cb, G_OBJECT (chan), NULL, &error))
+ {
+ g_warning ("%s: failed to send submit message: %s", G_STRFUNC,
+ error->message);
+ g_error_free (error);
+
+ close_channel (chan, NULL, TRUE, actor, reason_code);
+
+ goto OUT;
+ }
+ }
+
+ /* Update room properties */
+ room_properties_update (chan);
+
+ /* update permissions after requesting new properties so that if we
+ * become an owner, we get our configuration form reply after the
+ * discovery reply, so we know whether there is a description
+ * property before we try and decide whether we can write to it. */
+ new_role = get_role_from_string (role);
+ new_affil = get_affiliation_from_string (affil);
+
+ if (new_role != priv->self_role || new_affil != priv->self_affil)
+ {
+ priv->self_role = new_role;
+ priv->self_affil = new_affil;
+
+ update_permissions (chan);
+ }
+ }
+ }
+ else
+ {
+ LmMessageNode *reason_node, *actor_node;
+ const gchar *reason = "", *actor_jid = "";
+
+ actor_node = lm_message_node_get_child (item_node, "actor");
+ if (actor_node != NULL)
+ {
+ actor_jid = lm_message_node_get_attribute (actor_node, "jid");
+ if (actor_jid != NULL)
+ {
+ actor = gabble_handle_for_contact(chan->group.handle_repo, actor_jid, FALSE);
+ }
+ }
+
+ /* Possible reasons we could have been removed from the room:
+ * 301 banned
+ * 307 kicked
+ * 321 "because of an affiliation change" - no reason_code
+ * 322 room has become members-only and we're not a member - no reason_code
+ * 332 system (server) is being shut down - no reason code
+ */
+ if (status_code)
+ {
+ if (strcmp (status_code, "301") == 0)
+ {
+ reason_code = TP_CHANNEL_GROUP_CHANGE_REASON_BANNED;
+ }
+ else if (strcmp (status_code, "307") == 0)
+ {
+ reason_code = TP_CHANNEL_GROUP_CHANGE_REASON_KICKED;
+ }
+ }
+
+ reason_node = lm_message_node_get_child (item_node, "reason");
+ if (reason_node != NULL)
+ {
+ reason = lm_message_node_get_value (reason_node);
+ }
+
+ if (handle != mixin->self_handle)
+ {
+ gabble_group_mixin_change_members (G_OBJECT (chan), reason,
+ NULL, set, NULL, NULL,
+ actor, reason_code);
+ }
+ else
+ {
+ close_channel (chan, reason, FALSE, actor, reason_code);
+ }
+ }
+
+OUT:
+ g_intset_destroy (set);
+}
+
+
+/**
+ * _gabble_muc_channel_receive
+ */
+gboolean
+_gabble_muc_channel_receive (GabbleMucChannel *chan,
+ TpChannelTextMessageType msg_type,
+ TpHandleType handle_type,
+ GabbleHandle sender,
+ time_t timestamp,
+ const gchar *text,
+ LmMessage *msg)
+{
+ gboolean error;
+ GabbleMucChannelPrivate *priv;
+ LmMessageNode *subj_node, *node;
+ GValue val = { 0, };
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ error = lm_message_get_sub_type (msg) == LM_MESSAGE_SUB_TYPE_ERROR;
+
+ subj_node = lm_message_node_get_child (msg->node, "subject");
+
+ if (subj_node)
+ {
+ GArray *changed_values, *changed_flags;
+
+ if (priv->properties_ctx)
+ {
+ gabble_properties_context_remove (priv->properties_ctx,
+ ROOM_PROP_SUBJECT);
+ }
+
+ if (error)
+ {
+ GabbleXmppError xmpp_error = INVALID_XMPP_ERROR;
+ const gchar *err_desc = NULL;
+
+ node = lm_message_node_get_child (msg->node, "error");
+ if (node)
+ {
+ xmpp_error = gabble_xmpp_error_from_node (node);
+ }
+
+ if (xmpp_error != INVALID_XMPP_ERROR)
+ {
+ err_desc = gabble_xmpp_error_description (xmpp_error);
+ }
+
+ if (priv->properties_ctx)
+ {
+ GError *error = NULL;
+
+ error = g_error_new (TELEPATHY_ERRORS, PermissionDenied,
+ (err_desc) ? err_desc : "failed to change subject");
+
+ gabble_properties_context_return (priv->properties_ctx, error);
+ priv->properties_ctx = NULL;
+
+ /* Get the properties into a consistent state. */
+ room_properties_update (chan);
+ }
+
+ return TRUE;
+ }
+
+ changed_values = changed_flags = NULL;
+
+ /* ROOM_PROP_SUBJECT */
+ g_value_init (&val, G_TYPE_STRING);
+ g_value_set_string (&val, lm_message_node_get_value (subj_node));
+
+ gabble_properties_mixin_change_value (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT, &val, &changed_values);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT, TP_PROPERTY_FLAG_READ, 0,
+ &changed_flags);
+
+ g_value_unset (&val);
+
+ if (handle_type == TP_HANDLE_TYPE_CONTACT)
+ {
+ /* ROOM_PROP_SUBJECT_CONTACT */
+ g_value_init (&val, G_TYPE_UINT);
+ g_value_set_uint (&val, sender);
+
+ gabble_properties_mixin_change_value (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT_CONTACT, &val, &changed_values);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT_CONTACT, TP_PROPERTY_FLAG_READ, 0,
+ &changed_flags);
+
+ g_value_unset (&val);
+ }
+
+ /* ROOM_PROP_SUBJECT_TIMESTAMP */
+ g_value_init (&val, G_TYPE_UINT);
+ g_value_set_uint (&val, timestamp);
+
+ gabble_properties_mixin_change_value (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT_TIMESTAMP, &val, &changed_values);
+
+ gabble_properties_mixin_change_flags (G_OBJECT (chan),
+ ROOM_PROP_SUBJECT_TIMESTAMP, TP_PROPERTY_FLAG_READ, 0,
+ &changed_flags);
+
+ g_value_unset (&val);
+
+ /* Emit signals */
+ gabble_properties_mixin_emit_changed (G_OBJECT (chan), &changed_values);
+ gabble_properties_mixin_emit_flags (G_OBJECT (chan), &changed_flags);
+
+ if (priv->properties_ctx)
+ {
+ if (gabble_properties_context_return_if_done (priv->properties_ctx))
+ {
+ priv->properties_ctx = NULL;
+ }
+ }
+
+ return TRUE;
+ }
+ else if (handle_type == TP_HANDLE_TYPE_ROOM)
+ {
+ NODE_DEBUG (msg->node, "ignoring message from channel");
+
+ return TRUE;
+ }
+ else if ((sender == chan->group.self_handle) && (timestamp == 0))
+ {
+ /* If we sent the message and it's not delayed, just emit the sent signal */
+ timestamp = time (NULL);
+ gabble_text_mixin_emit_sent (G_OBJECT (chan), timestamp, msg_type, text);
+
+ return TRUE;
+ }
+
+ /* Receive messages from other contacts and our own if they're delayed, and
+ * set the timestamp for non-delayed messages */
+ if (timestamp == 0)
+ timestamp = time (NULL);
+
+ return gabble_text_mixin_receive (G_OBJECT (chan), msg_type, sender,
+ timestamp, text);
+}
+
+void
+_gabble_muc_channel_handle_invited (GabbleMucChannel *chan,
+ GabbleHandle inviter,
+ const gchar *message)
+{
+ GabbleMucChannelPrivate *priv;
+ GabbleHandle self_handle;
+ GIntSet *set_members, *set_pending;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (chan));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+
+ /* add ourself to local pending and the inviter to members */
+ set_members = g_intset_new ();
+ set_pending = g_intset_new ();
+
+ g_intset_add (set_members, inviter);
+
+ /* get our own identity in the room */
+ contact_handle_to_room_identity (chan, priv->conn->self_handle,
+ &self_handle, &priv->self_jid);
+ g_intset_add (set_pending, self_handle);
+
+ gabble_group_mixin_change_members (G_OBJECT (chan), message, set_members,
+ NULL, set_pending, NULL, inviter,
+ TP_CHANNEL_GROUP_CHANGE_REASON_INVITED);
+
+ g_intset_destroy (set_members);
+ g_intset_destroy (set_pending);
+
+ /* queue the message */
+ if (message && (message[0] != '\0'))
+ {
+ gabble_text_mixin_receive (G_OBJECT (chan), TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE, inviter,
+ time(NULL), message);
+ }
+
+ /* emit READY signal so NewChannel is emitted */
+ g_signal_emit (chan, signals[READY], 0);
+ priv->ready_emitted = TRUE;
+}
+
+
+/**
+ * gabble_muc_channel_acknowledge_pending_messages
+ *
+ * Implements D-Bus method AcknowledgePendingMessages
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_acknowledge_pending_messages (GabbleMucChannel *self,
+ const GArray *ids,
+ GError **error)
+{
+ g_assert (GABBLE_IS_MUC_CHANNEL (self));
+
+ return gabble_text_mixin_acknowledge_pending_messages (G_OBJECT (self), ids,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_add_members
+ *
+ * Implements D-Bus method AddMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_add_members (GabbleMucChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error)
+{
+ return gabble_group_mixin_add_members (G_OBJECT (self), contacts, message,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_close
+ *
+ * Implements D-Bus method Close
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_close (GabbleMucChannel *self,
+ GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (self));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+
+ gabble_debug (DEBUG_FLAG, "called on %p", self);
+
+ if (priv->closed)
+ {
+ gabble_debug (DEBUG_FLAG, "channel already closed");
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Channel already closed");
+
+ return FALSE;
+ }
+
+ close_channel (self, NULL, TRUE, 0, 0);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_muc_channel_get_all_members
+ *
+ * Implements D-Bus method GetAllMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_all_members (GabbleMucChannel *self,
+ GArray **ret,
+ GArray **ret1,
+ GArray **ret2,
+ GError **error)
+{
+ return gabble_group_mixin_get_all_members (G_OBJECT (self), ret, ret1, ret2,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_get_channel_type
+ *
+ * Implements D-Bus method GetChannelType
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_channel_type (GabbleMucChannel *self,
+ gchar **ret,
+ GError **error)
+{
+ *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_TEXT);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_muc_channel_get_group_flags
+ *
+ * Implements D-Bus method GetGroupFlags
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_group_flags (GabbleMucChannel *self,
+ guint *ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_group_flags (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_muc_channel_get_handle
+ *
+ * Implements D-Bus method GetHandle
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_handle (GabbleMucChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (self));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+
+ *ret = TP_HANDLE_TYPE_ROOM;
+ *ret1 = priv->handle;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_muc_channel_get_handle_owners
+ *
+ * Implements D-Bus method GetHandleOwners
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_handle_owners (GabbleMucChannel *self,
+ const GArray *handles,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_handle_owners (G_OBJECT (self), handles, ret,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_interfaces (GabbleMucChannel *self,
+ gchar ***ret,
+ GError **error)
+{
+ const gchar *interfaces[] = {
+ TP_IFACE_CHANNEL_INTERFACE_GROUP,
+ TP_IFACE_CHANNEL_INTERFACE_PASSWORD,
+ TP_IFACE_PROPERTIES,
+ NULL
+ };
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_muc_channel_get_local_pending_members
+ *
+ * Implements D-Bus method GetLocalPendingMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_local_pending_members (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_local_pending_members (G_OBJECT (self), ret,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_get_members
+ *
+ * Implements D-Bus method GetMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_members (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_members (G_OBJECT (self), ret, error);
+}
+
+
+
+
+/**
+ * gabble_muc_channel_get_message_types
+ *
+ * Implements D-Bus method GetMessageTypes
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_message_types (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_text_mixin_get_message_types (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_muc_channel_get_password_flags
+ *
+ * Implements D-Bus method GetPasswordFlags
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Password
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_password_flags (GabbleMucChannel *self,
+ guint *ret,
+ GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (self));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+
+ *ret = priv->password_flags;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_muc_channel_get_remote_pending_members
+ *
+ * Implements D-Bus method GetRemotePendingMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_remote_pending_members (GabbleMucChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_remote_pending_members (G_OBJECT (self), ret,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_get_self_handle
+ *
+ * Implements D-Bus method GetSelfHandle
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_self_handle (GabbleMucChannel *self,
+ guint *ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_self_handle (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_muc_channel_list_pending_messages
+ *
+ * Implements D-Bus method ListPendingMessages
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_list_pending_messages (GabbleMucChannel *self,
+ gboolean clear,
+ GPtrArray **ret,
+ GError **error)
+{
+ return gabble_text_mixin_list_pending_messages (G_OBJECT (self), clear, ret,
+ error);
+}
+
+
+/**
+ * gabble_muc_channel_provide_password
+ *
+ * Implements D-Bus method ProvidePassword
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Password
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_muc_channel_provide_password (GabbleMucChannel *self,
+ const gchar *password,
+ DBusGMethodInvocation *context)
+{
+ GError *error = NULL;
+ GabbleMucChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (self));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+
+ if ((priv->password_flags & TP_CHANNEL_PASSWORD_FLAG_PROVIDE) == 0 ||
+ priv->password_ctx != NULL)
+ {
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "password cannot be provided in the current state");
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+
+ return;
+ }
+
+ if (!send_join_request (self, password, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+
+ return;
+ }
+
+ priv->password_ctx = context;
+}
+
+
+/**
+ * gabble_muc_channel_remove_members
+ *
+ * Implements D-Bus method RemoveMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean gabble_muc_channel_remove_members (GabbleMucChannel *obj, const GArray * contacts, const gchar * message, GError **error)
+{
+ return gabble_group_mixin_remove_members (G_OBJECT (obj), contacts, message, error);
+}
+
+/**
+ * gabble_muc_channel_send
+ *
+ * Implements D-Bus method Send
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_send (GabbleMucChannel *self,
+ guint type,
+ const gchar *text,
+ GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_MUC_CHANNEL (self));
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (self);
+
+ return gabble_text_mixin_send (G_OBJECT (self), type,
+ LM_MESSAGE_SUB_TYPE_GROUPCHAT, priv->jid, text, priv->conn,
+ FALSE /* emit_signal */, error);
+}
+
+
+static gboolean
+gabble_muc_channel_add_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+ GabbleGroupMixin *mixin;
+ const gchar *jid;
+ LmMessage *msg;
+ LmMessageNode *x_node, *invite_node;
+ gboolean result;
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (GABBLE_MUC_CHANNEL (obj));
+
+ mixin = GABBLE_GROUP_MIXIN (obj);
+
+ if (handle == mixin->self_handle)
+ {
+ GIntSet *set_empty, *set_members, *set_pending;
+ GArray *arr_members;
+
+ /* are we already a member or in remote pending? */
+ if (handle_set_is_member (mixin->members, handle) ||
+ handle_set_is_member (mixin->remote_pending, handle))
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "already a member or in remote pending");
+
+ return FALSE;
+ }
+
+ /* add ourself to remote pending and remove the inviter's
+ * main jid from the member list */
+ set_empty = g_intset_new ();
+ set_members = g_intset_new ();
+ set_pending = g_intset_new ();
+
+ arr_members = handle_set_to_array (mixin->members);
+ if (arr_members->len > 0)
+ {
+ g_intset_add (set_members, g_array_index (arr_members, guint32, 0));
+ }
+ g_array_free (arr_members, TRUE);
+
+ g_intset_add (set_pending, handle);
+
+ gabble_group_mixin_change_members (obj, "", set_empty, set_members,
+ set_empty, set_pending, 0,
+ TP_CHANNEL_GROUP_CHANGE_REASON_INVITED);
+
+ g_intset_destroy (set_empty);
+ g_intset_destroy (set_members);
+ g_intset_destroy (set_pending);
+
+ /* seek to enter the room */
+ result = send_join_request (GABBLE_MUC_CHANNEL (obj), NULL, error);
+
+ g_object_set (obj, "state",
+ (result) ? MUC_STATE_INITIATED : MUC_STATE_ENDED,
+ NULL);
+
+ /* deny adding */
+ gabble_group_mixin_change_flags (obj, 0, TP_CHANNEL_GROUP_FLAG_CAN_ADD);
+
+ /* clear message queue (which might contain an invite reason) */
+ gabble_text_mixin_clear (G_OBJECT (obj));
+
+ return result;
+ }
+
+ /* check that we're indeed a member when attempting to invite others */
+ if (priv->state < MUC_STATE_JOINED)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "channel membership is required for inviting others");
+
+ return FALSE;
+ }
+
+ msg = lm_message_new (priv->jid, LM_MESSAGE_TYPE_MESSAGE);
+
+ x_node = lm_message_node_add_child (msg->node, "x", NULL);
+ lm_message_node_set_attribute (x_node, "xmlns", NS_MUC_USER);
+
+ invite_node = lm_message_node_add_child (x_node, "invite", NULL);
+
+ jid = gabble_handle_inspect (GABBLE_GROUP_MIXIN (obj)->handle_repo,
+ TP_HANDLE_TYPE_CONTACT, handle);
+
+ lm_message_node_set_attribute (invite_node, "to", jid);
+
+ if (*message != '\0')
+ {
+ lm_message_node_add_child (invite_node, "reason", message);
+ }
+
+ NODE_DEBUG (msg->node, "sending MUC invitation");
+
+ result = _gabble_connection_send (priv->conn, msg, error);
+ lm_message_unref (msg);
+
+ return result;
+}
+
+static LmHandlerResult
+kick_request_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object,
+ gpointer user_data)
+{
+ const gchar *jid = user_data;
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ g_warning ("%s: Failed to kick user %s from room", G_STRFUNC, jid);
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static gboolean
+gabble_muc_channel_remove_member (GObject *obj, GabbleHandle handle, const gchar *message, GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+ LmMessage *msg;
+ LmMessageNode *query_node, *item_node;
+ const gchar *jid;
+ gchar *nick;
+ gboolean result;
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (GABBLE_MUC_CHANNEL (obj));
+
+ msg = lm_message_new_with_sub_type (priv->jid, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ query_node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (query_node, "xmlns", NS_MUC_ADMIN);
+
+ item_node = lm_message_node_add_child (query_node, "item", NULL);
+
+ jid = gabble_handle_inspect (GABBLE_GROUP_MIXIN (obj)->handle_repo,
+ TP_HANDLE_TYPE_CONTACT, handle);
+
+ gabble_decode_jid (jid, NULL, NULL, &nick);
+
+ lm_message_node_set_attributes (item_node,
+ "nick", nick,
+ "role", "none",
+ NULL);
+
+ g_free (nick);
+
+ if (*message != '\0')
+ {
+ lm_message_node_add_child (item_node, "reason", message);
+ }
+
+ NODE_DEBUG (msg->node, "sending MUC kick request");
+
+ result = _gabble_connection_send_with_reply (priv->conn, msg,
+ kick_request_reply_cb,
+ obj, (gpointer) jid,
+ error);
+
+ lm_message_unref (msg);
+
+ return result;
+}
+
+
+/**
+ * gabble_muc_channel_list_properties
+ *
+ * Implements D-Bus method ListProperties
+ * on interface org.freedesktop.Telepathy.Properties
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_list_properties (GabbleMucChannel *self,
+ GPtrArray **ret,
+ GError **error)
+{
+ return gabble_properties_mixin_list_properties (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_muc_channel_get_properties
+ *
+ * Implements D-Bus method GetProperties
+ * on interface org.freedesktop.Telepathy.Properties
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_muc_channel_get_properties (GabbleMucChannel *self,
+ const GArray *properties,
+ GPtrArray **ret,
+ GError **error)
+{
+ return gabble_properties_mixin_get_properties (G_OBJECT (self), properties,
+ ret, error);
+}
+
+/**
+ * gabble_muc_channel_set_properties
+ *
+ * Implements D-Bus method SetProperties
+ * on interface org.freedesktop.Telepathy.Properties
+ *
+ * @context: The D-Bus invocation context to use to return values
+ * or throw an error.
+ */
+void
+gabble_muc_channel_set_properties (GabbleMucChannel *self,
+ const GPtrArray *properties,
+ DBusGMethodInvocation *context)
+{
+ gabble_properties_mixin_set_properties (G_OBJECT (self), properties,
+ context);
+}
+
+static LmHandlerResult request_config_form_reply_cb (GabbleConnection *conn, LmMessage *sent_msg, LmMessage *reply_msg, GObject *object, gpointer user_data);
+
+static gboolean
+gabble_muc_channel_do_set_properties (GObject *obj, GabblePropertiesContext *ctx, GError **error)
+{
+ GabbleMucChannelPrivate *priv;
+ LmMessage *msg;
+ LmMessageNode *node;
+ gboolean success;
+
+ priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (GABBLE_MUC_CHANNEL (obj));
+
+ g_assert (priv->properties_ctx == NULL);
+
+ /* Changing subject? */
+ if (gabble_properties_context_has (ctx, ROOM_PROP_SUBJECT))
+ {
+ const gchar *str;
+
+ str = g_value_get_string (gabble_properties_context_get (ctx, ROOM_PROP_SUBJECT));
+
+ msg = lm_message_new_with_sub_type (priv->jid,
+ LM_MESSAGE_TYPE_MESSAGE, LM_MESSAGE_SUB_TYPE_GROUPCHAT);
+ lm_message_node_add_child (msg->node, "subject", str);
+
+ success = _gabble_connection_send (priv->conn, msg, error);
+
+ lm_message_unref (msg);
+
+ if (!success)
+ return FALSE;
+ }
+
+ /* Changing any other properties? */
+ if (gabble_properties_context_has_other_than (ctx, ROOM_PROP_SUBJECT))
+ {
+ msg = lm_message_new_with_sub_type (priv->jid,
+ LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_GET);
+ node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_MUC_OWNER);
+
+ success = _gabble_connection_send_with_reply (priv->conn, msg,
+ request_config_form_reply_cb, G_OBJECT (obj), NULL,
+ error);
+
+ lm_message_unref (msg);
+
+ if (!success)
+ return FALSE;
+ }
+
+ priv->properties_ctx = ctx;
+
+ return TRUE;
+}
+
+static LmHandlerResult request_config_form_submit_reply_cb (GabbleConnection *conn, LmMessage *sent_msg, LmMessage *reply_msg, GObject *object, gpointer user_data);
+
+static LmHandlerResult
+request_config_form_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object,
+ gpointer user_data)
+{
+ GabbleMucChannel *chan = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+ GabblePropertiesContext *ctx = priv->properties_ctx;
+ GError *error = NULL;
+ LmMessage *msg = NULL;
+ LmMessageNode *submit_node, *form_node, *node, *query_node;
+ guint i, props_left;
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ error = g_error_new (TELEPATHY_ERRORS, PermissionDenied,
+ "request for configuration form denied");
+
+ goto OUT;
+ }
+
+ form_node = config_form_get_form_node (reply_msg);
+ if (form_node == NULL)
+ goto PARSE_ERROR;
+
+ /* initialize */
+ msg = lm_message_new_with_sub_type (priv->jid, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_MUC_OWNER);
+
+ submit_node = lm_message_node_add_child (node, "x", NULL);
+ lm_message_node_set_attributes (submit_node,
+ "xmlns", NS_X_DATA,
+ "type", "submit",
+ NULL);
+
+ /* find the query node */
+ query_node = lm_message_node_get_child (reply_msg->node, "query");
+ if (query_node == NULL)
+ goto PARSE_ERROR;
+
+ /* then the form node */
+ form_node = NULL;
+ for (node = query_node->children; node; node = node->next)
+ {
+ if (strcmp (node->name, "x") == 0)
+ {
+ const gchar *type = lm_message_node_get_attribute (node, "type");
+
+ if (!lm_message_node_has_namespace (node, NS_X_DATA, NULL))
+ continue;
+
+ if (g_strdiff (type, "form"))
+ continue;
+
+ form_node = node;
+ break;
+ }
+ }
+
+ if (form_node == NULL)
+ goto PARSE_ERROR;
+
+ props_left = 0;
+ for (i = 0; i < NUM_ROOM_PROPS; i++)
+ {
+ if (i == ROOM_PROP_SUBJECT)
+ continue;
+
+ if (gabble_properties_context_has (ctx, i))
+ props_left |= 1 << i;
+ }
+
+ for (node = form_node->children; node; node = node->next)
+ {
+ const gchar *var, *prev_value;
+ LmMessageNode *field_node, *value_node;
+ guint id;
+ GType type;
+ gboolean invert;
+ gchar buf[16];
+ const gchar *val_str;
+ gboolean val_bool;
+
+ if (strcmp (node->name, "field") != 0)
+ {
+ gabble_debug (DEBUG_FLAG, "skipping node '%s'", node->name);
+ continue;
+ }
+
+ var = lm_message_node_get_attribute (node, "var");
+ if (var == NULL) {
+ gabble_debug (DEBUG_FLAG, "skipping node '%s' because of lacking var attribute",
+ node->name);
+ continue;
+ }
+
+ value_node = lm_message_node_get_child (node, "value");
+ if (value_node == NULL)
+ {
+ gabble_debug (DEBUG_FLAG, "skipping var '%s' because of lacking value attribute",
+ var);
+ continue;
+ }
+
+ prev_value = lm_message_node_get_value (value_node);
+
+ /* add the corresponding field node to the reply message */
+ field_node = lm_message_node_add_child (submit_node, "field", NULL);
+
+ lm_message_node_set_attribute (field_node, "var", var);
+
+ val_str = lm_message_node_get_attribute (node, "type");
+ if (val_str)
+ {
+ lm_message_node_set_attribute (field_node, "type", val_str);
+ }
+
+ value_node = lm_message_node_add_child (field_node, "value", prev_value);
+
+ id = INVALID_ROOM_PROP;
+ type = G_TYPE_BOOLEAN;
+ invert = FALSE;
+ val_str = NULL;
+
+ if (strcmp (var, "anonymous") == 0)
+ {
+ id = ROOM_PROP_ANONYMOUS;
+ }
+ else if (strcmp (var, "muc#roomconfig_whois") == 0)
+ {
+ id = ROOM_PROP_ANONYMOUS;
+
+ if (gabble_properties_context_has (ctx, id))
+ {
+ val_bool = g_value_get_boolean (
+ gabble_properties_context_get (ctx, id));
+ val_str = (val_bool) ? "moderators" : "anyone";
+ }
+ }
+ else if (strcmp (var, "muc#owner_whois") == 0)
+ {
+ id = ROOM_PROP_ANONYMOUS;
+
+ if (gabble_properties_context_has (ctx, id))
+ {
+ val_bool = g_value_get_boolean (
+ gabble_properties_context_get (ctx, id));
+ val_str = (val_bool) ? "admins" : "anyone";
+ }
+ }
+ else if (strcmp (var, "members_only") == 0 ||
+ strcmp (var, "muc#roomconfig_membersonly") == 0 ||
+ strcmp (var, "muc#owner_inviteonly") == 0)
+ {
+ id = ROOM_PROP_INVITE_ONLY;
+ }
+ else if (strcmp (var, "moderated") == 0 ||
+ strcmp (var, "muc#roomconfig_moderatedroom") == 0 ||
+ strcmp (var, "muc#owner_moderatedroom") == 0)
+ {
+ id = ROOM_PROP_MODERATED;
+ }
+ else if (strcmp (var, "title") == 0 ||
+ strcmp (var, "muc#roomconfig_roomname") == 0 ||
+ strcmp (var, "muc#owner_roomname") == 0)
+ {
+ id = ROOM_PROP_NAME;
+ type = G_TYPE_STRING;
+ }
+ else if (strcmp (var, "muc#roomconfig_roomdesc") == 0 ||
+ strcmp (var, "muc#owner_roomdesc") == 0)
+ {
+ id = ROOM_PROP_DESCRIPTION;
+ type = G_TYPE_STRING;
+ }
+ else if (strcmp (var, "password") == 0 ||
+ strcmp (var, "muc#roomconfig_roomsecret") == 0 ||
+ strcmp (var, "muc#owner_roomsecret") == 0)
+ {
+ id = ROOM_PROP_PASSWORD;
+ type = G_TYPE_STRING;
+ }
+ else if (strcmp (var, "password_protected") == 0 ||
+ strcmp (var, "muc#roomconfig_passwordprotectedroom") == 0 ||
+ strcmp (var, "muc#owner_passwordprotectedroom") == 0)
+ {
+ id = ROOM_PROP_PASSWORD_REQUIRED;
+ }
+ else if (strcmp (var, "persistent") == 0 ||
+ strcmp (var, "muc#roomconfig_persistentroom") == 0 ||
+ strcmp (var, "muc#owner_persistentroom") == 0)
+ {
+ id = ROOM_PROP_PERSISTENT;
+ }
+ else if (strcmp (var, "public") == 0 ||
+ strcmp (var, "muc#roomconfig_publicroom") == 0 ||
+ strcmp (var, "muc#owner_publicroom") == 0)
+ {
+ id = ROOM_PROP_PRIVATE;
+ invert = TRUE;
+ }
+ else
+ {
+ g_warning ("%s: ignoring field '%s'", G_STRFUNC, var);
+ continue;
+ }
+
+ gabble_debug (DEBUG_FLAG, "looking up %s", room_property_signatures[id].name);
+
+ if (!gabble_properties_context_has (ctx, id))
+ continue;
+
+ if (!val_str)
+ {
+ const GValue *provided_value;
+
+ provided_value = gabble_properties_context_get (ctx, id);
+
+ switch (type) {
+ case G_TYPE_BOOLEAN:
+ val_bool = g_value_get_boolean (provided_value);
+ sprintf (buf, "%d", (invert) ? !val_bool : val_bool);
+ val_str = buf;
+ break;
+ case G_TYPE_STRING:
+ val_str = g_value_get_string (provided_value);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ lm_message_node_set_value (value_node, val_str);
+
+ props_left &= ~(1 << id);
+ }
+
+ if (props_left != 0)
+ {
+ g_message (ANSI_BOLD_ON ANSI_FG_WHITE ANSI_BG_RED
+ "\n%s: the following properties were not substituted:\n",
+ G_STRFUNC);
+
+ for (i = 0; i < NUM_ROOM_PROPS; i++)
+ {
+ if ((props_left & (1 << i)) != 0)
+ {
+ g_message (" %s\n", room_property_signatures[i].name);
+ }
+ }
+
+ g_message ("\nthis is a MUC server compatibility bug in gabble, please "
+ "report it with a full debug log attached (running gabble "
+ "with LM_DEBUG=net)" ANSI_RESET "\n\n");
+ fflush (stdout);
+
+ error = g_error_new (TELEPATHY_ERRORS, InvalidArgument,
+ "not all properties were substituted");
+ goto OUT;
+ }
+
+ _gabble_connection_send_with_reply (priv->conn, msg,
+ request_config_form_submit_reply_cb, G_OBJECT (object),
+ NULL, &error);
+
+ goto OUT;
+
+PARSE_ERROR:
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "error parsing reply from server");
+
+OUT:
+ if (error)
+ {
+ gabble_properties_context_return (ctx, error);
+ priv->properties_ctx = NULL;
+ }
+
+ if (msg)
+ lm_message_unref (msg);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static LmHandlerResult
+request_config_form_submit_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object,
+ gpointer user_data)
+{
+ GabbleMucChannel *chan = GABBLE_MUC_CHANNEL (object);
+ GabbleMucChannelPrivate *priv = GABBLE_MUC_CHANNEL_GET_PRIVATE (chan);
+ GabblePropertiesContext *ctx = priv->properties_ctx;
+ GError *error = NULL;
+ gboolean returned;
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ error = g_error_new (TELEPATHY_ERRORS, PermissionDenied,
+ "submitted configuration form was rejected");
+ }
+
+ if (!error)
+ {
+ guint i;
+
+ for (i = 0; i < NUM_ROOM_PROPS; i++)
+ {
+ if (i != ROOM_PROP_SUBJECT)
+ gabble_properties_context_remove (ctx, i);
+ }
+
+ returned = gabble_properties_context_return_if_done (ctx);
+ }
+ else
+ {
+ gabble_properties_context_return (ctx, error);
+ returned = TRUE;
+
+ /* Get the properties into a consistent state. */
+ room_properties_update (chan);
+ }
+
+ if (returned)
+ priv->properties_ctx = NULL;
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-presence-cache-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,108 @@
+/*
+ * gabble-presence-cache-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:UINT,UINT,UINT (gabble-presence-cache-signals-marshal.list:1) */
+void
+gabble_presence_cache_marshal_VOID__UINT_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-presence-cache.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1267 @@
+/*
+ * gabble-presence-cache.c - Gabble's contact presence cache
+ * Copyright (C) 2005 Collabora Ltd.
+ * and/or its subsidiaries. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "debug.h"
+#include "disco.h" /* \o\ \o/ /o/ */
+#include "gabble-presence.h"
+#include "namespaces.h"
+#include "util.h"
+#include "handle-set.h"
+#include "gintset.h"
+
+#include "gabble-presence-cache.h"
+
+#include "gabble-presence-cache-signals-marshal.h"
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE (GabblePresenceCache, gabble_presence_cache, G_TYPE_OBJECT);
+#endif
+
+/* when five DIFFERENT guys report the same caps for a given bundle, it'll be enough */
+#define CAPABILITY_BUNDLE_ENOUGH_TRUST 5
+#define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+/* signal enum */
+enum
+{
+ PRESENCE_UPDATE,
+ NICKNAME_UPDATE,
+ CAPABILITIES_UPDATE,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_PRE_CACHE
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_pre_cache,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_pre_cache, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_presence_cache_parent_class,gabble_pre_cache,gpointer)
+ #define gabble_presence_cache_parent_class (*GET_WSD_VAR_NAME(gabble_presence_cache_parent_class,gabble_pre_cache,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_pre_cache,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_pre_cache,s)())
+
+
+static void gabble_presence_cache_init (GabblePresenceCache *self);
+static void gabble_presence_cache_class_init (GabblePresenceCacheClass *klass);
+static void gabble_presence_cache_class_intern_init (gpointer klass)
+ {
+ gabble_presence_cache_parent_class = g_type_class_peek_parent (klass);
+ gabble_presence_cache_class_init ((GabblePresenceCacheClass*) klass);
+ }
+ EXPORT_C GType gabble_presence_cache_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ { static const GTypeInfo g_define_type_info = { sizeof (GabblePresenceCacheClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_presence_cache_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabblePresenceCache), 0, (GInstanceInitFunc) gabble_presence_cache_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabblePresenceCache"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ };
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+#define GABBLE_PRESENCE_CACHE_PRIV(account) ((GabblePresenceCachePrivate *)account->priv)
+
+typedef struct _GabblePresenceCachePrivate GabblePresenceCachePrivate;
+
+struct _GabblePresenceCachePrivate
+{
+ GabbleConnection *conn;
+
+ gulong status_changed_cb;
+ LmMessageHandler *lm_message_cb;
+
+ GHashTable *presence;
+ GabbleHandleSet *presence_handles;
+
+ GHashTable *capabilities;
+ GHashTable *disco_pending;
+ guint caps_serial;
+
+ gboolean dispose_has_run;
+};
+
+typedef struct _DiscoWaiter DiscoWaiter;
+
+struct _DiscoWaiter
+{
+ GabbleHandleRepo *repo;
+ GabbleHandle handle;
+ gchar *resource;
+ guint serial;
+ gboolean disco_requested;
+};
+
+/**
+ * disco_waiter_new ()
+ */
+static DiscoWaiter *
+disco_waiter_new (GabbleHandleRepo *repo, GabbleHandle handle, const gchar *resource, guint serial)
+{
+ DiscoWaiter *waiter;
+
+ g_assert (repo);
+ gabble_handle_ref (repo, TP_HANDLE_TYPE_CONTACT, handle);
+
+ waiter = g_new0 (DiscoWaiter, 1);
+ waiter->repo = repo;
+ waiter->handle = handle;
+ waiter->resource = g_strdup (resource);
+ waiter->serial = serial;
+
+ gabble_debug (DEBUG_FLAG, "created waiter %p for handle %u with serial %u", waiter, handle, serial);
+
+ return waiter;
+}
+
+static void
+disco_waiter_free (DiscoWaiter *waiter)
+{
+ g_assert (NULL != waiter);
+
+ gabble_debug (DEBUG_FLAG, "freeing waiter %p for handle %u with serial %u", waiter, waiter->handle, waiter->serial);
+
+ gabble_handle_unref (waiter->repo, TP_HANDLE_TYPE_CONTACT, waiter->handle);
+
+ g_free (waiter->resource);
+ g_free (waiter);
+}
+
+static void
+disco_waiter_list_free (GSList *list)
+{
+ GSList *i;
+
+ gabble_debug (DEBUG_FLAG, "list %p", list);
+
+ for (i = list; NULL != i; i = i->next)
+ disco_waiter_free ((DiscoWaiter *) i->data);
+
+ g_slist_free (list);
+}
+
+static guint
+disco_waiter_list_get_request_count (GSList *list)
+{
+ guint c = 0;
+ GSList *i;
+
+ for (i = list; i; i = i->next)
+ {
+ DiscoWaiter *waiter = (DiscoWaiter *) i->data;
+
+ if (waiter->disco_requested)
+ c++;
+ }
+
+ return c;
+}
+
+typedef struct _CapabilityInfo CapabilityInfo;
+
+struct _CapabilityInfo
+{
+ GabblePresenceCapabilities caps;
+ GIntSet *guys;
+ guint trust;
+};
+
+static CapabilityInfo *
+capability_info_get (GabblePresenceCache *cache, const gchar *node,
+ GabblePresenceCapabilities caps)
+{
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ CapabilityInfo *info = g_hash_table_lookup (priv->capabilities, node);
+
+ if (NULL == info)
+ {
+ info = g_new0 (CapabilityInfo, 1);
+ info->caps = caps;
+ info->guys = g_intset_new ();
+ g_hash_table_insert (priv->capabilities, g_strdup (node), info);
+ }
+
+ return info;
+}
+
+static guint
+capability_info_recvd (GabblePresenceCache *cache, const gchar *node,
+ GabbleHandle handle, GabblePresenceCapabilities caps)
+{
+ CapabilityInfo *info = capability_info_get (cache, node, caps);
+
+ /* Detect inconsistency in reported caps */
+ if (info->caps != caps)
+ {
+ g_intset_clear (info->guys);
+ info->caps = caps;
+ info->trust = 0;
+ }
+
+ if (!g_intset_is_member (info->guys, handle))
+ {
+ g_intset_add (info->guys, handle);
+ info->trust++;
+ }
+
+ return info->trust;
+}
+
+static void gabble_presence_cache_init (GabblePresenceCache *presence_cache);
+static GObject * gabble_presence_cache_constructor (GType type, guint n_props,
+ GObjectConstructParam *props);
+static void gabble_presence_cache_dispose (GObject *object);
+static void gabble_presence_cache_finalize (GObject *object);
+static void gabble_presence_cache_set_property (GObject *object, guint
+ property_id, const GValue *value, GParamSpec *pspec);
+static void gabble_presence_cache_get_property (GObject *object, guint
+ property_id, GValue *value, GParamSpec *pspec);
+static GabblePresence *_cache_insert (GabblePresenceCache *cache,
+ GabbleHandle handle);
+
+static void gabble_presence_cache_status_changed_cb (GabbleConnection *,
+ TpConnectionStatus, TpConnectionStatusReason, gpointer);
+static LmHandlerResult gabble_presence_cache_lm_message_cb (LmMessageHandler*,
+ LmConnection*, LmMessage*, gpointer);
+
+static void
+gabble_presence_cache_class_init (GabblePresenceCacheClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (object_class, sizeof (GabblePresenceCachePrivate));
+
+ object_class->constructor = gabble_presence_cache_constructor;
+
+ object_class->dispose = gabble_presence_cache_dispose;
+ object_class->finalize = gabble_presence_cache_finalize;
+
+ object_class->get_property = gabble_presence_cache_get_property;
+ object_class->set_property = gabble_presence_cache_set_property;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "presence cache.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class,
+ PROP_CONNECTION,
+ param_spec);
+
+ signals[PRESENCE_UPDATE] = g_signal_new (
+ "presence-update",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals[NICKNAME_UPDATE] = g_signal_new (
+ "nickname-update",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals[CAPABILITIES_UPDATE] = g_signal_new (
+ "capabilities-update",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ gabble_presence_cache_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+}
+
+static void
+gabble_presence_cache_init (GabblePresenceCache *cache)
+{
+ GabblePresenceCachePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (cache,
+ GABBLE_TYPE_PRESENCE_CACHE, GabblePresenceCachePrivate);
+
+ cache->priv = priv;
+
+ priv->presence = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
+ priv->capabilities = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->disco_pending = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, (GDestroyNotify) disco_waiter_list_free);
+ priv->caps_serial = 1;
+}
+
+static GObject *
+gabble_presence_cache_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabblePresenceCachePrivate *priv;
+
+ obj = G_OBJECT_CLASS (gabble_presence_cache_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_PRESENCE_CACHE_PRIV (GABBLE_PRESENCE_CACHE (obj));
+
+ priv->status_changed_cb = g_signal_connect (priv->conn, "status-changed",
+ G_CALLBACK (gabble_presence_cache_status_changed_cb), obj);
+
+ return obj;
+}
+
+static void
+gabble_presence_cache_dispose (GObject *object)
+{
+ GabblePresenceCache *self = GABBLE_PRESENCE_CACHE (object);
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+
+ priv->dispose_has_run = TRUE;
+
+ g_assert (priv->lm_message_cb == NULL);
+
+ g_signal_handler_disconnect (priv->conn, priv->status_changed_cb);
+
+ g_hash_table_destroy (priv->presence);
+ priv->presence = NULL;
+
+ handle_set_destroy (priv->presence_handles);
+ priv->presence_handles = NULL;
+
+ if (G_OBJECT_CLASS (gabble_presence_cache_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_presence_cache_parent_class)->dispose (object);
+}
+
+static void
+gabble_presence_cache_finalize (GObject *object)
+{
+ gabble_debug (DEBUG_FLAG, "called with %p", object);
+
+ G_OBJECT_CLASS (gabble_presence_cache_parent_class)->finalize (object);
+}
+
+static void
+gabble_presence_cache_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (object);
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_presence_cache_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (object);
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ GabbleHandleSet *new_presence_handles;
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ new_presence_handles = handle_set_new (priv->conn->handles, TP_HANDLE_TYPE_CONTACT);
+
+ if (priv->presence_handles)
+ {
+ const GIntSet *add;
+ GIntSet *tmp;
+ add = handle_set_peek (priv->presence_handles);
+ tmp = handle_set_update (new_presence_handles, add);
+ handle_set_destroy (priv->presence_handles);
+ g_intset_destroy (tmp);
+ }
+ priv->presence_handles = new_presence_handles;
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+#if 0
+static gboolean
+_presence_node_has_google_voice (LmMessageNode *pres_node)
+{
+ LmMessageNode *node;
+ const gchar *cap_ext;
+ gchar **features, **tmp;
+ gboolean found = FALSE;
+
+ node = lm_message_node_get_child_with_namespace (pres_node, "c", NS_CAPS);
+
+ if (node == NULL);
+ return FALSE;
+
+ cap_ext = lm_message_node_get_attribute (node, "ext");
+
+ if (cap_ext == NULL);
+ return FALSE;
+
+ features = g_strsplit (cap_ext, " ", 0);
+
+ for (tmp = features; *tmp; tmp++)
+ {
+ if (!g_strdiff (tmp, "voice-v1"))
+ {
+ found = TRUE;
+ break;
+ }
+ }
+
+ g_strfreev (features);
+
+ return found;
+}
+#endif
+
+static void
+gabble_presence_cache_status_changed_cb (GabbleConnection *conn,
+ TpConnectionStatus status,
+ TpConnectionStatusReason reason,
+ gpointer data)
+{
+ GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (data);
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+
+ g_assert (conn == priv->conn);
+
+ switch (status)
+ {
+ case TP_CONN_STATUS_CONNECTING:
+ g_assert (priv->lm_message_cb == NULL);
+
+ priv->lm_message_cb = lm_message_handler_new (gabble_presence_cache_lm_message_cb,
+ cache, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn,
+ priv->lm_message_cb,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_HANDLER_PRIORITY_LAST);
+ lm_connection_register_message_handler (priv->conn->lmconn,
+ priv->lm_message_cb,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_FIRST);
+ break;
+ case TP_CONN_STATUS_CONNECTED:
+ /* TODO: emit self presence */
+ break;
+ case TP_CONN_STATUS_DISCONNECTED:
+ g_assert (priv->lm_message_cb != NULL);
+
+ lm_connection_unregister_message_handler (conn->lmconn,
+ priv->lm_message_cb,
+ LM_MESSAGE_TYPE_PRESENCE);
+ lm_connection_unregister_message_handler (conn->lmconn,
+ priv->lm_message_cb,
+ LM_MESSAGE_TYPE_MESSAGE);
+ lm_message_handler_unref (priv->lm_message_cb);
+ priv->lm_message_cb = NULL;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static GabblePresenceId
+_presence_node_get_status (LmMessageNode *pres_node)
+{
+ const gchar *presence_show;
+ LmMessageNode *child_node = lm_message_node_get_child (pres_node, "show");
+
+ if (!child_node)
+ {
+ /*
+ NODE_DEBUG (pres_node,
+ "<presence> without <show> received from server, "
+ "setting presence to available");
+ */
+ return GABBLE_PRESENCE_AVAILABLE;
+ }
+
+ presence_show = lm_message_node_get_value (child_node);
+
+ if (!presence_show)
+ {
+ /*
+ NODE_DEBUG (pres_node,
+ "empty <show> tag received from server, "
+ "setting presence to available");
+ */
+ return GABBLE_PRESENCE_AVAILABLE;
+ }
+
+ if (0 == strcmp (presence_show, JABBER_PRESENCE_SHOW_AWAY))
+ return GABBLE_PRESENCE_AWAY;
+ else if (0 == strcmp (presence_show, JABBER_PRESENCE_SHOW_CHAT))
+ return GABBLE_PRESENCE_CHAT;
+ else if (0 == strcmp (presence_show, JABBER_PRESENCE_SHOW_DND))
+ return GABBLE_PRESENCE_DND;
+ else if (0 == strcmp (presence_show, JABBER_PRESENCE_SHOW_XA))
+ return GABBLE_PRESENCE_XA;
+ else
+ {
+ NODE_DEBUG (pres_node,
+ "unrecognised <show/> value received from server, "
+ "setting presence to available");
+ return GABBLE_PRESENCE_AVAILABLE;
+ }
+}
+
+static void
+_grab_nickname (GabblePresenceCache *cache,
+ GabbleHandle handle,
+ const gchar *from,
+ LmMessageNode *node)
+{
+ const gchar *nickname;
+ GabblePresence *presence;
+
+ node = lm_message_node_get_child_with_namespace (node, "nick", NS_NICK);
+
+ if (NULL == node)
+ return;
+
+ presence = gabble_presence_cache_get (cache, handle);
+
+ if (NULL == presence)
+ return;
+
+ nickname = lm_message_node_get_value (node);
+ gabble_debug (DEBUG_FLAG, "got nickname \"%s\" for %s", nickname, from);
+
+ if (g_strdiff (presence->nickname, nickname))
+ {
+ if (NULL != presence->nickname)
+ g_free (presence->nickname);
+
+ presence->nickname = g_strdup (nickname);
+ g_signal_emit (cache, signals[NICKNAME_UPDATE], 0, handle);
+ }
+}
+
+static GSList *
+_extract_cap_bundles (LmMessageNode *lm_node)
+{
+ const gchar *node, *ver, *ext;
+ GSList *uris = NULL;
+ LmMessageNode *cap_node;
+
+ cap_node = lm_message_node_get_child_with_namespace (lm_node, "c", NS_CAPS);
+
+ if (NULL == cap_node)
+ return NULL;
+
+ node = lm_message_node_get_attribute (cap_node, "node");
+
+ if (NULL == node)
+ return NULL;
+
+ ver = lm_message_node_get_attribute (cap_node, "ver");
+
+ if (NULL != ver)
+ uris = g_slist_prepend (uris, g_strdup_printf ("%s#%s", node, ver));
+
+ ext = lm_message_node_get_attribute (cap_node, "ext");
+
+ if (NULL != ext)
+ {
+ gchar **exts, **i;
+
+ exts = g_strsplit (ext, " ", 0);
+
+ for (i = exts; NULL != *i; i++)
+ uris = g_slist_prepend (uris, g_strdup_printf ("%s#%s", node, *i));
+
+ g_strfreev (exts);
+ }
+
+ return uris;
+}
+
+static void
+_caps_disco_cb (GabbleDisco *disco,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *query_result,
+ GError *error,
+ gpointer user_data)
+{
+ GSList *waiters, *i;
+ LmMessageNode *child;
+ GabblePresenceCache *cache;
+ GabblePresenceCachePrivate *priv;
+ gchar *full_jid = NULL;
+ GabblePresenceCapabilities caps = 0;
+ guint trust;
+ GabbleHandle handle;
+
+ cache = GABBLE_PRESENCE_CACHE (user_data);
+ priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+
+ if (NULL == node)
+ {
+ g_warning ("got disco response with NULL node, ignoring");
+ return;
+ }
+
+ waiters = g_hash_table_lookup (priv->disco_pending, node);
+
+ if (NULL != error)
+ {
+ DiscoWaiter *waiter = NULL;
+
+ gabble_debug (DEBUG_FLAG, "disco query failed: %s", error->message);
+
+ for (i = waiters; NULL != i; i = i->next)
+ {
+ waiter = (DiscoWaiter *) i->data;
+
+ if (!waiter->disco_requested)
+ {
+ const gchar *jid;
+
+ jid = gabble_handle_inspect (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ waiter->handle);
+ full_jid = g_strdup_printf ("%s/%s", jid, waiter->resource);
+
+ gabble_disco_request (disco, GABBLE_DISCO_TYPE_INFO, full_jid, node,
+ _caps_disco_cb, cache, G_OBJECT(cache), NULL);
+ waiter->disco_requested = TRUE;
+ break;
+ }
+ }
+
+ if (NULL != i)
+ {
+ gabble_debug (DEBUG_FLAG, "sent a retry disco request to %s for URI %s", full_jid, node);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "failed to find a suitable candidate to retry disco request for URI %s", node);
+ /* FIXME do something very clever here? */
+ g_hash_table_remove (priv->disco_pending, node);
+ }
+
+ goto OUT;
+ }
+
+ for (child = query_result->children; NULL != child; child = child->next)
+ {
+ const gchar *var;
+
+ if (0 != strcmp (child->name, "feature"))
+ continue;
+
+ var = lm_message_node_get_attribute (child, "var");
+
+ if (NULL == var)
+ continue;
+
+ /* TODO: use a table that equates disco features to caps */
+ if (0 == strcmp (var, NS_GOOGLE_TRANSPORT_P2P))
+ caps |= PRESENCE_CAP_GOOGLE_TRANSPORT_P2P;
+ else if (0 == strcmp (var, NS_GOOGLE_FEAT_VOICE))
+ caps |= PRESENCE_CAP_GOOGLE_VOICE;
+ else if (0 == strcmp (var, NS_JINGLE))
+ caps |= PRESENCE_CAP_JINGLE;
+ else if (0 == strcmp (var, NS_JINGLE_DESCRIPTION_AUDIO))
+ caps |= PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO;
+ else if (0 == strcmp (var, NS_JINGLE_DESCRIPTION_VIDEO))
+ caps |= PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO;
+ }
+
+ handle = gabble_handle_for_contact (priv->conn->handles, jid, FALSE);
+ trust = capability_info_recvd (cache, node, handle, caps);
+
+ for (i = waiters; NULL != i;)
+ {
+ DiscoWaiter *waiter;
+ GabblePresence *presence;
+
+ waiter = (DiscoWaiter *) i->data;
+
+ if (trust >= CAPABILITY_BUNDLE_ENOUGH_TRUST || waiter->handle == handle)
+ {
+ GSList *tmp;
+ /* trusted reply */
+ presence = gabble_presence_cache_get (cache, waiter->handle);
+
+ if (presence)
+ {
+ GabblePresenceCapabilities save_caps = presence->caps;
+ gabble_debug (DEBUG_FLAG, "setting caps for %d (%s) to %d", handle, jid, caps);
+ gabble_presence_set_capabilities (presence, waiter->resource,caps,
+ waiter->serial);
+ gabble_debug (DEBUG_FLAG, "caps for %d (%s) now %d", handle, jid, presence->caps);
+ g_signal_emit (cache, signals[CAPABILITIES_UPDATE], 0,
+ waiter->handle, save_caps, presence->caps);
+ }
+
+ tmp = i;
+ i = i->next;
+
+ waiters = g_slist_delete_link (waiters, tmp);
+
+ g_hash_table_steal (priv->disco_pending, node);
+ g_hash_table_insert (priv->disco_pending, g_strdup (node), waiters);
+
+ disco_waiter_free (waiter);
+ }
+ else if (trust + disco_waiter_list_get_request_count (waiters) - 1
+ < CAPABILITY_BUNDLE_ENOUGH_TRUST)
+ {
+ /* if the possible trust, not counting this guy, is too low,
+ * we have been poisoned and reset our trust meters - disco
+ * anybody we still haven't to be able to get more trusted replies */
+
+ if (!waiter->disco_requested)
+ {
+ const gchar *jid;
+
+ jid = gabble_handle_inspect (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, waiter->handle);
+ full_jid = g_strdup_printf ("%s/%s", jid, waiter->resource);
+
+ gabble_disco_request (disco, GABBLE_DISCO_TYPE_INFO, full_jid,
+ node, _caps_disco_cb, cache, G_OBJECT(cache), NULL);
+ waiter->disco_requested = TRUE;
+
+ g_free (full_jid);
+ full_jid = NULL;
+ }
+
+ i = i->next;
+ }
+ else
+ {
+ /* trust level still uncertain, don't do nothing */
+ i = i->next;
+ }
+ }
+
+ if (trust >= CAPABILITY_BUNDLE_ENOUGH_TRUST)
+ g_hash_table_remove (priv->disco_pending, node);
+
+OUT:
+
+ g_free (full_jid);
+}
+
+static void
+_process_caps_uri (GabblePresenceCache *cache,
+ const gchar *from,
+ const gchar *uri,
+ GabbleHandle handle,
+ const gchar *resource,
+ guint serial)
+{
+ CapabilityInfo *info;
+ gpointer value;
+ GabblePresenceCachePrivate *priv;
+
+ priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ info = capability_info_get (cache, uri, 0);
+
+ if (info->trust >= CAPABILITY_BUNDLE_ENOUGH_TRUST
+ || g_intset_is_member (info->guys, handle))
+ {
+ /* we already have enough trust for this node; apply the cached value to
+ * the (handle, resource) */
+
+ GabblePresence *presence = gabble_presence_cache_get (cache, handle);
+ gabble_debug (DEBUG_FLAG, "enough trust for URI %s, setting caps for %u (%s) to %u",
+ uri, handle, from, info->caps);
+
+ if (presence)
+ {
+ GabblePresenceCapabilities save_caps = presence->caps;
+ gabble_presence_set_capabilities (presence, resource, info->caps, serial);
+ g_signal_emit (cache, signals[CAPABILITIES_UPDATE], 0,
+ handle, save_caps, presence->caps);
+ gabble_debug (DEBUG_FLAG, "caps for %d (%s) now %d", handle, from, presence->caps);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "presence not found");
+ }
+ }
+ else
+ {
+ /* Append the (handle, resource) pair to the list of such pairs
+ * waiting for capabilities for this uri, and send a disco request
+ * if we don't have enough possible trust yet */
+
+ GSList *waiters;
+ DiscoWaiter *waiter;
+ guint possible_trust;
+
+ gabble_debug (DEBUG_FLAG, "not enough trust for URI %s", uri);
+ value = g_hash_table_lookup (priv->disco_pending, uri);
+
+ if (value)
+ g_hash_table_steal (priv->disco_pending, uri);
+
+ waiters = (GSList *) value;
+ waiter = disco_waiter_new (priv->conn->handles, handle, resource, serial);
+ waiters = g_slist_prepend (waiters, waiter);
+ g_hash_table_insert (priv->disco_pending, g_strdup (uri), waiters);
+
+ possible_trust = disco_waiter_list_get_request_count (waiters);
+
+ if (!value || info->trust + possible_trust < CAPABILITY_BUNDLE_ENOUGH_TRUST)
+ {
+ /* DISCO */
+ gabble_debug (DEBUG_FLAG, "only %u trust out of %u possible thus far, sending disco for URI %s",
+ info->trust + possible_trust, CAPABILITY_BUNDLE_ENOUGH_TRUST, uri);
+ gabble_disco_request (priv->conn->disco, GABBLE_DISCO_TYPE_INFO,
+ from, uri, _caps_disco_cb, cache, G_OBJECT (cache), NULL);
+ /* enough DISCO for you, buddy */
+ waiter->disco_requested = TRUE;
+ }
+ }
+}
+
+static void
+_process_caps (GabblePresenceCache *cache,
+ GabbleHandle handle,
+ const gchar *from,
+ LmMessageNode *lm_node)
+{
+ gchar *resource;
+ GSList *uris, *i;
+ GabblePresenceCachePrivate *priv;
+ guint serial;
+
+ priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ serial = priv->caps_serial++;
+
+ gabble_decode_jid (from, NULL, NULL, &resource);
+
+ if (NULL == resource)
+ return;
+
+ uris = _extract_cap_bundles (lm_node);
+
+ for (i = uris; NULL != i; i = i->next)
+ {
+ _process_caps_uri (cache, from, (gchar *) i->data, handle, resource, serial);
+ g_free (i->data);
+ }
+
+ g_free (resource);
+ g_slist_free (uris);
+}
+
+static void
+_grab_avatar_sha1 (GabblePresenceCache *cache,
+ GabbleHandle handle,
+ const gchar *from,
+ LmMessageNode *node)
+{
+ const gchar *sha1;
+ LmMessageNode *x_node, *photo_node;
+ GabblePresence *presence;
+ //LIB_TRACE( ELibTraceTypeInfo, "%s", "Out _grab_avatar_sha1" );
+ presence = gabble_presence_cache_get (cache, handle);
+
+ if (NULL == presence)
+ return;
+
+ x_node = lm_message_node_get_child_with_namespace (node, "x",
+ NS_VCARD_TEMP_UPDATE);
+
+ if (NULL == x_node)
+ {
+#if 0
+ if (handle == priv->conn->parent.self_handle)
+ {
+ /* One of my other resources does not support XEP-0153. As per that
+ * XEP, I MUST stop advertising the image hash, at least until all
+ * instances of non-conforming resources have gone offline.
+ * However, we're going to ignore this requirement and hope that
+ * non-conforming clients won't alter the <PHOTO>, which should
+ * in practice be true.
+ */
+ presence->avatar_sha1 = NULL;
+ }
+#endif
+ return;
+ }
+
+ photo_node = lm_message_node_get_child (x_node, "photo");
+
+ /* If there is no photo node, the resource supports XEP-0153, but has
+ * nothing in particular to say about the avatar. */
+ if (NULL == photo_node)
+ return;
+
+ sha1 = lm_message_node_get_value (photo_node);
+
+ if (g_strdiff (presence->avatar_sha1, sha1))
+ {
+ g_free (presence->avatar_sha1);
+ presence->avatar_sha1 = g_strdup (sha1);
+
+#if 0
+ if (handle == priv->conn->parent.self_handle)
+ {
+ /* that would be us, then. According to XEP-0153, we MUST
+ * immediately send a presence update with an empty update child
+ * element (no photo node), then re-download our own vCard;
+ * when that arrives, we may start setting the photo node in our
+ * presence again.
+ *
+ * For the moment I'm going to ignore that requirement and
+ * trust that our other resource is getting its sha1 right!
+ */
+ /* TODO: I don't trust anyone to get XMPP right, so let's do
+ * this. :D */
+ }
+#endif
+ //LIB_TRACE( ELibTraceTypeInfo, "%s", "AVATAR_UPDATE _grab_avatar_sha1" );
+ //g_signal_emit (cache, signals[AVATAR_UPDATE], 0, handle);
+ }
+ //LIB_TRACE( ELibTraceTypeInfo, "%s", "Out _grab_avatar_sha1" );
+}
+
+static LmHandlerResult
+_parse_presence_message (GabblePresenceCache *cache,
+ GabbleHandle handle,
+ const gchar *from,
+ LmMessage *message)
+{
+ gint8 priority = 0;
+ gchar *resource = NULL;
+ const gchar *status_message = NULL;
+ LmMessageNode *presence_node, *child_node;
+ LmHandlerResult ret = LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ GabblePresenceId presence_id;
+ GabblePresence *presence;
+
+ presence_node = message->node;
+ g_assert (0 == strcmp (presence_node->name, "presence"));
+
+ gabble_decode_jid (from, NULL, NULL, &resource);
+
+ presence = gabble_presence_cache_get (cache, handle);
+
+ if (NULL != presence)
+ presence->keep_unavailable = FALSE;
+
+ child_node = lm_message_node_get_child (presence_node, "status");
+
+ if (child_node)
+ status_message = lm_message_node_get_value (child_node);
+
+ child_node = lm_message_node_get_child (presence_node, "priority");
+
+ if (child_node)
+ {
+ const gchar *prio = lm_message_node_get_value (child_node);
+
+ if (prio != NULL)
+ priority = CLAMP (atoi (prio), G_MININT8, G_MAXINT8);
+ }
+
+ switch (lm_message_get_sub_type (message))
+ {
+ case LM_MESSAGE_SUB_TYPE_NOT_SET:
+ case LM_MESSAGE_SUB_TYPE_AVAILABLE:
+ presence_id = _presence_node_get_status (presence_node);
+ gabble_presence_cache_update (cache, handle, resource, presence_id,
+ status_message, priority);
+
+#if 0
+ if (_presence_node_has_google_voice (presence_node))
+ {
+ presence = gabble_presence_cache_get (cache, handle);
+ g_assert (NULL != presence);
+ gabble_debug (DEBUG_FLAG, "%s has voice-v1 support", from);
+ gabble_presence_set_capabilities (presence, resource,
+ PRESENCE_CAP_GOOGLE_VOICE);
+ }
+#endif
+
+ ret = LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ break;
+
+ case LM_MESSAGE_SUB_TYPE_ERROR:
+ NODE_DEBUG (presence_node, "setting contact offline due to error");
+ /* fall through */
+
+ case LM_MESSAGE_SUB_TYPE_UNAVAILABLE:
+ gabble_presence_cache_update (cache, handle, resource,
+ GABBLE_PRESENCE_OFFLINE, status_message, priority);
+
+ ret = LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ break;
+
+ default:
+ break;
+ }
+
+ _grab_avatar_sha1 (cache, handle, from, presence_node);
+ _grab_nickname (cache, handle, from, presence_node);
+ _process_caps (cache, handle, from, presence_node);
+
+ g_free (resource);
+
+ return ret;
+}
+
+static LmHandlerResult
+_parse_message_message (GabblePresenceCache *cache,
+ GabbleHandle handle,
+ const gchar *from,
+ LmMessage *message)
+{
+ LmMessageNode *node;
+ GabblePresence *presence;
+
+ presence = gabble_presence_cache_get (cache, handle);
+
+ if (NULL == presence)
+ {
+ presence = _cache_insert (cache, handle);
+ presence->keep_unavailable = TRUE;
+ }
+
+ node = lm_message_get_node (message);
+
+ _grab_nickname (cache, handle, from, node);
+ _process_caps (cache, handle, from, node);
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+
+/**
+ * gabble_presence_cache_lm_message_cb:
+ * @handler: #LmMessageHandler for this message
+ * @connection: #LmConnection that originated the message
+ * @message: the presence message
+ * @user_data: callback data
+ *
+ * Called by loudmouth when we get an incoming <presence>.
+ */
+static LmHandlerResult
+gabble_presence_cache_lm_message_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (user_data);
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ const char *from;
+ GabbleHandle handle;
+
+ g_assert (lmconn == priv->conn->lmconn);
+
+ from = lm_message_node_get_attribute (message->node, "from");
+
+ if (NULL == from)
+ {
+ NODE_DEBUG (message->node, "message without from attribute, ignoring");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ handle = gabble_handle_for_contact (priv->conn->handles, from, FALSE);
+
+ if (0 == handle)
+ {
+ NODE_DEBUG (message->node, "ignoring message from malformed jid");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (handle == priv->conn->self_handle)
+ {
+ NODE_DEBUG (message->node,
+ "ignoring message from ourselves on another resource");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ switch (lm_message_get_type (message))
+ {
+ case LM_MESSAGE_TYPE_PRESENCE:
+ return _parse_presence_message (cache, handle, from, message);
+ case LM_MESSAGE_TYPE_MESSAGE:
+ return _parse_message_message (cache, handle, from, message);
+ default:
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+}
+
+
+GabblePresenceCache *
+gabble_presence_cache_new (GabbleConnection *conn)
+{
+ return g_object_new (GABBLE_TYPE_PRESENCE_CACHE,
+ "connection", conn,
+ NULL);
+}
+
+GabblePresence *
+gabble_presence_cache_get (GabblePresenceCache *cache, GabbleHandle handle)
+{
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+
+
+// g_assert (gabble_handle_is_valid (priv->conn->handles,
+// TP_HANDLE_TYPE_CONTACT, handle, NULL));
+ if(priv)
+ if(priv->conn)
+ if(priv->conn->handles){
+ if ( gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL) )
+ {
+ return g_hash_table_lookup (priv->presence, GINT_TO_POINTER (handle));
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+void
+gabble_presence_cache_maybe_remove (
+ GabblePresenceCache *cache,
+ GabbleHandle handle)
+{
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ GabblePresence *presence;
+
+ presence = gabble_presence_cache_get (cache, handle);
+
+ if (NULL == presence)
+ return;
+
+ if (presence->status == GABBLE_PRESENCE_OFFLINE &&
+ presence->status_message == NULL &&
+ !presence->keep_unavailable)
+ {
+ const gchar *jid;
+
+ jid = gabble_handle_inspect (priv->conn->handles, TP_HANDLE_TYPE_CONTACT,
+ handle);
+ gabble_debug (DEBUG_FLAG, "discarding cached presence for unavailable jid %s", jid);
+ g_hash_table_remove (priv->presence, GINT_TO_POINTER (handle));
+ handle_set_remove (priv->presence_handles, handle);
+ }
+}
+
+static GabblePresence *
+_cache_insert (
+ GabblePresenceCache *cache,
+ GabbleHandle handle)
+{
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ GabblePresence *presence;
+
+ presence = gabble_presence_new ();
+ g_hash_table_insert (priv->presence, GINT_TO_POINTER (handle), presence);
+ handle_set_add (priv->presence_handles, handle);
+ return presence;
+}
+
+void
+gabble_presence_cache_update (
+ GabblePresenceCache *cache,
+ GabbleHandle handle,
+ const gchar *resource,
+ GabblePresenceId presence_id,
+ const gchar *status_message,
+ gint8 priority)
+{
+ GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
+ const gchar *jid;
+ GabblePresence *presence;
+
+ jid = gabble_handle_inspect (priv->conn->handles, TP_HANDLE_TYPE_CONTACT,
+ handle);
+ gabble_debug (DEBUG_FLAG, "%s (%d) resource %s prio %d presence %d message \"%s\"",
+ jid, handle, resource, priority, presence_id, status_message);
+
+ presence = gabble_presence_cache_get (cache, handle);
+
+ if (presence == NULL)
+ presence = _cache_insert (cache, handle);
+
+ if (gabble_presence_update (presence, resource, presence_id, status_message,
+ priority))
+ g_signal_emit (cache, signals[PRESENCE_UPDATE], 0, handle);
+
+ gabble_presence_cache_maybe_remove (cache, handle);
+}
+
+void gabble_presence_cache_add_bundle_caps (GabblePresenceCache *cache,
+ const gchar *node, GabblePresenceCapabilities new_caps)
+{
+ CapabilityInfo *info;
+
+ info = capability_info_get (cache, node, 0);
+ info->trust = CAPABILITY_BUNDLE_ENOUGH_TRUST;
+ info->caps |= new_caps;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-presence.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,448 @@
+/*
+ * gabble-presence.c - Gabble's per-contact presence structure
+ * Copyright (C) 2005 Collabora Ltd.
+ * and/or its subsidiaries. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <string.h>
+#include <glib.h>
+
+#include "gabble-presence-cache.h"
+#include "gabble-presence.h"
+#include "util.h"
+
+#include "config.h"
+#define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
+#include "debug.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE (GabblePresence, gabble_presence, G_TYPE_OBJECT);
+#endif
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(gabble_presence_parent_class,gabble_presence,gpointer)
+ #define gabble_presence_parent_class (*GET_WSD_VAR_NAME(gabble_presence_parent_class,gabble_presence,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_presence,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_presence,s)())
+
+static void gabble_presence_init (GabblePresence *self);
+static void gabble_presence_class_init (GabblePresenceClass *klass);
+static void gabble_presence_class_intern_init (gpointer klass)
+{
+gabble_presence_parent_class = g_type_class_peek_parent (klass);
+gabble_presence_class_init ((GabblePresenceClass*) klass);
+}
+ EXPORT_C GType gabble_presence_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ { static const GTypeInfo g_define_type_info =
+ { sizeof (GabblePresenceClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_presence_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabblePresence), 0, (GInstanceInitFunc) gabble_presence_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabblePresence"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ } ;
+
+#endif
+
+#define GABBLE_PRESENCE_PRIV(account) ((GabblePresencePrivate *)account->priv)
+
+typedef struct _Resource Resource;
+
+struct _Resource {
+ gchar *name;
+ GabblePresenceCapabilities caps;
+ guint caps_serial;
+ GabblePresenceId status;
+ gchar *status_message;
+ gint8 priority;
+};
+
+typedef struct _GabblePresencePrivate GabblePresencePrivate;
+
+struct _GabblePresencePrivate {
+ gchar *no_resource_status_message;
+ GSList *resources;
+};
+
+static Resource *
+_resource_new (gchar *name)
+{
+ Resource *new = g_new (Resource, 1);
+ new->name = name;
+ new->caps = PRESENCE_CAP_NONE;
+ new->status = GABBLE_PRESENCE_OFFLINE;
+ new->status_message = NULL;
+ new->priority = 0;
+ new->caps_serial = 0;
+ return new;
+}
+
+static void
+_resource_free (Resource *resource)
+{
+ g_free (resource->status_message);
+ g_free (resource);
+}
+
+static void
+gabble_presence_finalize (GObject *object)
+{
+ GSList *i;
+ GabblePresence *presence = GABBLE_PRESENCE (object);
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+
+ for (i = priv->resources; NULL != i; i = i->next)
+ _resource_free (i->data);
+
+ g_slist_free (priv->resources);
+ g_free (presence->nickname);
+ g_free (priv->no_resource_status_message);
+}
+
+static void
+gabble_presence_class_init (GabblePresenceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (object_class, sizeof (GabblePresencePrivate));
+ object_class->finalize = gabble_presence_finalize;
+}
+
+static void
+gabble_presence_init (GabblePresence *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_PRESENCE, GabblePresencePrivate);
+ ((GabblePresencePrivate *)self->priv)->resources = NULL;
+}
+
+
+GabblePresence*
+gabble_presence_new (void)
+{
+ return g_object_new (GABBLE_TYPE_PRESENCE, NULL);
+}
+
+
+const gchar *
+gabble_presence_pick_resource_by_caps (
+ GabblePresence *presence,
+ GabblePresenceCapabilities caps)
+{
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+ GSList *i;
+ Resource *chosen = NULL;
+
+ for (i = priv->resources; NULL != i; i = i->next)
+ {
+ Resource *res = (Resource *) i->data;
+
+ if ((res->priority >= 0) &&
+ ((res->caps & caps) == caps) &&
+ (NULL == chosen || res->priority > chosen->priority))
+ chosen = res;
+ }
+
+ if (chosen)
+ return chosen->name;
+ else
+ return NULL;
+}
+
+gboolean
+gabble_presence_resource_has_caps (GabblePresence *presence,
+ const gchar *resource,
+ GabblePresenceCapabilities caps)
+{
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+ GSList *i;
+
+ for (i = priv->resources; NULL != i; i = i->next)
+ {
+ Resource *res = (Resource *) i->data;
+
+ if (!g_strdiff (res->name, resource) && (res->caps & caps))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+void
+gabble_presence_set_capabilities (GabblePresence *presence,
+ const gchar *resource,
+ GabblePresenceCapabilities caps,
+ guint serial)
+{
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+ GSList *i;
+ g_message("[gabble_presence_set_capabilities]\n");
+ presence->caps = 0;
+
+ gabble_debug (DEBUG_FLAG, "about to add caps %u to resource %s with serial %u", caps, resource,
+ serial);
+
+ for (i = priv->resources; NULL != i; i = i->next)
+ {
+ Resource *tmp = (Resource *) i->data;
+
+ if (0 == strcmp (tmp->name, resource))
+ {
+ gabble_debug (DEBUG_FLAG, "found resource %s", resource);
+
+ if (serial > tmp->caps_serial)
+ {
+ gabble_debug (DEBUG_FLAG, "new serial %u, old %u, clearing caps", serial,
+ tmp->caps_serial);
+ tmp->caps = 0;
+ tmp->caps_serial = serial;
+ }
+
+ if (serial >= tmp->caps_serial)
+ {
+ gabble_debug (DEBUG_FLAG, "adding caps %u to resource %s", caps, resource);
+ tmp->caps |= caps;
+ gabble_debug (DEBUG_FLAG, "resource %s caps now %u", resource, tmp->caps);
+ }
+ }
+
+ presence->caps |= tmp->caps;
+ }
+ g_message("[leaving connect_callbacks\n]");
+ gabble_debug (DEBUG_FLAG, "total caps now %u", presence->caps);
+}
+
+static Resource *
+_find_resource (GabblePresence *presence, const gchar *resource)
+{
+ GSList *i;
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+
+ for (i = priv->resources; NULL != i; i = i->next)
+ {
+ Resource *res = (Resource *) i->data;
+
+ if (0 == strcmp (res->name, resource))
+ return res;
+ }
+
+ return NULL;
+}
+
+
+gboolean
+gabble_presence_update (GabblePresence *presence,
+ const gchar *resource,
+ GabblePresenceId status,
+ const gchar *status_message,
+ gint8 priority)
+{
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+ Resource *res;
+ GabblePresenceId old_status;
+ gchar *old_status_message;
+ GSList *i;
+ gint8 prio;
+ gboolean ret = FALSE;
+
+ /* save our current state */
+ old_status = presence->status;
+ old_status_message = g_strdup (presence->status_message);
+
+ if (NULL == resource)
+ {
+ /* presence from a JID with no resource: free all resources and set
+ * presence directly */
+
+ for (i = priv->resources; i; i = i->next)
+ _resource_free (i->data);
+
+ g_slist_free (priv->resources);
+ priv->resources = NULL;
+
+ if (g_strdiff (priv->no_resource_status_message, status_message))
+ {
+ g_free (priv->no_resource_status_message);
+ priv->no_resource_status_message = g_strdup (status_message);
+ }
+
+ presence->status = status;
+ presence->status_message = priv->no_resource_status_message;
+ goto OUT;
+ }
+
+ res = _find_resource (presence, resource);
+
+ /* remove, create or update a Resource as appropriate */
+ if (GABBLE_PRESENCE_OFFLINE == status &&
+ NULL == status_message)
+ {
+ if (NULL != res)
+ {
+ priv->resources = g_slist_remove (priv->resources, res);
+ _resource_free (res);
+ res = NULL;
+ }
+ }
+ else
+ {
+ if (NULL == res)
+ {
+ res = _resource_new (g_strdup (resource));
+ priv->resources = g_slist_append (priv->resources, res);
+ }
+
+ res->status = status;
+
+ if (g_strdiff (res->status_message, status_message))
+ {
+ g_free (res->status_message);
+ res->status_message = g_strdup (status_message);
+ }
+
+ res->priority = priority;
+ }
+
+ /* select the most preferable Resource and update presence->* based on our
+ * choice */
+ presence->caps = 0;
+ presence->status = GABBLE_PRESENCE_OFFLINE;
+
+ /* use the status message from any offline Resource we're
+ * keeping around just because it has a message on it */
+ presence->status_message = res ? res->status_message : NULL;
+
+ prio = -128;
+
+ for (i = priv->resources; NULL != i; i = i->next)
+ {
+ Resource *res = (Resource *) i->data;
+
+ presence->caps |= res->caps;
+
+ /* trump existing status & message if it's more present
+ * or has the same presence and a higher priority */
+ if (res->status > presence->status ||
+ (res->status == presence->status && res->priority > prio))
+ {
+ presence->status = res->status;
+ presence->status_message = res->status_message;
+ prio = res->priority;
+ }
+ }
+
+OUT:
+ /* detect changes */
+ if (presence->status != old_status ||
+ g_strdiff (presence->status_message, old_status_message))
+ ret = TRUE;
+
+ g_free (old_status_message);
+ return ret;
+}
+
+LmMessage *
+gabble_presence_as_message (GabblePresence *presence, const gchar *resource)
+{
+ LmMessage *message;
+ LmMessageNode *node;
+ LmMessageSubType subtype;
+ Resource *res = _find_resource (presence, resource);
+
+ g_assert (NULL != res);
+
+ if (presence->status == GABBLE_PRESENCE_OFFLINE)
+ subtype = LM_MESSAGE_SUB_TYPE_UNAVAILABLE;
+ else
+ subtype = LM_MESSAGE_SUB_TYPE_AVAILABLE;
+
+ message = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_PRESENCE,
+ subtype);
+ node = lm_message_get_node (message);
+
+ switch (presence->status)
+ {
+ case GABBLE_PRESENCE_AVAILABLE:
+ case GABBLE_PRESENCE_OFFLINE:
+ case GABBLE_PRESENCE_HIDDEN:
+ break;
+ case GABBLE_PRESENCE_AWAY:
+ lm_message_node_add_child (node, "show", JABBER_PRESENCE_SHOW_AWAY);
+ break;
+ case GABBLE_PRESENCE_CHAT:
+ lm_message_node_add_child (node, "show", JABBER_PRESENCE_SHOW_CHAT);
+ break;
+ case GABBLE_PRESENCE_DND:
+ lm_message_node_add_child (node, "show", JABBER_PRESENCE_SHOW_DND);
+ break;
+ case GABBLE_PRESENCE_XA:
+ lm_message_node_add_child (node, "show", JABBER_PRESENCE_SHOW_XA);
+ break;
+ default:
+ g_critical ("%s: Unexpected Telepathy presence type", G_STRFUNC);
+ break;
+ }
+
+ if (presence->status_message)
+ lm_message_node_add_child (node, "status", presence->status_message);
+
+ if (res->priority)
+ {
+ gchar *priority = g_strdup_printf ("%d", res->priority);
+ lm_message_node_add_child (node, "priority", priority);
+ g_free (priority);
+ }
+
+ return message;
+}
+
+
+gchar *
+gabble_presence_dump (GabblePresence *presence)
+{
+ GSList *i;
+ GString *ret = g_string_new ("");
+ GabblePresencePrivate *priv = GABBLE_PRESENCE_PRIV (presence);
+
+ g_string_append_printf (ret,
+ "nickname: %s\n"
+ "accumulated status: %d\n"
+ "accumulated status msg: %s\n"
+ "accumulated capabilities: %d\n"
+ "kept while unavailable: %d\n"
+ "resources:\n", presence->nickname, presence->status,
+ presence->status_message, presence->caps,
+ presence->keep_unavailable);
+
+ for (i = priv->resources; i; i = i->next)
+ {
+ Resource *res = (Resource *) i->data;
+
+ g_string_append_printf(ret,
+ " %s\n"
+ " capabilities: %d\n"
+ " status: %d\n"
+ " status msg: %s\n"
+ " priority: %d\n", res->name, res->caps, res->status,
+ res->status_message, res->priority);
+ }
+
+ if (priv->resources == NULL)
+ g_string_append_printf(ret, " (none)\n");
+
+ return g_string_free (ret, FALSE);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-register-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,108 @@
+/*
+ * gabble-register-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:BOOLEAN,INT,STRING (gabble-register-signals-marshal.list:1) */
+void
+gabble_register_marshal_VOID__BOOLEAN_INT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__BOOLEAN_INT_STRING) (gpointer data1,
+ gboolean arg_1,
+ gint arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__BOOLEAN_INT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__BOOLEAN_INT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_boolean (param_values + 1),
+ g_marshal_value_peek_int (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-register.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,393 @@
+/*
+ * gabble-register.c - Source for Gabble account registration
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "telepathy-helpers.h"
+#include "telepathy-errors.h"
+
+#include "gabble-connection.h"
+#include "gabble-error.h"
+#include "gabble-register.h"
+#include "gabble-register-signals-marshal.h"
+#include "namespaces.h"
+#include "util.h"
+
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleRegister, gabble_register, G_TYPE_OBJECT);
+#endif
+
+/* signal enum */
+enum
+{
+ FINISHED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_REGISTER
+#endif
+
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_register,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_register, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_register_parent_class,gabble_register,gpointer)
+ #define gabble_register_parent_class (*GET_WSD_VAR_NAME(gabble_register_parent_class,gabble_register,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_register,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_register,s)())
+
+
+static void gabble_register_init (GabbleRegister *self);
+static void gabble_register_class_init (GabbleRegisterClass *klass);
+static void gabble_register_class_intern_init (gpointer klass)
+{
+ gabble_register_parent_class = g_type_class_peek_parent (klass);
+ gabble_register_class_init ((GabbleRegisterClass*) klass);
+ }
+ EXPORT_C GType gabble_register_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ { static const GTypeInfo g_define_type_info = { sizeof (GabbleRegisterClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_register_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleRegister), 0, (GInstanceInitFunc) gabble_register_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleRegister"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id;
+ } ;
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+
+/* private structure */
+typedef struct _GabbleRegisterPrivate GabbleRegisterPrivate;
+struct _GabbleRegisterPrivate
+{
+ GabbleConnection *conn;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_REGISTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GABBLE_TYPE_REGISTER, GabbleRegisterPrivate))
+
+static void
+gabble_register_init (GabbleRegister *obj)
+{
+}
+
+static void gabble_register_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec);
+static void gabble_register_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec);
+static void gabble_register_dispose (GObject *object);
+static void gabble_register_finalize (GObject *object);
+
+static void
+gabble_register_class_init (GabbleRegisterClass *gabble_register_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_register_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_register_class, sizeof (GabbleRegisterPrivate));
+
+ object_class->get_property = gabble_register_get_property;
+ object_class->set_property = gabble_register_set_property;
+
+ object_class->dispose = gabble_register_dispose;
+ object_class->finalize = gabble_register_finalize;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "GabbleRegister object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ signals[FINISHED] =
+ g_signal_new ("finished",
+ G_OBJECT_CLASS_TYPE (gabble_register_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ gabble_register_marshal_VOID__BOOLEAN_INT_STRING,
+ G_TYPE_NONE, 3, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_STRING);
+}
+
+static void
+gabble_register_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRegister *chan = GABBLE_REGISTER (object);
+ GabbleRegisterPrivate *priv = GABBLE_REGISTER_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_register_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRegister *chan = GABBLE_REGISTER (object);
+ GabbleRegisterPrivate *priv = GABBLE_REGISTER_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+void
+gabble_register_dispose (GObject *object)
+{
+ GabbleRegister *self = GABBLE_REGISTER (object);
+ GabbleRegisterPrivate *priv = GABBLE_REGISTER_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ g_debug ("%s: dispose called", G_STRFUNC);
+
+ if (G_OBJECT_CLASS (gabble_register_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_register_parent_class)->dispose (object);
+}
+
+void
+gabble_register_finalize (GObject *object)
+{
+ g_debug ("%s called with %p", G_STRFUNC, object);
+
+ G_OBJECT_CLASS (gabble_register_parent_class)->finalize (object);
+}
+
+/**
+ * gabble_register_new:
+ *
+ * Creates an object to use for account registration.
+ *
+ * @conn: The #GabbleConnection to register an account on
+ */
+GabbleRegister *
+gabble_register_new (GabbleConnection *conn)
+{
+ g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), NULL);
+ return GABBLE_REGISTER (g_object_new (GABBLE_TYPE_REGISTER,
+ "connection", conn, NULL));
+}
+
+static LmHandlerResult
+set_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ LmMessageNode *node;
+ gint code = NotAvailable;
+ GString *msg;
+
+ msg = g_string_sized_new (30);
+ g_string_append (msg, "Request failed");
+
+ node = lm_message_node_get_child (reply_msg->node, "error");
+ if (node)
+ {
+ GabbleXmppError error;
+
+ error = gabble_xmpp_error_from_node (node);
+ if (error == XMPP_ERROR_CONFLICT)
+ {
+ code = InvalidArgument;
+ }
+
+ if (error != INVALID_XMPP_ERROR)
+ {
+ g_string_append_printf (msg, ": %s",
+ gabble_xmpp_error_string (error));
+ }
+ }
+
+ g_signal_emit (object, signals[FINISHED], 0, FALSE, code, msg->str);
+ g_string_free (msg, TRUE);
+ }
+ else
+ {
+ g_signal_emit (object, signals[FINISHED], 0, TRUE, -1, NULL);
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static LmHandlerResult
+get_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ GabbleRegister *reg = GABBLE_REGISTER (object);
+ GabbleRegisterPrivate *priv = GABBLE_REGISTER_GET_PRIVATE (reg);
+ GError *error = NULL;
+ gint err_code = -1;
+ const gchar *err_msg = NULL;
+ LmMessage *msg = NULL;
+ LmMessageNode *query_node;
+ gchar *username, *password;
+
+ if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ err_code = NotAvailable;
+ err_msg = "Server doesn't support " NS_REGISTER;
+
+ goto OUT;
+ }
+
+ /* sanity check the reply to some degree ... */
+ query_node = lm_message_node_get_child_with_namespace (reply_msg->node,
+ "query", NS_REGISTER);
+
+ if (query_node == NULL)
+ goto ERROR_MALFORMED_REPLY;
+
+ if (!lm_message_node_get_child (query_node, "username"))
+ goto ERROR_MALFORMED_REPLY;
+
+ if (!lm_message_node_get_child (query_node, "password"))
+ goto ERROR_MALFORMED_REPLY;
+
+ /* craft a reply */
+ msg = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ query_node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (query_node, "xmlns", NS_REGISTER);
+
+ g_object_get (priv->conn,
+ "username", &username,
+ "password", &password,
+ NULL);
+
+ lm_message_node_add_child (query_node, "username", username);
+ lm_message_node_add_child (query_node, "password", password);
+
+ g_free (username);
+ g_free (password);
+
+ if (!_gabble_connection_send_with_reply (priv->conn, msg, set_reply_cb,
+ G_OBJECT (reg), NULL, &error))
+ {
+ err_code = error->code;
+ err_msg = error->message;
+ }
+
+ goto OUT;
+
+ERROR_MALFORMED_REPLY:
+ err_code = NotAvailable;
+ err_msg = "Malformed reply";
+
+OUT:
+ if (err_code != -1)
+ {
+ g_signal_emit (reg, signals[FINISHED], 0, FALSE, err_code, err_msg);
+ }
+
+ if (msg)
+ lm_message_unref (msg);
+
+ if (error)
+ g_error_free (error);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+/**
+ * gabble_register_start:
+ *
+ * Start account registration.
+ *
+ * @reg: The #GabbleRegister object performing the registration
+ */
+void gabble_register_start (GabbleRegister *reg)
+{
+ GabbleRegisterPrivate *priv = GABBLE_REGISTER_GET_PRIVATE (reg);
+ LmMessage *msg;
+ LmMessageNode *node;
+ GError *error = NULL;
+
+ msg = lm_message_new_with_sub_type (NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+
+ node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_REGISTER);
+
+ if (!_gabble_connection_send_with_reply (priv->conn, msg, get_reply_cb,
+ G_OBJECT (reg), NULL, &error))
+ {
+ g_signal_emit (reg, signals[FINISHED], 0, FALSE, error->code,
+ error->message);
+ g_error_free (error);
+ }
+
+ lm_message_unref (msg);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-roomlist-channel-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,70 @@
+/*
+ * gabble-roomlist-channel-signals-marshal.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-roomlist-channel.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,734 @@
+/*
+ * gabble-roomlist-channel.c - Source for GabbleRoomlistChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_ROOMLIST
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "handles.h"
+#include "handle-set.h"
+#include "telepathy-constants.h"
+#include "telepathy-interfaces.h"
+#include "telepathy-helpers.h"
+#include "tp-channel-iface.h"
+#include "namespaces.h"
+#include "util.h"
+
+#include "gabble-roomlist-channel.h"
+#include "gabble-roomlist-channel-glue.h"
+#include "gabble-roomlist-channel-signals-marshal.h"
+
+#include "gabble_enums.h"
+
+#define TP_TYPE_ROOM_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), \
+ G_TYPE_INVALID))
+
+#define TP_TYPE_ROOM_LIST (dbus_g_type_get_collection ("GPtrArray", \
+ TP_TYPE_ROOM_STRUCT))
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleRoomlistChannel, gabble_roomlist_channel,
+ G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+#endif
+
+/* signal enum */
+enum
+{
+ CLOSED,
+ GOT_ROOMS,
+ LISTING_ROOMS,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_ROOM_CHNL
+#endif
+
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_room_chnl,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_room_chnl, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_roomlist_channel_parent_class,gabble_room_chnl,gpointer)
+ #define gabble_roomlist_channel_parent_class (*GET_WSD_VAR_NAME(gabble_roomlist_channel_parent_class,gabble_room_chnl,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_room_chnl,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_room_chnl,s)())
+
+
+ static void gabble_roomlist_channel_init (GabbleRoomlistChannel *self);
+ static void gabble_roomlist_channel_class_init (GabbleRoomlistChannelClass *klass);
+ static void gabble_roomlist_channel_class_intern_init (gpointer klass)
+ {
+ gabble_roomlist_channel_parent_class = g_type_class_peek_parent (klass);
+ gabble_roomlist_channel_class_init ((GabbleRoomlistChannelClass*) klass);
+ }
+ EXPORT_C GType gabble_roomlist_channel_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleRoomlistChannelClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_roomlist_channel_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleRoomlistChannel), 0, (GInstanceInitFunc) gabble_roomlist_channel_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleRoomlistChannel"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) ((void *)0) }; g_type_add_interface_static (g_define_type_id, tp_channel_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_CHANNEL_TYPE,
+ PROP_HANDLE_TYPE,
+ PROP_HANDLE,
+ PROP_CONNECTION,
+ PROP_CONFERENCE_SERVER,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleRoomlistChannelPrivate GabbleRoomlistChannelPrivate;
+
+struct _GabbleRoomlistChannelPrivate
+{
+ GabbleConnection *conn;
+ gchar *object_path;
+ gchar *conference_server;
+
+ gboolean closed;
+ gboolean listing;
+
+ gpointer disco_pipeline;
+ GabbleHandleSet *signalled_rooms;
+
+ GPtrArray *pending_room_signals;
+ guint timer_source_id;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE(obj) \
+ ((GabbleRoomlistChannelPrivate *)obj->priv)
+
+#define ROOM_SIGNAL_INTERVAL 300
+
+static gboolean emit_room_signal (gpointer data);
+
+static void
+gabble_roomlist_channel_init (GabbleRoomlistChannel *self)
+{
+ GabbleRoomlistChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_ROOMLIST_CHANNEL, GabbleRoomlistChannelPrivate);
+
+ self->priv = priv;
+
+ priv->pending_room_signals = g_ptr_array_new ();
+}
+
+
+static GObject *
+gabble_roomlist_channel_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleRoomlistChannelPrivate *priv;
+ DBusGConnection *bus;
+
+ obj = G_OBJECT_CLASS (gabble_roomlist_channel_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (GABBLE_ROOMLIST_CHANNEL (obj));
+
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ return obj;
+}
+
+static void
+gabble_roomlist_channel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRoomlistChannel *chan = GABBLE_ROOMLIST_CHANNEL (object);
+ GabbleRoomlistChannelPrivate *priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_CHANNEL_TYPE:
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_ROOM_LIST);
+ break;
+ case PROP_HANDLE_TYPE:
+ g_value_set_uint (value, TP_HANDLE_TYPE_NONE);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, 0);
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ case PROP_CONFERENCE_SERVER:
+ g_value_set_string (value, priv->conference_server);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_roomlist_channel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRoomlistChannel *chan = GABBLE_ROOMLIST_CHANNEL (object);
+ GabbleRoomlistChannelPrivate *priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (chan);
+ GabbleHandleSet *new_signalled_rooms;
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_HANDLE:
+ /* this property is writable in the interface, but not actually
+ * meaningfully changable on this channel, so we do nothing */
+ break;
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ new_signalled_rooms = handle_set_new (priv->conn->handles, TP_HANDLE_TYPE_ROOM);
+ if (priv->signalled_rooms != NULL)
+ {
+ const GIntSet *add;
+ GIntSet *tmp;
+ add = handle_set_peek (priv->signalled_rooms);
+ tmp = handle_set_update (new_signalled_rooms, add);
+ handle_set_destroy (priv->signalled_rooms);
+ g_intset_destroy (tmp);
+ }
+ priv->signalled_rooms = new_signalled_rooms;
+ break;
+ case PROP_CONFERENCE_SERVER:
+ g_free (priv->conference_server);
+ priv->conference_server = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_roomlist_channel_dispose (GObject *object);
+static void gabble_roomlist_channel_finalize (GObject *object);
+
+static void
+gabble_roomlist_channel_class_init (GabbleRoomlistChannelClass *gabble_roomlist_channel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_roomlist_channel_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_roomlist_channel_class, sizeof (GabbleRoomlistChannelPrivate));
+
+ object_class->constructor = gabble_roomlist_channel_constructor;
+
+ object_class->get_property = gabble_roomlist_channel_get_property;
+ object_class->set_property = gabble_roomlist_channel_set_property;
+
+ object_class->dispose = gabble_roomlist_channel_dispose;
+ object_class->finalize = gabble_roomlist_channel_finalize;
+
+ g_object_class_override_property (object_class, PROP_OBJECT_PATH, "object-path");
+ g_object_class_override_property (object_class, PROP_CHANNEL_TYPE, "channel-type");
+ g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type");
+ g_object_class_override_property (object_class, PROP_HANDLE, "handle");
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "room list channel object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ param_spec = g_param_spec_string ("conference-server",
+ "Name of conference server to use",
+ "Name of the XMPP conference server "
+ "on which to list rooms",
+ "",
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONFERENCE_SERVER,
+ param_spec);
+
+ signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (gabble_roomlist_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[GOT_ROOMS] =
+ g_signal_new ("got-rooms",
+ G_OBJECT_CLASS_TYPE (gabble_roomlist_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)), G_TYPE_INVALID)))));
+
+ signals[LISTING_ROOMS] =
+ g_signal_new ("listing-rooms",
+ G_OBJECT_CLASS_TYPE (gabble_roomlist_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_roomlist_channel_class), &dbus_glib_gabble_roomlist_channel_object_info);
+}
+
+void
+gabble_roomlist_channel_dispose (GObject *object)
+{
+ GabbleRoomlistChannel *self = GABBLE_ROOMLIST_CHANNEL (object);
+ GabbleRoomlistChannelPrivate *priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ if (priv->listing)
+ {
+ emit_room_signal (object);
+ g_signal_emit (object, signals [LISTING_ROOMS], 0, FALSE);
+ priv->listing = FALSE;
+ }
+
+ if (!priv->closed)
+ {
+ g_signal_emit (object, signals[CLOSED], 0);
+ priv->closed = TRUE;
+ }
+
+ if (priv->disco_pipeline != NULL)
+ {
+ gabble_disco_pipeline_destroy (priv->disco_pipeline);
+ priv->disco_pipeline = NULL;
+ }
+
+ if (priv->timer_source_id)
+ {
+ g_source_remove (priv->timer_source_id);
+ priv->timer_source_id = 0;
+ }
+
+ g_assert (priv->pending_room_signals != NULL);
+ g_assert (priv->pending_room_signals->len == 0);
+ g_ptr_array_free (priv->pending_room_signals, TRUE);
+ priv->pending_room_signals = NULL;
+
+ if (G_OBJECT_CLASS (gabble_roomlist_channel_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_roomlist_channel_parent_class)->dispose (object);
+}
+
+void
+gabble_roomlist_channel_finalize (GObject *object)
+{
+ GabbleRoomlistChannel *self = GABBLE_ROOMLIST_CHANNEL (object);
+ GabbleRoomlistChannelPrivate *priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (self);
+
+ /* free any data held directly by the object here */
+
+ g_free (priv->object_path);
+ g_free (priv->conference_server);
+
+ if (priv->signalled_rooms != NULL)
+ handle_set_destroy (priv->signalled_rooms);
+
+ G_OBJECT_CLASS (gabble_roomlist_channel_parent_class)->finalize (object);
+}
+
+GabbleRoomlistChannel *
+_gabble_roomlist_channel_new (GabbleConnection *conn,
+ const gchar *object_path,
+ const gchar *conference_server)
+{
+ g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), NULL);
+ g_return_val_if_fail (object_path != NULL, NULL);
+ g_return_val_if_fail (conference_server != NULL, NULL);
+
+ return GABBLE_ROOMLIST_CHANNEL (
+ g_object_new (GABBLE_TYPE_ROOMLIST_CHANNEL,
+ "connection", conn,
+ "object-path", object_path,
+ "conference-server", conference_server, NULL));
+}
+
+static gboolean
+emit_room_signal (gpointer data)
+{
+ GabbleRoomlistChannel *chan = data;
+ GabbleRoomlistChannelPrivate *priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (chan);
+
+ if (!priv->listing)
+ return FALSE;
+
+ if (priv->pending_room_signals->len == 0)
+ return TRUE;
+
+ g_signal_emit (chan, signals[GOT_ROOMS], 0, priv->pending_room_signals);
+
+ while (priv->pending_room_signals->len != 0)
+ {
+ gpointer boxed = g_ptr_array_index (priv->pending_room_signals, 0);
+ g_boxed_free (TP_TYPE_ROOM_STRUCT, boxed);
+ g_ptr_array_remove_index_fast (priv->pending_room_signals, 0);
+ }
+
+ return TRUE;
+}
+
+/**
+ * destroy_value:
+ * @data: a GValue to destroy
+ *
+ * destroys a GValue allocated on the heap
+ */
+static void
+destroy_value (GValue *value)
+{
+ g_value_unset (value);
+ g_free (value);
+}
+
+static void
+room_info_cb (gpointer pipeline, GabbleDiscoItem *item, gpointer user_data)
+{
+ GabbleRoomlistChannel *chan = user_data;
+ GabbleRoomlistChannelPrivate *priv;
+ const char *jid, *category, *type, *var, *name;
+ GabbleHandle handle;
+ GHashTable *keys;
+ GValue room = {0,};
+ GValue *tmp;
+ gpointer k, v;
+
+ #define INSERT_KEY(hash, name, type, type2, value) \
+ do {\
+ tmp = g_new0 (GValue, 1); \
+ g_value_init (tmp, (type)); \
+ g_value_set_##type2 (tmp, (value)); \
+ g_hash_table_insert (hash, (name), tmp); \
+ } while (0)
+
+ g_assert (GABBLE_IS_ROOMLIST_CHANNEL (chan));
+ priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (chan);
+
+ jid = item->jid;
+ name = item->name;
+ category = item->category;
+ type = item->type;
+
+ if (0 != strcmp (category, "conference") ||
+ 0 != strcmp (type, "text"))
+ return;
+
+ if (!g_hash_table_lookup_extended (item->features, "http://jabber.org/protocol/muc", &k, &v))
+ {
+ /* not muc */
+ return;
+ }
+
+ gabble_debug (DEBUG_FLAG, "got room identity, name=%s, category=%s, type=%s", name, category, type);
+
+ keys = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) destroy_value);
+
+ INSERT_KEY (keys, "name", G_TYPE_STRING, string, name);
+
+ if (g_hash_table_lookup_extended (item->features, "muc_membersonly", &k, &v))
+ INSERT_KEY (keys, "invite-only", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_open", &k, &v))
+ INSERT_KEY (keys, "invite-only", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_passwordprotected", &k, &v))
+ INSERT_KEY (keys, "password", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_unsecure", &k, &v))
+ INSERT_KEY (keys, "password", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_unsecured", &k, &v))
+ INSERT_KEY (keys, "password", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_hidden", &k, &v))
+ INSERT_KEY (keys, "hidden", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_public", &k, &v))
+ INSERT_KEY (keys, "hidden", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_membersonly", &k, &v))
+ INSERT_KEY (keys, "members-only", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_open", &k, &v))
+ INSERT_KEY (keys, "members-only", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_moderated", &k, &v))
+ INSERT_KEY (keys, "moderated", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_unmoderated", &k, &v))
+ INSERT_KEY (keys, "moderated", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_nonanonymous", &k, &v))
+ INSERT_KEY (keys, "anonymous", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_anonymous", &k, &v))
+ INSERT_KEY (keys, "anonymous", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_semianonymous", &k, &v))
+ INSERT_KEY (keys, "anonymous", G_TYPE_BOOLEAN, boolean, FALSE);
+ if (g_hash_table_lookup_extended (item->features, "muc_persistent", &k, &v))
+ INSERT_KEY (keys, "persistent", G_TYPE_BOOLEAN, boolean, TRUE);
+ if (g_hash_table_lookup_extended (item->features, "muc_temporary", &k, &v))
+ INSERT_KEY (keys, "persistent", G_TYPE_BOOLEAN, boolean, FALSE);
+
+ var = g_hash_table_lookup (item->features, "muc#roominfo_description");
+ if (var != NULL)
+ INSERT_KEY (keys, "description", G_TYPE_STRING, string, var);
+
+ var = g_hash_table_lookup (item->features, "muc#roominfo_occupants");
+ if (var != NULL)
+ INSERT_KEY (keys, "members", G_TYPE_UINT, uint,
+ (guint) g_ascii_strtoull (var, NULL, 10));
+
+ var = g_hash_table_lookup (item->features, "muc#roominfo_lang");
+ if (var != NULL)
+ INSERT_KEY (keys, "language", G_TYPE_STRING, string, var);
+
+ handle = gabble_handle_for_room (priv->conn->handles, jid);
+
+ handle_set_add (priv->signalled_rooms, handle);
+
+ g_value_init (&room, TP_TYPE_ROOM_STRUCT);
+ g_value_take_boxed (&room,
+ dbus_g_type_specialized_construct (TP_TYPE_ROOM_STRUCT));
+
+ dbus_g_type_struct_set (&room,
+ 0, handle,
+ 1, "org.freedesktop.Telepathy.Channel.Type.Text",
+ 2, keys,
+ G_MAXUINT);
+
+ gabble_debug (DEBUG_FLAG, "adding new room signal data to pending: %s", jid);
+ g_ptr_array_add (priv->pending_room_signals, g_value_get_boxed (&room));
+ g_hash_table_destroy (keys);
+}
+
+static void
+rooms_end_cb (gpointer data, gpointer user_data)
+{
+ GabbleRoomlistChannel *chan = user_data;
+ GabbleRoomlistChannelPrivate *priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (chan);
+
+ emit_room_signal (chan);
+
+ priv->listing = FALSE;
+ g_signal_emit (chan, signals[LISTING_ROOMS], 0, FALSE);
+
+ g_source_remove (priv->timer_source_id);
+ priv->timer_source_id = 0;
+}
+
+
+/************************* D-Bus Method definitions **************************/
+
+/**
+ * gabble_roomlist_channel_close
+ *
+ * Implements D-Bus method Close
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roomlist_channel_close (GabbleRoomlistChannel *self,
+ GError **error)
+{
+ g_assert (GABBLE_IS_ROOMLIST_CHANNEL (self));
+
+ gabble_debug (DEBUG_FLAG, "called on %p", self);
+
+ g_object_run_dispose (G_OBJECT (self));
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_roomlist_channel_get_channel_type
+ *
+ * Implements D-Bus method GetChannelType
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roomlist_channel_get_channel_type (GabbleRoomlistChannel *self,
+ gchar **ret,
+ GError **error)
+{
+ *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_ROOM_LIST);
+ return TRUE;
+}
+
+
+/**
+ * gabble_roomlist_channel_get_handle
+ *
+ * Implements D-Bus method GetHandle
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roomlist_channel_get_handle (GabbleRoomlistChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error)
+{
+ g_assert (GABBLE_IS_ROOMLIST_CHANNEL (self));
+
+ *ret = 0;
+ *ret1 = 0;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_roomlist_channel_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roomlist_channel_get_interfaces (GabbleRoomlistChannel *self,
+ gchar ***ret,
+ GError **error)
+{
+ const char *interfaces[] = { NULL };
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_roomlist_channel_get_listing_rooms
+ *
+ * Implements D-Bus method GetListingRooms
+ * on interface org.freedesktop.Telepathy.Channel.Type.RoomList
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roomlist_channel_get_listing_rooms (GabbleRoomlistChannel *self,
+ gboolean *ret,
+ GError **error)
+{
+ GabbleRoomlistChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_ROOMLIST_CHANNEL (self));
+
+ priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (self);
+ *ret = priv->listing;
+ return TRUE;
+}
+
+
+/**
+ * gabble_roomlist_channel_list_rooms
+ *
+ * Implements D-Bus method ListRooms
+ * on interface org.freedesktop.Telepathy.Channel.Type.RoomList
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roomlist_channel_list_rooms (GabbleRoomlistChannel *self,
+ GError **error)
+{
+ GabbleRoomlistChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_ROOMLIST_CHANNEL (self));
+
+ priv = GABBLE_ROOMLIST_CHANNEL_GET_PRIVATE (self);
+
+ priv->listing = TRUE;
+ g_signal_emit (self, signals[LISTING_ROOMS], 0, TRUE);
+
+ if (priv->disco_pipeline == NULL)
+ priv->disco_pipeline = gabble_disco_pipeline_init (priv->conn->disco,
+ room_info_cb, rooms_end_cb, self);
+
+ gabble_disco_pipeline_run (priv->disco_pipeline, priv->conference_server);
+
+ priv->timer_source_id = g_timeout_add (ROOM_SIGNAL_INTERVAL,
+ emit_room_signal, self);
+
+ return TRUE;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-roster-channel-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,66 @@
+/*
+ * gabble-roster-channel-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-roster-channel.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,812 @@
+/*
+ * gabble-roster-channel.c - Source for GabbleRosterChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_ROSTER
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "gintset.h"
+#include "group-mixin.h"
+#include "handle-set.h"
+#include "roster.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "telepathy-interfaces.h"
+#include "tp-channel-iface.h"
+#include "util.h"
+
+#include "gabble-roster-channel.h"
+#include "gabble-roster-channel-glue.h"
+#include "gabble-roster-channel-signals-marshal.h"
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleRosterChannel, gabble_roster_channel,
+ G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+#endif
+
+/* signal enum */
+enum
+{
+ CLOSED,
+ GROUP_FLAGS_CHANGED,
+ MEMBERS_CHANGED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_ROS_CHNL
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_ros_chnl,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_ros_chnl, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_roster_channel_parent_class,gabble_ros_chnl,gpointer)
+ #define gabble_roster_channel_parent_class (*GET_WSD_VAR_NAME(gabble_roster_channel_parent_class,gabble_ros_chnl,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_ros_chnl,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_ros_chnl,s)())
+
+static void gabble_roster_channel_init (GabbleRosterChannel *self);
+static void gabble_roster_channel_class_init (GabbleRosterChannelClass *klass);
+static void gabble_roster_channel_class_intern_init (gpointer klass)
+{
+ gabble_roster_channel_parent_class = g_type_class_peek_parent (klass);
+ gabble_roster_channel_class_init ((GabbleRosterChannelClass*) klass);
+ }
+
+ EXPORT_C GType gabble_roster_channel_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleRosterChannelClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_roster_channel_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleRosterChannel), 0, (GInstanceInitFunc) gabble_roster_channel_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleRosterChannel"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) ((void *)0) }; g_type_add_interface_static (g_define_type_id, tp_channel_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_CHANNEL_TYPE,
+ PROP_HANDLE_TYPE,
+ PROP_HANDLE,
+ PROP_CONNECTION,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleRosterChannelPrivate GabbleRosterChannelPrivate;
+
+struct _GabbleRosterChannelPrivate
+{
+ GabbleConnection *conn;
+ char *object_path;
+ GabbleHandle handle;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_ROSTER_CHANNEL_GET_PRIVATE(obj) \
+ ((GabbleRosterChannelPrivate *)obj->priv)
+
+static void
+gabble_roster_channel_init (GabbleRosterChannel *self)
+{
+ GabbleRosterChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_ROSTER_CHANNEL, GabbleRosterChannelPrivate);
+
+ self->priv = priv;
+
+ /* allocate any data required by the object here */
+}
+
+static GObject *
+gabble_roster_channel_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleRosterChannelPrivate *priv;
+ DBusGConnection *bus;
+ GabbleHandleRepo *handles;
+ gboolean valid;
+ GabbleHandle self_handle;
+
+ obj = G_OBJECT_CLASS (gabble_roster_channel_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (GABBLE_ROSTER_CHANNEL (obj));
+ handles = priv->conn->handles;
+ self_handle = priv->conn->self_handle;
+
+ /* register object on the bus */
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ /* ref our list handle */
+ valid = gabble_handle_ref (handles, TP_HANDLE_TYPE_LIST, priv->handle);
+ g_assert (valid);
+
+ /* initialize group mixin */
+ gabble_group_mixin_init (obj, G_STRUCT_OFFSET (GabbleRosterChannel, group),
+ handles, self_handle);
+
+ if (GABBLE_LIST_HANDLE_PUBLISH == priv->handle)
+ {
+ gabble_group_mixin_change_flags (obj,
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_ACCEPT |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE,
+ 0);
+ }
+ else if (GABBLE_LIST_HANDLE_SUBSCRIBE == priv->handle)
+ {
+ gabble_group_mixin_change_flags (obj,
+ TP_CHANNEL_GROUP_FLAG_CAN_ADD |
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_CAN_RESCIND |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE |
+ TP_CHANNEL_GROUP_FLAG_MESSAGE_RESCIND,
+ 0);
+ }
+ else if (GABBLE_LIST_HANDLE_KNOWN == priv->handle)
+ {
+ gabble_group_mixin_change_flags (obj,
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE,
+ 0);
+ }
+ else if (GABBLE_LIST_HANDLE_DENY == priv->handle)
+ {
+ gabble_group_mixin_change_flags (obj,
+ TP_CHANNEL_GROUP_FLAG_CAN_ADD |
+ TP_CHANNEL_GROUP_FLAG_CAN_REMOVE,
+ 0);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return obj;
+}
+
+static void
+gabble_roster_channel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRosterChannel *chan = GABBLE_ROSTER_CHANNEL (object);
+ GabbleRosterChannelPrivate *priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_CHANNEL_TYPE:
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST);
+ break;
+ case PROP_HANDLE_TYPE:
+ g_value_set_uint (value, TP_HANDLE_TYPE_LIST);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, priv->handle);
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_roster_channel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRosterChannel *chan = GABBLE_ROSTER_CHANNEL (object);
+ GabbleRosterChannelPrivate *priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_HANDLE:
+ priv->handle = g_value_get_uint (value);
+ break;
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_roster_channel_dispose (GObject *object);
+static void gabble_roster_channel_finalize (GObject *object);
+
+static gboolean _gabble_roster_channel_add_member_cb (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+static gboolean _gabble_roster_channel_remove_member_cb (GObject *obj, GabbleHandle handle, const gchar *message, GError **error);
+
+static void
+gabble_roster_channel_class_init (GabbleRosterChannelClass *gabble_roster_channel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_roster_channel_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_roster_channel_class, sizeof (GabbleRosterChannelPrivate));
+
+ object_class->constructor = gabble_roster_channel_constructor;
+
+ object_class->get_property = gabble_roster_channel_get_property;
+ object_class->set_property = gabble_roster_channel_set_property;
+
+ object_class->dispose = gabble_roster_channel_dispose;
+ object_class->finalize = gabble_roster_channel_finalize;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "Roster channel object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ g_object_class_override_property (object_class, PROP_OBJECT_PATH, "object-path");
+ g_object_class_override_property (object_class, PROP_CHANNEL_TYPE, "channel-type");
+ g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type");
+ g_object_class_override_property (object_class, PROP_HANDLE, "handle");
+
+ signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (gabble_roster_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ gabble_group_mixin_class_init (object_class,
+ G_STRUCT_OFFSET (GabbleRosterChannelClass, group_class),
+ _gabble_roster_channel_add_member_cb,
+ _gabble_roster_channel_remove_member_cb);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_roster_channel_class), &dbus_glib_gabble_roster_channel_object_info);
+}
+
+void
+gabble_roster_channel_dispose (GObject *object)
+{
+ GabbleRosterChannel *self = GABBLE_ROSTER_CHANNEL (object);
+ GabbleRosterChannelPrivate *priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ g_signal_emit(self, signals[CLOSED], 0);
+
+ /* release any references held by the object here */
+
+ if (G_OBJECT_CLASS (gabble_roster_channel_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_roster_channel_parent_class)->dispose (object);
+}
+
+void
+gabble_roster_channel_finalize (GObject *object)
+{
+ GabbleRosterChannel *self = GABBLE_ROSTER_CHANNEL (object);
+ GabbleRosterChannelPrivate *priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (self);
+
+ /* free any data held directly by the object here */
+
+ g_free (priv->object_path);
+
+ gabble_handle_unref (priv->conn->handles, TP_HANDLE_TYPE_LIST, priv->handle);
+
+ gabble_group_mixin_finalize (object);
+
+ G_OBJECT_CLASS (gabble_roster_channel_parent_class)->finalize (object);
+}
+
+
+static gboolean
+_gabble_roster_channel_send_presence (GabbleRosterChannel *chan,
+ LmMessageSubType sub_type,
+ GabbleHandle handle,
+ const gchar *status,
+ GError **error)
+{
+ GabbleRosterChannelPrivate *priv;
+ GabbleHandleRepo *repo;
+ const char *contact;
+ LmMessage *message;
+ gboolean result;
+
+ priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (chan);
+ repo = priv->conn->handles;
+ contact = gabble_handle_inspect (repo, TP_HANDLE_TYPE_CONTACT, handle);
+
+ message = lm_message_new_with_sub_type (contact,
+ LM_MESSAGE_TYPE_PRESENCE,
+ sub_type);
+
+ if (LM_MESSAGE_SUB_TYPE_SUBSCRIBE == sub_type)
+ lm_message_node_add_own_nick (message->node, priv->conn);
+
+ if (status != NULL && status[0] != '\0')
+ lm_message_node_add_child (message->node, "status", status);
+
+ result = _gabble_connection_send (priv->conn, message, error);
+
+ lm_message_unref (message);
+
+ return result;
+}
+
+
+/**
+ * _gabble_roster_channel_add_member_cb
+ *
+ * Called by the group mixin to add one member.
+ */
+static gboolean
+_gabble_roster_channel_add_member_cb (GObject *obj,
+ GabbleHandle handle,
+ const gchar *message,
+ GError **error)
+{
+ GabbleRosterChannelPrivate *priv;
+ GabbleHandleRepo *repo;
+ gboolean ret = FALSE;
+
+ priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (GABBLE_ROSTER_CHANNEL (obj));
+
+ repo = priv->conn->handles;
+
+ gabble_debug (DEBUG_FLAG, "called on %s with handle %u (%s) \"%s\"", gabble_handle_inspect (repo, TP_HANDLE_TYPE_LIST, priv->handle), handle,
+ gabble_handle_inspect (repo, TP_HANDLE_TYPE_CONTACT, handle), message);
+
+ /* publish list */
+ if (GABBLE_LIST_HANDLE_PUBLISH == priv->handle)
+ {
+ /* send <presence type="subscribed"> */
+ ret = _gabble_roster_channel_send_presence (GABBLE_ROSTER_CHANNEL (obj),
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBED, handle, message, error);
+ }
+ /* subscribe list */
+ else if (GABBLE_LIST_HANDLE_SUBSCRIBE == priv->handle)
+ {
+ /* add item to the roster (GTalk depends on this, clearing the H flag) */
+ gabble_roster_handle_add (priv->conn->roster, handle, NULL);
+
+ /* send <presence type="subscribe"> */
+ ret = _gabble_roster_channel_send_presence (GABBLE_ROSTER_CHANNEL (obj),
+ LM_MESSAGE_SUB_TYPE_SUBSCRIBE, handle, message, error);
+ }
+ /* deny list */
+ else if (GABBLE_LIST_HANDLE_DENY == priv->handle)
+ {
+ /* block contact */
+ ret = gabble_roster_handle_set_blocked (priv->conn->roster, handle, TRUE,
+ error);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return ret;
+}
+
+
+/**
+ * _gabble_roster_channel_remove_member_cb
+ *
+ * Called by the group mixin to remove one member.
+ */
+static gboolean
+_gabble_roster_channel_remove_member_cb (GObject *obj,
+ GabbleHandle handle,
+ const gchar *message,
+ GError **error)
+{
+ GabbleRosterChannelPrivate *priv;
+ GabbleHandleRepo *repo;
+ gboolean ret = FALSE;
+
+ priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (GABBLE_ROSTER_CHANNEL (obj));
+
+ repo = priv->conn->handles;
+
+ gabble_debug (DEBUG_FLAG, "called on %s with handle %u (%s) \"%s\"", gabble_handle_inspect (repo, TP_HANDLE_TYPE_LIST, priv->handle), handle,
+ gabble_handle_inspect (repo, TP_HANDLE_TYPE_CONTACT, handle), message);
+
+ /* publish list */
+ if (GABBLE_LIST_HANDLE_PUBLISH == priv->handle)
+ {
+ /* send <presence type="unsubscribed"> */
+ ret = _gabble_roster_channel_send_presence (GABBLE_ROSTER_CHANNEL (obj),
+ LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED, handle, message, error);
+
+ /* remove it from local_pending here, because roster callback doesn't
+ know if it can (subscription='none' is used both during request and
+ when it's rejected) */
+ if (handle_set_is_member (GABBLE_ROSTER_CHANNEL (obj)->group.local_pending, handle))
+ {
+ GIntSet *rem = g_intset_new ();
+
+ g_intset_add (rem, handle);
+ gabble_group_mixin_change_members (obj, "", NULL, rem, NULL, NULL,
+ 0, 0);
+
+ g_intset_destroy (rem);
+ }
+ }
+ /* subscribe list */
+ else if (GABBLE_LIST_HANDLE_SUBSCRIBE == priv->handle)
+ {
+ /* send <presence type="unsubscribe"> */
+ ret = _gabble_roster_channel_send_presence (GABBLE_ROSTER_CHANNEL (obj),
+ LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE, handle, message, error);
+ }
+ /* known list */
+ else if (GABBLE_LIST_HANDLE_KNOWN == priv->handle)
+ {
+ /* send roster subscription=remove IQ */
+ ret = gabble_roster_handle_remove (priv->conn->roster, handle, error);
+ }
+ /* deny list */
+ else if (GABBLE_LIST_HANDLE_DENY == priv->handle)
+ {
+ /* unblock contact */
+ ret = gabble_roster_handle_set_blocked (priv->conn->roster, handle, FALSE,
+ error);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return ret;
+}
+
+
+/**
+ * gabble_roster_channel_add_members
+ *
+ * Implements D-Bus method AddMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_add_members (GabbleRosterChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error)
+{
+ return gabble_group_mixin_add_members (G_OBJECT (self), contacts, message,
+ error);
+}
+
+
+/**
+ * gabble_roster_channel_close
+ *
+ * Implements D-Bus method Close
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_close (GabbleRosterChannel *self,
+ GError **error)
+{
+ g_set_error (error, TELEPATHY_ERRORS, NotImplemented,
+ "you may not close contact list channels");
+
+ return FALSE;
+}
+
+
+/**
+ * gabble_roster_channel_get_all_members
+ *
+ * Implements D-Bus method GetAllMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_all_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GArray **ret1,
+ GArray **ret2,
+ GError **error)
+{
+ return gabble_group_mixin_get_all_members (G_OBJECT (self), ret, ret1, ret2,
+ error);
+}
+
+
+/**
+ * gabble_roster_channel_get_channel_type
+ *
+ * Implements D-Bus method GetChannelType
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_channel_type (GabbleRosterChannel *self,
+ gchar **ret,
+ GError **error)
+{
+ *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_CONTACT_LIST);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_roster_channel_get_group_flags
+ *
+ * Implements D-Bus method GetGroupFlags
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_group_flags (GabbleRosterChannel *self,
+ guint *ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_group_flags (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_roster_channel_get_handle
+ *
+ * Implements D-Bus method GetHandle
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_handle (GabbleRosterChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error)
+{
+ GabbleRosterChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_ROSTER_CHANNEL (self));
+
+ priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (self);
+
+ *ret = TP_HANDLE_TYPE_LIST;
+ *ret1 = priv->handle;
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_roster_channel_get_handle_owners
+ *
+ * Implements D-Bus method GetHandleOwners
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_handle_owners (GabbleRosterChannel *self,
+ const GArray *handles,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_handle_owners (G_OBJECT (self), handles, ret,
+ error);
+}
+
+
+/**
+ * gabble_roster_channel_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_interfaces (GabbleRosterChannel *self,
+ gchar ***ret,
+ GError **error)
+{
+ const char *interfaces[] = { TP_IFACE_CHANNEL_INTERFACE_GROUP, NULL };
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_roster_channel_get_local_pending_members
+ *
+ * Implements D-Bus method GetLocalPendingMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_local_pending_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_local_pending_members (G_OBJECT (self), ret,
+ error);
+}
+
+
+/**
+ * gabble_roster_channel_get_members
+ *
+ * Implements D-Bus method GetMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_members (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_roster_channel_get_remote_pending_members
+ *
+ * Implements D-Bus method GetRemotePendingMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_remote_pending_members (GabbleRosterChannel *self,
+ GArray **ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_remote_pending_members (G_OBJECT (self), ret,
+ error);
+}
+
+
+/**
+ * gabble_roster_channel_get_self_handle
+ *
+ * Implements D-Bus method GetSelfHandle
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_get_self_handle (GabbleRosterChannel *self,
+ guint *ret,
+ GError **error)
+{
+ return gabble_group_mixin_get_self_handle (G_OBJECT (self), ret, error);
+}
+
+
+/**
+ * gabble_roster_channel_remove_members
+ *
+ * Implements D-Bus method RemoveMembers
+ * on interface org.freedesktop.Telepathy.Channel.Interface.Group
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_roster_channel_remove_members (GabbleRosterChannel *self,
+ const GArray *contacts,
+ const gchar *message,
+ GError **error)
+{
+ return gabble_group_mixin_remove_members (G_OBJECT (self), contacts, message,
+ error);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble-search-channel.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,680 @@
+/*
+ * gabble-im-channel.c - Source for GabbleSearchChannel
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include "loudmouth/loudmouth.h"
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+
+#define DEBUG_FLAG GABBLE_DEBUG_SEARCH
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "gabble-presence.h"
+#include "gabble-presence-cache.h"
+#include "handles.h"
+#include "roster.h"
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "telepathy-interfaces.h"
+#include "tp-channel-iface.h"
+#include "namespaces.h"
+
+#include "gabble-search-channel.h"
+#include "gabble-search-channel-glue.h"
+#include "search-mixin-signals-marshal.h"
+#include "search-mixin.h"
+
+#include "gabble_enums.h"
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleSearchChannel, gabble_search_channel, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+
+#endif
+
+/* signal enum */
+enum
+{
+ CLOSED,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_SEARCH
+#endif
+
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_search,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_search, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_search_channel_parent_class,gabble_search,gpointer)
+ #define gabble_search_channel_parent_class (*GET_WSD_VAR_NAME(gabble_search_channel_parent_class,gabble_search,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_search,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_search,s)())
+
+
+static void gabble_search_channel_init (GabbleSearchChannel *self);
+static void gabble_search_channel_class_init (GabbleSearchChannelClass *klass);
+static void gabble_search_channel_class_intern_init (gpointer klass)
+{
+ gabble_search_channel_parent_class = g_type_class_peek_parent (klass);
+ gabble_search_channel_class_init ((GabbleSearchChannelClass*) klass);
+ }
+ EXPORT_C GType gabble_search_channel_get_type (void)
+ {
+ if ((g_define_type_id == 0))
+ { static const GTypeInfo g_define_type_info =
+ { sizeof (GabbleSearchChannelClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_search_channel_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleSearchChannel), 0, (GInstanceInitFunc) gabble_search_channel_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleSearchChannel"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) ((void *)0) }; g_type_add_interface_static (g_define_type_id, tp_channel_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id;
+ };
+
+
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_CHANNEL_TYPE,
+ PROP_HANDLE_TYPE,
+ PROP_HANDLE,
+ PROP_CONNECTION,
+ LAST_PROPERTY
+};
+
+/* private structure */
+typedef struct _GabbleSearchChannelPrivate GabbleSearchChannelPrivate;
+
+struct _GabbleSearchChannelPrivate
+{
+ GabbleConnection *conn;
+ char *object_path;
+ GabbleHandle handle;
+ gboolean closed;
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_SEARCH_CHANNEL_GET_PRIVATE(obj) \
+ ((GabbleSearchChannelPrivate *)obj->priv)
+
+static void
+gabble_search_channel_init (GabbleSearchChannel *self)
+{
+ GabbleSearchChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_SEARCH_CHANNEL, GabbleSearchChannelPrivate);
+
+ self->priv = priv;
+}
+
+static GObject *
+gabble_search_channel_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleSearchChannelPrivate *priv;
+ DBusGConnection *bus;
+
+ g_message("in gabble_search_channel_constructor\n");
+ obj = G_OBJECT_CLASS (gabble_search_channel_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (GABBLE_SEARCH_CHANNEL (obj));
+
+ bus = tp_get_bus ();
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+
+ gabble_search_mixin_init (obj, G_STRUCT_OFFSET (GabbleSearchChannel, search_mixin));
+
+
+ return obj;
+}
+
+static void
+gabble_search_channel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (object);
+ GabbleSearchChannelPrivate *priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_CHANNEL_TYPE:
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
+ break;
+ case PROP_HANDLE_TYPE:
+ g_value_set_uint (value, TP_HANDLE_TYPE_NONE);
+ break;
+ case PROP_HANDLE:
+ g_value_set_uint (value, 0 );
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_search_channel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (object);
+ GabbleSearchChannelPrivate *priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_HANDLE:
+ priv->handle = g_value_get_uint (value);
+ break;
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void gabble_search_channel_dispose (GObject *object);
+static void gabble_search_channel_finalize (GObject *object);
+
+static void
+gabble_search_channel_class_init (GabbleSearchChannelClass *gabble_search_channel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_search_channel_class);
+ GParamSpec *param_spec;
+ g_message("in gabble_search_channel_class_init");
+
+ g_type_class_add_private (gabble_search_channel_class, sizeof (GabbleSearchChannelPrivate));
+
+ object_class->constructor = gabble_search_channel_constructor;
+
+ object_class->get_property = gabble_search_channel_get_property;
+ object_class->set_property = gabble_search_channel_set_property;
+
+ object_class->dispose = gabble_search_channel_dispose;
+ object_class->finalize = gabble_search_channel_finalize;
+
+ g_object_class_override_property (object_class, PROP_OBJECT_PATH, "object-path");
+ g_object_class_override_property (object_class, PROP_CHANNEL_TYPE, "channel-type");
+ g_object_class_override_property (object_class, PROP_HANDLE_TYPE, "handle-type");
+ g_object_class_override_property (object_class, PROP_HANDLE, "handle");
+
+
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "Search channel object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ signals[CLOSED] =
+ g_signal_new ("closed",
+ G_OBJECT_CLASS_TYPE (gabble_search_channel_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ gabble_search_mixin_class_init (object_class, G_STRUCT_OFFSET (GabbleSearchChannelClass, mixin_class));
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (gabble_search_channel_class), &dbus_glib_gabble_search_channel_object_info);
+}
+
+void
+gabble_search_channel_dispose (GObject *object)
+{
+ GabbleSearchChannel *self = GABBLE_SEARCH_CHANNEL (object);
+ GabbleSearchChannelPrivate *priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (self);
+
+ g_message("in gabble_search_channel_dispose\n");
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+
+ if (!priv->closed)
+ g_signal_emit(self, signals[CLOSED], 0);
+
+ if (G_OBJECT_CLASS (gabble_search_channel_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_search_channel_parent_class)->dispose (object);
+}
+
+void
+gabble_search_channel_finalize (GObject *object)
+{
+ GabbleSearchChannel *self = GABBLE_SEARCH_CHANNEL (object);
+ GabbleSearchChannelPrivate *priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (self);
+
+ g_message("in gabble_search_channel_finalize\n");
+ /* free any data held directly by the object here */
+ if( priv->object_path )
+ {
+ g_message("freeing priv->object_path in gabble_search_channel_finalize\n");
+ g_free (priv->object_path);
+ priv->object_path = NULL;
+ }
+
+ //also free the data,if any, held by mixin obj
+ //gabble_search_mixin_finalize(object);
+
+ G_OBJECT_CLASS (gabble_search_channel_parent_class)->finalize (object);
+}
+
+
+
+/**
+ * gabble_search_channel_close
+ *
+ * Implements D-Bus method Close
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_close (GabbleSearchChannel *self,
+ GError **error)
+{
+ GabbleSearchChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_SEARCH_CHANNEL (self));
+
+ gabble_debug (DEBUG_FLAG, "called on %p", self);
+
+ g_message("gabble_search_channel_close");
+ priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (self);
+
+ if (priv->closed)
+ {
+ gabble_debug (DEBUG_FLAG, "channel already closed");
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Channel already closed");
+
+ return FALSE;
+ }
+
+
+ priv->closed = TRUE;
+
+ g_signal_emit (self, signals[CLOSED], 0);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_search_channel_get_channel_type
+ *
+ * Implements D-Bus method GetChannelType
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_get_channel_type (GabbleSearchChannel *self,
+ gchar **ret,
+ GError **error)
+{
+ *ret = g_strdup (TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_search_channel_get_interfaces
+ *
+ * Implements D-Bus method GetInterfaces
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_get_interfaces (GabbleSearchChannel *self,
+ gchar ***ret,
+ GError **error)
+{
+ const char *interfaces[] = { NULL };
+
+ *ret = g_strdupv ((gchar **) interfaces);
+
+ return TRUE;
+}
+
+
+/**
+ * gabble_search_channel_search
+ *
+ * Implements D-Bus method Search
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_search ( GabbleSearchChannel *self,
+ GHashTable *params,
+ GError **error
+ )
+{
+ GabbleSearchChannelPrivate *priv;
+
+ g_message("In gabble_search_channel_search: serachchan is %u\n",self);
+
+ g_assert (GABBLE_IS_SEARCH_CHANNEL (self));
+ priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (self);
+
+ return gabble_search_mixin_search (G_OBJECT (self), params,
+ priv->conn, error);
+
+}
+
+/**
+ * gabble_search_channel_get_search_state
+ *
+ * Implements D-Bus method GetSearchState
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_get_search_state ( GabbleSearchChannel *self,
+ guint *ret,
+ GError **error
+ )
+{
+ g_message("In gabble_search_channel_get_search_state\n");
+ return gabble_search_mixin_get_search_state (G_OBJECT (self),ret, error);
+ }
+
+
+/**
+ * gabble_search_channel_get_handle
+ *
+ * Implements D-Bus method GetHandle
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_get_handle (GabbleSearchChannel *self,
+ guint *ret,
+ guint *ret1,
+ GError **error)
+{
+ GabbleSearchChannelPrivate *priv;
+
+ g_assert (GABBLE_IS_SEARCH_CHANNEL (self));
+
+ priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (self);
+
+ *ret = TP_HANDLE_TYPE_NONE;
+ //search channel doesnt correspond to any particular handle
+ *ret1 = 0;
+
+ return TRUE;
+}
+
+/**
+ * TODO: this method may be modified in future to get the search key types
+ * as dbus-glib binding tool doesnt support 'g' type signature
+ * Also this method should be able to give value
+ * for the options for list-single or list-multi type search keys if required
+ * gabble_search_channel_get_search_keys
+ *
+ * Implements D-Bus method GetSearchKeys
+ * on interface org.freedesktop.Telepathy.Channel
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns FALSE.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_channel_get_search_keys ( GabbleSearchChannel *self,
+ gchar **ret_instruction,
+ gchar ***ret_searchkeys,
+ GError **error
+ )
+{
+ GabbleSearchChannelPrivate *priv;
+
+ g_message("In gabble_search_channel_get_search_keys: serachchan is %u\n",self);
+
+ g_assert (GABBLE_IS_SEARCH_CHANNEL (self));
+ priv = GABBLE_SEARCH_CHANNEL_GET_PRIVATE (self);
+
+ return gabble_search_mixin_get_search_keys (G_OBJECT (self),ret_instruction,
+ ret_searchkeys,
+ priv->conn, error);
+ }
+
+
+/**
+ * search_channel_iq_cb:
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler
+ * is concerned only with search queries, and allows other handlers
+ * if queries other than search are received.
+ */
+
+LmHandlerResult
+search_channel_iq_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (user_data);
+ GabbleSearchChannelPrivate *priv = NULL;
+ GabbleSearchMixin *mixin = NULL;
+
+ LmMessageNode *iq_node, *query_node;
+ LmMessageSubType sub_type;
+
+ LmMessageNode *x_node, *x_item_node, *result_node;
+ const char *x_node_type;
+ const gchar **from = NULL;
+
+ GHashTable *results = NULL;
+ guint contact_handle = 0;
+
+
+ g_message("in search_channel_iq_cb: user data - chan is : %u\n", chan);
+
+ sub_type = lm_message_get_sub_type (message);
+
+ if (sub_type != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+ iq_node = lm_message_get_node (message);
+ query_node = lm_message_node_get_child_with_namespace (iq_node, "query",
+ NS_SEARCH);
+
+ if (query_node == NULL || chan == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+
+
+ priv= GABBLE_SEARCH_CHANNEL_GET_PRIVATE (chan);
+ mixin = GABBLE_SEARCH_MIXIN (chan);
+
+
+ x_node = lm_message_node_get_child_with_namespace (query_node, "x", NS_X_DATA);
+
+ if( x_node )
+ {
+ //if service supports data forms
+ result_node = x_node;
+ x_node_type = lm_message_node_get_attribute (x_node, "type" );
+ if (0 != strcmp (x_node_type, "result"))
+ {
+ //this can be for search_keys_iq_cb
+ //callback received as result of request to get search key fields
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ //if(type == NULL), do some error handling
+ }
+
+ else
+ result_node = query_node;
+
+
+ for (x_item_node = result_node->children; x_item_node; x_item_node = x_item_node->next)
+ {
+ LmMessageNode *item_node, *node;
+ GHashTable *search_result = NULL;
+ gboolean reported_field_has_type = FALSE;
+
+
+ if(!search_result)
+ search_result = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,NULL);
+
+ //there should be only one reported field
+ //Later "reported" should also be used to get the types of search result fields
+ //'g' type currently not supported by dbus-glib-binding
+ if (0 != strcmp (x_item_node->name, "item") )
+ continue;
+
+ contact_handle = 0;
+
+ //x_item_node is an item node
+ //get the field nodes from each item node
+ for (node = x_item_node->children; node; node = node->next)
+ {
+ const gchar *key, *value;
+ LmMessageNode *value_node;
+ GValue *val = g_new0(GValue, 1);
+ LmMessageNode *reported_field_node;
+
+
+ if (0 != strcmp (node->name, "field"))
+ continue;
+
+ //node is a field or reported node
+ //get the name, type and value of each field
+ key = lm_message_node_get_attribute(node, "var");
+
+ value_node = lm_message_node_get_child(node, "value");
+
+ value = lm_message_node_get_value(value_node);
+
+ if(0 == strcmp (key, "jid"))
+ {
+ g_message("getting contact_handle\n");
+ contact_handle = gabble_handle_for_contact (priv->conn->handles, value, FALSE);
+ }
+
+ g_value_init (val, G_TYPE_STRING);
+ //"val" should be a struct with members "var" and "type"
+ g_value_set_string (val, g_strdup(value) );
+ g_hash_table_insert(search_result,g_strdup(key),val);
+
+ }
+
+
+ g_message("search results: %u",g_hash_table_size(search_result));
+ //emit the signal for search result received
+ _gabble_search_mixin_emit_search_result_received(G_OBJECT (chan),contact_handle, search_result);
+
+ g_hash_table_destroy(search_result);
+ }
+
+
+ //if no search results, service must return empty query element
+ //so emit the signal for the same
+ if(!contact_handle)
+ {
+
+ if(!results)
+ results = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,NULL);
+
+ _gabble_search_mixin_emit_search_result_received(G_OBJECT (chan),contact_handle, results);
+ g_hash_table_destroy(results);
+
+ }
+
+ //search state should be completed
+ g_message("b4 set search state changed \n");
+ _gabble_search_mixin_set_search_state(G_OBJECT (chan), TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER);
+
+ //search request completed now, emit the signal for search state changed
+ g_message("b4 emiiting search state changed signal\n");
+ _gabble_search_mixin_emit_search_state_changed(G_OBJECT (chan),TP_CHANNEL_CONTACT_SEARCH_STATE_AFTER);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gabble.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,223 @@
+/*
+ * gabble.h - entry point and utility functions for telepathy-gabble
+ * Copyright (C) 2005 Collabora Ltd.
+ * Portions and/or its subsidiary/subsidiaris. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <dbus/dbus-glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif /* HAVE_EXECINFO_H */
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif /* HAVE_SIGNAL_H */
+
+#include "debug.h"
+#include "gabble-connection-manager.h"
+#include "telepathy-errors.h"
+#include "telepathy-errors-enumtypes.h"
+
+GSource *timeout = NULL;
+GMainLoop *mainloop = NULL;
+GabbleConnectionManager *manager = NULL;
+gboolean connections_exist = FALSE;
+guint timeout_id;
+
+#define DIE_TIME 5000
+
+static gboolean
+kill_connection_manager (gpointer data)
+{
+ g_debug ("%s: in kill_connection_manager", G_STRFUNC);
+#ifdef ENABLE_DEBUG
+ if (!gabble_debug_flag_is_set (GABBLE_DEBUG_PERSIST) && !connections_exist)
+#else
+ if (!connections_exist)
+#endif
+ {
+ g_debug ("no connections, and timed out");
+ g_object_unref (manager);
+ g_main_loop_quit (mainloop);
+ }
+
+ timeout_id = 0;
+ g_debug ("%s: out kill_connection_manager", G_STRFUNC);
+ return FALSE;
+}
+
+static void
+new_connection (GabbleConnectionManager *conn,
+ gchar *bus_name,
+ gchar *object_path,
+ gchar *proto)
+{
+ connections_exist = TRUE;
+
+ if (0 != timeout_id)
+ {
+ g_source_remove (timeout_id);
+ }
+}
+
+static void
+no_more_connections (GabbleConnectionManager *conn)
+{
+ connections_exist = FALSE;
+ g_debug ("%s: in no more connections", G_STRFUNC);
+ if (0 != timeout_id)
+ {
+ g_source_remove (timeout_id);
+ }
+
+ timeout_id = g_timeout_add (DIE_TIME, kill_connection_manager, NULL);
+ g_debug ("%s: out no more connections", G_STRFUNC);
+}
+
+#ifdef ENABLE_BACKTRACE
+static void
+print_backtrace (void)
+{
+#if defined (HAVE_BACKTRACE) && defined (HAVE_BACKTRACE_SYMBOLS_FD)
+ void *array[20];
+ size_t size;
+
+#define MSG "\n########## Backtrace (version " VERSION ") ##########\n"
+ write (STDERR_FILENO, MSG, strlen (MSG));
+#undef MSG
+
+ size = backtrace (array, 20);
+ backtrace_symbols_fd (array, size, STDERR_FILENO);
+#endif /* HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS_FD */
+}
+
+static void
+critical_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ g_log_default_handler (log_domain, log_level, message, user_data);
+ print_backtrace ();
+}
+
+#ifdef HAVE_SIGNAL
+static void
+segv_handler (int sig)
+{
+#define MSG "caught SIGSEGV\n"
+ write (STDERR_FILENO, MSG, strlen (MSG));
+#undef MSG
+
+ print_backtrace ();
+ abort ();
+}
+#endif /* HAVE_SIGNAL */
+
+#endif /* ENABLE_BACKTRACE */
+
+static void
+add_signal_handlers (void)
+{
+#if defined(HAVE_SIGNAL) && defined(ENABLE_BACKTRACE)
+ signal (SIGSEGV, segv_handler);
+#endif /* HAVE_SIGNAL && ENABLE_BACKTRACE */
+}
+
+
+main (int argc,
+ char **argv)
+/* bsr main (int argc,
+ char **argv)*/
+{
+ add_signal_handlers ();
+ g_type_init();
+
+ g_set_prgname("telepathy-gabble");
+
+/* bsr #ifdef ENABLE_DEBUG*/
+ gabble_debug_set_flags_from_env ();
+//_dbus_setenv ("DBUS_VERBOSE","1");
+
+ if (g_getenv ("GABBLE_PERSIST"))
+ gabble_debug_set_flags (0xffff);
+/*#endif bsr */
+
+ {
+ GLogLevelFlags fatal_mask;
+
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
+
+#ifdef ENABLE_BACKTRACE
+ g_log_set_handler ("GLib-GObject",
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR |
+ G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ critical_handler, NULL);
+ g_log_set_handler ("GLib",
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR |
+ G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ critical_handler, NULL);
+ g_log_set_handler (NULL,
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR |
+ G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ critical_handler, NULL);
+#endif /* ENABLE_BACKTRACE */
+ }
+
+ g_message("before gabble mainloop new \n");
+ //getchar();
+ /* exit(1); */
+ mainloop = g_main_loop_new (NULL, FALSE);
+
+ dbus_g_error_domain_register (TELEPATHY_ERRORS,
+ "org.freedesktop.Telepathy.Error", TELEPATHY_TYPE_ERRORS);
+
+ g_message("after dbus_g_error_domain_register \n");
+ //getchar();
+
+ manager = g_object_new (GABBLE_TYPE_CONNECTION_MANAGER, /*"name","GabbleConnectionManager",*/ NULL); /* bsr */
+ g_assert (manager != NULL);
+ g_message("after g_object_new \n");
+ //getchar();
+
+ g_signal_connect (manager, "new-connection",
+ (GCallback) new_connection, NULL);
+ g_message("after g_signal_connect \n");
+ //getchar();
+
+ g_signal_connect (manager, "no-more-connections",
+ (GCallback) no_more_connections, NULL);
+
+ g_message("calling gabble_connection_manager_register \n");
+ _gabble_connection_manager_register (manager);
+
+ g_message("started version " VERSION);
+
+ timeout_id = g_timeout_add (DIE_TIME, kill_connection_manager, NULL);
+
+ g_main_loop_run (mainloop);
+ g_message("extign tg \n");
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gheap.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,158 @@
+/*
+ * Header file for GHeap
+ *
+ * Copyright (C) 2006 Nokia Corporation. All rights reserved.
+ *
+ * Contact: Olli Salli (Nokia-M/Helsinki) <olli.salli@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib.h>
+#include "gheap.h"
+
+#define DEFAULT_SIZE 64
+
+struct _GHeap
+{
+ GPtrArray *data;
+ GCompareFunc comparator;
+};
+
+
+GHeap *
+g_heap_new (GCompareFunc comparator)
+{
+ GHeap *ret = g_slice_new (GHeap);
+ g_assert (comparator != NULL);
+
+ ret->data = g_ptr_array_sized_new (DEFAULT_SIZE);
+ ret->comparator = comparator;
+
+ return ret;
+}
+
+void
+g_heap_destroy (GHeap * heap)
+{
+ g_return_if_fail (heap != NULL);
+
+ g_ptr_array_free (heap->data, TRUE);
+ g_slice_free (GHeap, heap);
+}
+
+void
+g_heap_clear (GHeap *heap)
+{
+ g_return_if_fail (heap != NULL);
+
+ g_ptr_array_free (heap->data, TRUE);
+ heap->data = g_ptr_array_sized_new (DEFAULT_SIZE);
+}
+
+#define HEAP_INDEX(heap, index) (g_ptr_array_index ((heap)->data, (index)-1))
+
+
+void
+g_heap_add (GHeap *heap, gpointer element)
+{
+ guint m;
+
+ g_return_if_fail (heap != NULL);
+
+ g_ptr_array_add (heap->data, element);
+ m = heap->data->len;
+ while (m != 1)
+ {
+ gpointer parent = HEAP_INDEX (heap, m / 2);
+
+ if (heap->comparator (element, parent) == -1)
+ {
+ HEAP_INDEX (heap, m / 2) = element;
+ HEAP_INDEX (heap, m) = parent;
+ m /= 2;
+ }
+ else
+ break;
+ }
+}
+
+
+gpointer
+g_heap_peek_first (GHeap *heap)
+{
+ g_return_val_if_fail (heap != NULL, NULL);
+
+ if (heap->data->len > 0)
+ return HEAP_INDEX (heap, 1);
+ else
+ return NULL;
+}
+
+
+gpointer
+g_heap_extract_first (GHeap * heap)
+{
+ gpointer ret;
+
+ g_return_val_if_fail (heap != NULL, NULL);
+
+ if (heap->data->len > 0)
+ {
+ guint m = heap->data->len;
+ guint i = 1, j;
+ ret = HEAP_INDEX (heap, 1);
+
+ HEAP_INDEX (heap, 1) = HEAP_INDEX (heap, m);
+
+ while (i * 2 <= m)
+ {
+ /* select the child which is supposed to come FIRST */
+ if ((i * 2 + 1 <= m)
+ && (heap->
+ comparator (HEAP_INDEX (heap, i * 2),
+ HEAP_INDEX (heap, i * 2 + 1)) == 1))
+ j = i * 2 + 1;
+ else
+ j = i * 2;
+
+ if (heap->comparator (HEAP_INDEX (heap, i), HEAP_INDEX (heap, j)) ==
+ 1)
+ {
+ gpointer tmp = HEAP_INDEX (heap, i);
+ HEAP_INDEX (heap, i) = HEAP_INDEX (heap, j);
+ HEAP_INDEX (heap, j) = tmp;
+ i = j;
+ }
+ else
+ break;
+ }
+
+ g_ptr_array_remove_index (heap->data, m - 1);
+ }
+ else
+ ret = NULL;
+
+ return ret;
+}
+
+
+guint
+g_heap_size (GHeap *heap)
+{
+ g_return_val_if_fail (heap != NULL, 0);
+
+ return heap->data->len;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/gintset.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,450 @@
+/* gintset.c - Source for a Glib-link set of integers
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <string.h>
+#include <glib.h>
+#include "gintset.h"
+
+#define DEFAULT_SIZE 16
+#define DEFAULT_INCREMENT 8
+#define DEFAULT_INCREMENT_LOG2 3
+
+struct _GIntSet
+{
+ guint32 *bits;
+ guint size;
+};
+
+static GIntSet *
+_g_intset_new_with_size (guint size)
+{
+ GIntSet *set = g_new (GIntSet, 1);
+ set->size = MAX (size, DEFAULT_SIZE);
+ set->bits = g_new0 (guint32, set->size);
+ return set;
+}
+
+
+GIntSet *
+g_intset_new ()
+{
+ return _g_intset_new_with_size (DEFAULT_SIZE);
+}
+
+/**
+ * g_intset_destroy:
+ * @set: set
+ *
+ * delete the set
+ */
+
+void
+g_intset_destroy (GIntSet *set)
+{
+ g_return_if_fail (set != NULL);
+
+ g_free (set->bits);
+ g_free (set);
+}
+
+/**
+ * g_intset_clear:
+ * @set : set
+ *
+ * Unset every integer in the set.
+ */
+void
+g_intset_clear (GIntSet *set)
+{
+ g_return_if_fail (set != NULL);
+
+ memset (set->bits, 0, set->size * sizeof (guint32));
+}
+
+/**
+ * g_intset_add:
+ * @set: set
+ * @element: integer to add
+ *
+ * Add an integer into a GIntSet
+ */
+
+void
+g_intset_add (GIntSet *set, guint element)
+{
+ guint offset;
+ guint newsize;
+
+ g_return_if_fail (set != NULL);
+
+ offset = element >> 5;
+
+ if (offset >= set->size)
+ {
+ newsize = ((offset>>DEFAULT_INCREMENT_LOG2) +1 ) << DEFAULT_INCREMENT_LOG2;
+ set->bits = g_renew(guint32, set->bits, newsize);
+ memset (set->bits + set->size, 0, sizeof(guint32) * (newsize - set->size));
+ set->size = newsize;
+ g_assert(offset<newsize);
+ }
+ set->bits[offset] = set->bits[offset] | (1<<(element & 0x1f));
+}
+
+/**
+ * g_intset_remove:
+ * @set: set
+ * @element: integer to add
+ *
+ * Remove an integer from a GIntSet
+ * Returns: TRUE if element was in set
+ */
+
+gboolean
+g_intset_remove (GIntSet *set, guint element)
+{
+ guint offset;
+ guint mask;
+
+ g_return_val_if_fail (set != NULL, FALSE);
+
+ offset = element >> 5;
+ mask = 1 << (element & 0x1f);
+ if (offset >= set->size)
+ return FALSE;
+ else if (!(set->bits[offset] & mask))
+ return FALSE;
+ else
+ {
+ set->bits[offset] &= ~mask;
+ return TRUE;
+ }
+}
+
+/**
+ * g_intset_is_member:
+ * @set: set
+ * @element: integer to test
+ *
+ * Tests if @element is a member of @set
+ * Returns: TRUE if element was in set
+ */
+
+gboolean
+g_intset_is_member (const GIntSet *set, guint element)
+{
+ guint offset;
+
+ g_return_val_if_fail (set != NULL, FALSE);
+
+ offset = element >> 5;
+ if (offset >= set->size)
+ return FALSE;
+ else
+ return (set->bits[offset] & (1 << (element & 0x1f)));
+}
+
+/**
+ * g_intset_foreach:
+ * @set: set
+ * @func: @GIntFunc to use to iterate the set
+ * @userdata: user data to pass to each call of @func
+ *
+ * Iterates every member of the set calling @func
+ */
+
+void
+g_intset_foreach (const GIntSet *set, GIntFunc func, gpointer userdata)
+{
+ guint i, j;
+
+ g_return_if_fail (set != NULL);
+ g_return_if_fail (func != NULL);
+
+ for (i = 0; i < set->size; i++)
+ {
+ if (set->bits[i])
+ for (j = 0; j < 32; j++)
+ {
+ if (set->bits[i] & 1 << j)
+ func (i * 32 + j, userdata);
+ }
+ }
+}
+
+
+static void
+addint (guint32 i, gpointer data)
+{
+ GArray *array = (GArray *) data;
+ g_array_append_val (array, i);
+}
+
+/**
+ * g_intset_to_array:
+ * @set: set to convert
+ * Convert a gintset to an array, allocates the array for you, hence you
+ * must free it after use.
+ */
+
+GArray *
+g_intset_to_array (GIntSet *set)
+{
+ GArray *array;
+
+ g_return_val_if_fail (set != NULL, NULL);
+
+ array = g_array_new (FALSE, TRUE, sizeof (guint32));
+
+ g_intset_foreach (set, addint, array);
+
+ return array;
+}
+
+
+GIntSet *
+g_intset_from_array (GArray *array)
+{
+ GIntSet *set;
+ guint32 max, i;
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ /* look at the 1st, last and middle values in the array to get an
+ * approximation of the largest */
+ max = 0;
+ if (array->len > 0)
+ max = g_array_index (array, guint32, 0);
+ if (array->len > 1)
+ max = MAX (max, g_array_index (array, guint32, array->len - 1));
+ if (array->len > 2)
+ max = MAX (max, g_array_index (array, guint32, (array->len - 1) >> 1));
+ set = _g_intset_new_with_size (1 + (max >> 5));
+
+ for (i = 0; i < array->len; i++)
+ {
+ g_intset_add (set, g_array_index (array, guint32, i));
+ }
+
+ return set;
+}
+
+
+guint
+g_intset_size (const GIntSet *set)
+{
+ guint i, count = 0;
+ guint32 n;
+
+ g_return_val_if_fail (set != NULL, 0);
+
+ for (i = 0; i < set->size; i++)
+ {
+ n = set->bits[i];
+ n = n - ((n >> 1) & 033333333333) - ((n >> 2) & 011111111111);
+ count += ((n + (n >> 3)) & 030707070707) % 63;
+ }
+
+ return count;
+}
+
+
+gboolean
+g_intset_is_equal (const GIntSet *left, const GIntSet *right)
+{
+ const GIntSet *large, *small;
+ guint i;
+
+ g_return_val_if_fail (left != NULL, FALSE);
+ g_return_val_if_fail (right != NULL, FALSE);
+
+ if (left->size > right->size)
+ {
+ large = left;
+ small = right;
+ }
+ else
+ {
+ large = right;
+ small = left;
+ }
+
+ for (i = 0; i < small->size; i++)
+ {
+ if (large->bits[i] != small->bits[i])
+ return FALSE;
+ }
+
+ for (i = small->size; i < large->size; i++)
+ {
+ if (large->bits[i] != 0)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+GIntSet *
+g_intset_copy (const GIntSet *orig)
+{
+ GIntSet *ret;
+
+ g_return_val_if_fail (orig != NULL, NULL);
+
+ ret = _g_intset_new_with_size (orig->size);
+ memcpy (ret->bits, orig->bits, (ret->size * sizeof (guint32)));
+
+ return ret;
+}
+
+
+GIntSet *
+g_intset_intersection (const GIntSet *left, const GIntSet *right)
+{
+ const GIntSet *large, *small;
+ GIntSet *ret;
+ guint i;
+
+ g_return_val_if_fail (left != NULL, NULL);
+ g_return_val_if_fail (right != NULL, NULL);
+
+ if (left->size > right->size)
+ {
+ large = left;
+ small = right;
+ }
+ else
+ {
+ large = right;
+ small = left;
+ }
+
+ ret = g_intset_copy (small);
+
+ for (i = 0; i < ret->size; i++)
+ {
+ ret->bits[i] &= large->bits[i];
+ }
+
+ return ret;
+}
+
+
+GIntSet *
+g_intset_union (const GIntSet *left, const GIntSet *right)
+{
+ const GIntSet *large, *small;
+ GIntSet *ret;
+ guint i;
+
+ g_return_val_if_fail (left != NULL, NULL);
+ g_return_val_if_fail (right != NULL, NULL);
+
+ if (left->size > right->size)
+ {
+ large = left;
+ small = right;
+ }
+ else
+ {
+ large = right;
+ small = left;
+ }
+
+ ret = g_intset_copy (large);
+
+ for (i = 0; i < small->size; i++)
+ {
+ ret->bits[i] |= small->bits[i];
+ }
+
+ return ret;
+}
+
+
+GIntSet *
+g_intset_difference (const GIntSet *left, const GIntSet *right)
+{
+ GIntSet *ret;
+ guint i;
+
+ g_return_val_if_fail (left != NULL, NULL);
+ g_return_val_if_fail (right != NULL, NULL);
+
+ ret = g_intset_copy (left);
+
+ for (i = 0; i < MIN (right->size, left->size); i++)
+ {
+ ret->bits[i] &= ~right->bits[i];
+ }
+
+ return ret;
+}
+
+
+GIntSet *
+g_intset_symmetric_difference (const GIntSet *left, const GIntSet *right)
+{
+ const GIntSet *large, *small;
+ GIntSet *ret;
+ guint i;
+
+ g_return_val_if_fail (left != NULL, NULL);
+ g_return_val_if_fail (right != NULL, NULL);
+
+ if (left->size > right->size)
+ {
+ large = left;
+ small = right;
+ }
+ else
+ {
+ large = right;
+ small = left;
+ }
+
+ ret = g_intset_copy (large);
+
+ for (i = 0; i < small->size; i++)
+ {
+ ret->bits[i] ^= small->bits[i];
+ }
+
+ return ret;
+}
+
+static void
+_dump_foreach (guint i, gpointer data)
+{
+ GString *tmp = (GString *) data;
+
+ if (tmp->len == 0)
+ g_string_append_printf (tmp, "%d", i);
+ else
+ g_string_append_printf (tmp, " %d", i);
+}
+
+gchar *
+g_intset_dump (const GIntSet *set)
+{
+ GString *tmp = g_string_new ("");
+
+ g_intset_foreach (set, _dump_foreach, tmp);
+ return g_string_free (tmp, FALSE);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/group-mixin-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,150 @@
+/*
+ * group-mixin-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:UINT,UINT (group-mixin-signals-marshal.list:1) */
+void
+group_mixin_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
+/* VOID:STRING,BOXED,BOXED,BOXED,BOXED,UINT,UINT (group-mixin-signals-marshal.list:2) */
+void
+group_mixin_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer arg_3,
+ gpointer arg_4,
+ gpointer arg_5,
+ guint arg_6,
+ guint arg_7,
+ gpointer data2);
+ register GMarshalFunc_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 8);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ g_marshal_value_peek_boxed (param_values + 3),
+ g_marshal_value_peek_boxed (param_values + 4),
+ g_marshal_value_peek_boxed (param_values + 5),
+ g_marshal_value_peek_uint (param_values + 6),
+ g_marshal_value_peek_uint (param_values + 7),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/group-mixin.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,785 @@
+/*
+ * group-mixin.c - Source for GabbleGroupMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+
+#include "ansi.h"
+#include "debug.h"
+#include "telepathy-errors.h"
+
+
+#include "group-mixin.h"
+#include "group-mixin-signals-marshal.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_GROUPS
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark1,gabble_grp_mixin,GQuark)
+ #define offset_quark1 (*GET_WSD_VAR_NAME(offset_quark1,gabble_grp_mixin, s)())
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark,gabble_grp_mixin,GQuark)
+ #define offset_quark (*GET_WSD_VAR_NAME(offset_quark,gabble_grp_mixin, s)())
+
+
+#endif
+
+static const char *group_change_reason_str(guint reason)
+{
+ switch (reason)
+ {
+ case TP_CHANNEL_GROUP_CHANGE_REASON_NONE:
+ return "unspecified reason";
+ case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE:
+ return "offline";
+ case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
+ return "kicked";
+ case TP_CHANNEL_GROUP_CHANGE_REASON_BUSY:
+ return "busy";
+ case TP_CHANNEL_GROUP_CHANGE_REASON_INVITED:
+ return "invited";
+ case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
+ return "banned";
+ default:
+ return "(unknown reason code)";
+ }
+}
+
+struct _GabbleGroupMixinPrivate {
+ GabbleHandleSet *actors;
+ GHashTable *handle_owners;
+};
+
+
+/**
+ * gabble_group_mixin_class_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObjectClass
+ */
+GQuark
+gabble_group_mixin_class_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark1 = 0;
+#endif
+
+ if (!offset_quark1)
+ offset_quark1 = g_quark_from_static_string("GroupMixinClassOffsetQuark");
+ return offset_quark1;
+}
+
+/**
+ * gabble_group_mixin_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObject
+ */
+GQuark
+gabble_group_mixin_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark = 0;
+#endif
+
+ if (!offset_quark)
+ offset_quark = g_quark_from_static_string("GroupMixinOffsetQuark");
+ return offset_quark;
+}
+
+void gabble_group_mixin_class_init (GObjectClass *obj_cls,
+ glong offset,
+ GabbleGroupMixinAddMemberFunc add_func,
+ GabbleGroupMixinRemMemberFunc rem_func)
+{
+ GabbleGroupMixinClass *mixin_cls;
+
+ g_assert (G_IS_OBJECT_CLASS (obj_cls));
+
+ g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls),
+ GABBLE_GROUP_MIXIN_CLASS_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin_cls = GABBLE_GROUP_MIXIN_CLASS (obj_cls);
+
+ mixin_cls->add_member = add_func;
+ mixin_cls->remove_member = rem_func;
+
+ mixin_cls->group_flags_changed_signal_id =
+ g_signal_new ("group-flags-changed",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ group_mixin_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ mixin_cls->members_changed_signal_id =
+ g_signal_new ("members-changed",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ group_mixin_marshal_VOID__STRING_BOXED_BOXED_BOXED_BOXED_UINT_UINT,
+ G_TYPE_NONE, 7, G_TYPE_STRING, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, DBUS_TYPE_G_UINT_ARRAY, G_TYPE_UINT, G_TYPE_UINT);
+}
+
+void gabble_group_mixin_init (GObject *obj,
+ glong offset,
+ GabbleHandleRepo *handle_repo,
+ GabbleHandle self_handle)
+{
+ GabbleGroupMixin *mixin;
+
+ g_assert (G_IS_OBJECT (obj));
+
+ g_type_set_qdata (G_OBJECT_TYPE (obj),
+ GABBLE_GROUP_MIXIN_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin = GABBLE_GROUP_MIXIN (obj);
+
+ mixin->handle_repo = handle_repo;
+ mixin->self_handle = self_handle;
+
+ mixin->group_flags = 0;
+
+ mixin->members = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT);
+ mixin->local_pending = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT);
+ mixin->remote_pending = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT);
+
+ mixin->priv = g_new0 (GabbleGroupMixinPrivate, 1);
+ mixin->priv->handle_owners = g_hash_table_new (g_direct_hash, g_direct_equal);
+ mixin->priv->actors = handle_set_new (handle_repo, TP_HANDLE_TYPE_CONTACT);
+}
+
+static void
+handle_owners_foreach_unref (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ GabbleGroupMixin *mixin = user_data;
+
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ GPOINTER_TO_UINT (key));
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ GPOINTER_TO_UINT (value));
+}
+
+void gabble_group_mixin_finalize (GObject *obj)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ handle_set_destroy (mixin->priv->actors);
+
+ g_hash_table_foreach (mixin->priv->handle_owners,
+ handle_owners_foreach_unref,
+ mixin);
+
+ g_hash_table_destroy (mixin->priv->handle_owners);
+
+ g_free (mixin->priv);
+
+ handle_set_destroy (mixin->members);
+ handle_set_destroy (mixin->local_pending);
+ handle_set_destroy (mixin->remote_pending);
+}
+
+gboolean
+gabble_group_mixin_get_self_handle (GObject *obj, guint *ret, GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ if (handle_set_is_member (mixin->members, mixin->self_handle) ||
+ handle_set_is_member (mixin->local_pending, mixin->self_handle) ||
+ handle_set_is_member (mixin->remote_pending, mixin->self_handle))
+ {
+ *ret = mixin->self_handle;
+ }
+ else
+ {
+ *ret = 0;
+ }
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_get_group_flags (GObject *obj, guint *ret, GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ *ret = mixin->group_flags;
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_add_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error)
+{
+ GabbleGroupMixinClass *mixin_cls = GABBLE_GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ guint i;
+ GabbleHandle handle;
+
+ /* reject invalid handles */
+ if (!gabble_handles_are_valid (mixin->handle_repo,
+ TP_HANDLE_TYPE_CONTACT,
+ contacts,
+ FALSE,
+ error))
+ return FALSE;
+
+ /* check that adding is allowed by flags */
+ for (i = 0; i < contacts->len; i++)
+ {
+ handle = g_array_index (contacts, GabbleHandle, i);
+
+ if ((mixin->group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) == 0 &&
+ !handle_set_is_member (mixin->local_pending, handle))
+ {
+ gabble_debug (DEBUG_FLAG, "handle %u cannot be added to members without GROUP_FLAG_CAN_ADD",
+ handle);
+
+ g_set_error (error, TELEPATHY_ERRORS, PermissionDenied,
+ "handle %u cannot be added to members without GROUP_FLAG_CAN_ADD",
+ handle);
+
+ return FALSE;
+ }
+ }
+
+ /* add handle by handle */
+ for (i = 0; i < contacts->len; i++)
+ {
+ handle = g_array_index (contacts, GabbleHandle, i);
+
+ if (handle_set_is_member (mixin->members, handle))
+ {
+ gabble_debug (DEBUG_FLAG, "handle %u is already a member, skipping", handle);
+
+ continue;
+ }
+
+ if (!mixin_cls->add_member (obj, handle, message, error))
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_remove_members (GObject *obj, const GArray *contacts, const gchar *message, GError **error)
+{
+ GabbleGroupMixinClass *mixin_cls = GABBLE_GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ guint i;
+ GabbleHandle handle;
+
+ /* reject invalid handles */
+ if (!gabble_handles_are_valid (mixin->handle_repo,
+ TP_HANDLE_TYPE_CONTACT,
+ contacts,
+ FALSE,
+ error))
+ return FALSE;
+
+ /* check removing is allowed by flags */
+ for (i = 0; i < contacts->len; i++)
+ {
+ handle = g_array_index (contacts, GabbleHandle, i);
+
+ if (handle_set_is_member (mixin->members, handle))
+ {
+ if ((mixin->group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) == 0)
+ {
+ gabble_debug (DEBUG_FLAG, "handle %u cannot be removed from members without GROUP_FLAG_CAN_REMOVE",
+ handle);
+
+ g_set_error (error, TELEPATHY_ERRORS, PermissionDenied,
+ "handle %u cannot be removed from members without GROUP_FLAG_CAN_REMOVE",
+ handle);
+
+ return FALSE;
+ }
+ }
+ else if (handle_set_is_member (mixin->remote_pending, handle))
+ {
+ if ((mixin->group_flags & TP_CHANNEL_GROUP_FLAG_CAN_RESCIND) == 0)
+ {
+ gabble_debug (DEBUG_FLAG, "handle %u cannot be removed from remote pending without GROUP_FLAG_CAN_RESCIND",
+ handle);
+
+ g_set_error (error, TELEPATHY_ERRORS, PermissionDenied,
+ "handle %u cannot be removed from remote pending without GROUP_FLAG_CAN_RESCIND",
+ handle);
+
+ return FALSE;
+ }
+ }
+ else if (!handle_set_is_member (mixin->local_pending, handle))
+ {
+ gabble_debug (DEBUG_FLAG, "handle %u is not a current or pending member",
+ handle);
+
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "handle %u is not a current or pending member", handle);
+
+ return FALSE;
+ }
+ }
+
+ /* remove handle by handle */
+ for (i = 0; i < contacts->len; i++)
+ {
+ handle = g_array_index (contacts, GabbleHandle, i);
+
+ if (!mixin_cls->remove_member (obj, handle, message, error))
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_get_members (GObject *obj, GArray **ret, GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ *ret = handle_set_to_array (mixin->members);
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_get_local_pending_members (GObject *obj, GArray **ret, GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ *ret = handle_set_to_array (mixin->local_pending);
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_get_remote_pending_members (GObject *obj, GArray **ret, GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ *ret = handle_set_to_array (mixin->remote_pending);
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_get_all_members (GObject *obj, GArray **ret, GArray **ret1, GArray **ret2, GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+
+ *ret = handle_set_to_array (mixin->members);
+ *ret1 = handle_set_to_array (mixin->local_pending);
+ *ret2 = handle_set_to_array (mixin->remote_pending);
+
+ return TRUE;
+}
+
+gboolean
+gabble_group_mixin_get_handle_owners (GObject *obj,
+ const GArray *handles,
+ GArray **ret,
+ GError **error)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ GabbleGroupMixinPrivate *priv = mixin->priv;
+ guint i;
+
+ if ((mixin->group_flags &
+ TP_CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES) == 0)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "channel doesn't have channel specific handles");
+
+ return FALSE;
+ }
+
+ if (!gabble_handles_are_valid (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ handles, FALSE, error))
+ {
+ return FALSE;
+ }
+
+ *ret = g_array_sized_new (FALSE, FALSE, sizeof (GabbleHandle), handles->len);
+
+ for (i = 0; i < handles->len; i++)
+ {
+ GabbleHandle local_handle = g_array_index (handles, GabbleHandle, i);
+ GabbleHandle owner_handle;
+
+ if (!handle_set_is_member (mixin->members, local_handle))
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "handle %u is not a member", local_handle);
+
+ g_array_free (*ret, TRUE);
+ *ret = NULL;
+
+ return FALSE;
+ }
+
+ owner_handle = GPOINTER_TO_UINT (
+ g_hash_table_lookup (priv->handle_owners,
+ GUINT_TO_POINTER (local_handle)));
+
+ g_array_append_val (*ret, owner_handle);
+ }
+
+ return TRUE;
+}
+
+#define GFTS_APPEND_FLAG_IF_SET(flag) \
+ if (flags & flag) \
+ { \
+ if (i++ > 0) \
+ g_string_append (str, "|"); \
+ g_string_append (str, #flag + 22); \
+ }
+
+static gchar *
+group_flags_to_string (TpChannelGroupFlags flags)
+{
+ gint i = 0;
+ GString *str;
+
+ str = g_string_new ("[" ANSI_BOLD_OFF);
+
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_CAN_ADD);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_CAN_REMOVE);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_CAN_RESCIND);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_ADD);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_ACCEPT);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_REJECT);
+ GFTS_APPEND_FLAG_IF_SET (TP_CHANNEL_GROUP_FLAG_MESSAGE_RESCIND);
+
+ g_string_append (str, ANSI_BOLD_ON "]");
+
+ return g_string_free (str, FALSE);
+}
+
+/**
+ * gabble_group_mixin_change_flags:
+ *
+ * Request a change to be made to the flags. Emits the
+ * signal with the changes which were made.
+ */
+void
+gabble_group_mixin_change_flags (GObject *obj,
+ TpChannelGroupFlags add,
+ TpChannelGroupFlags remove)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ GabbleGroupMixinClass *mixin_cls = GABBLE_GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+ TpChannelGroupFlags added, removed;
+
+ added = add & ~mixin->group_flags;
+ mixin->group_flags |= added;
+
+ removed = remove & mixin->group_flags;
+ mixin->group_flags &= ~removed;
+
+ if (add != 0 || remove != 0)
+ {
+ gchar *str_added, *str_removed, *str_flags;
+
+ if (DEBUGGING)
+ {
+ str_added = group_flags_to_string (added);
+ str_removed = group_flags_to_string (removed);
+ str_flags = group_flags_to_string (mixin->group_flags);
+
+ g_message (ANSI_BOLD_ON ANSI_FG_WHITE
+ "%s: emitting group flags changed\n"
+ " added : %s\n"
+ " removed : %s\n"
+ " flags now: %s\n" ANSI_RESET,
+ G_STRFUNC, str_added, str_removed, str_flags);
+
+ fflush (stdout);
+
+ g_free (str_added);
+ g_free (str_removed);
+ g_free (str_flags);
+ }
+
+ g_signal_emit(obj, mixin_cls->group_flags_changed_signal_id, 0, added, removed);
+ }
+}
+
+static gchar *
+member_array_to_string (GabbleHandleRepo *repo, const GArray *array)
+{
+ GString *str;
+ guint i;
+
+ str = g_string_new ("[" ANSI_BOLD_OFF);
+
+ for (i = 0; i < array->len; i++)
+ {
+ GabbleHandle handle;
+ const gchar *handle_str;
+
+ handle = g_array_index (array, guint32, i);
+ handle_str = gabble_handle_inspect (repo, TP_HANDLE_TYPE_CONTACT, handle);
+
+ g_string_append_printf (str, "%s%u (%s)",
+ (i > 0) ? "\n " : "",
+ handle, handle_str);
+ }
+
+ g_string_append (str, ANSI_BOLD_ON "]");
+
+ return g_string_free (str, FALSE);
+}
+
+static void remove_handle_owners_if_exist (GObject *obj, GArray *array);
+
+/**
+ * gabble_group_mixin_change_members:
+ *
+ * Request members to be added, removed or marked as local or remote pending.
+ * Changes member sets, references, and emits the MembersChanged signal.
+ */
+gboolean
+gabble_group_mixin_change_members (GObject *obj,
+ const gchar *message,
+ GIntSet *add,
+ GIntSet *remove,
+ GIntSet *local_pending,
+ GIntSet *remote_pending,
+ GabbleHandle actor,
+ guint reason)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ GabbleGroupMixinClass *mixin_cls = GABBLE_GROUP_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+ GIntSet *new_add, *new_remove, *new_local_pending,
+ *new_remote_pending, *tmp, *tmp2, *empty;
+ gboolean ret;
+
+ empty = g_intset_new ();
+
+ if (add == NULL)
+ add = empty;
+
+ if (remove == NULL)
+ remove = empty;
+
+ if (local_pending == NULL)
+ local_pending = empty;
+
+ if (remote_pending == NULL)
+ remote_pending = empty;
+
+ /* members + add */
+ new_add = handle_set_update (mixin->members, add);
+
+ /* members - remove */
+ new_remove = handle_set_difference_update (mixin->members, remove);
+
+ /* members - local_pending */
+ tmp = handle_set_difference_update (mixin->members, local_pending);
+ g_intset_destroy (tmp);
+
+ /* members - remote_pending */
+ tmp = handle_set_difference_update (mixin->members, remote_pending);
+ g_intset_destroy (tmp);
+
+
+ /* local pending + local_pending */
+ new_local_pending = handle_set_update (mixin->local_pending, local_pending);
+
+ /* local pending - add */
+ tmp = handle_set_difference_update (mixin->local_pending, add);
+ g_intset_destroy (tmp);
+
+ /* local pending - remove */
+ tmp = handle_set_difference_update (mixin->local_pending, remove);
+ tmp2 = g_intset_union (new_remove, tmp);
+ g_intset_destroy (new_remove);
+ g_intset_destroy (tmp);
+ new_remove = tmp2;
+
+ /* local pending - remote_pending */
+ tmp = handle_set_difference_update (mixin->local_pending, remote_pending);
+ g_intset_destroy (tmp);
+
+
+ /* remote pending + remote_pending */
+ new_remote_pending = handle_set_update (mixin->remote_pending, remote_pending);
+
+ /* remote pending - add */
+ tmp = handle_set_difference_update (mixin->remote_pending, add);
+ g_intset_destroy (tmp);
+
+ /* remote pending - remove */
+ tmp = handle_set_difference_update (mixin->remote_pending, remove);
+ tmp2 = g_intset_union (new_remove, tmp);
+ g_intset_destroy (new_remove);
+ g_intset_destroy (tmp);
+ new_remove = tmp2;
+
+ /* remote pending - local_pending */
+ tmp = handle_set_difference_update (mixin->remote_pending, local_pending);
+ g_intset_destroy (tmp);
+
+ if (g_intset_size (new_add) > 0 ||
+ g_intset_size (new_remove) > 0 ||
+ g_intset_size (new_local_pending) > 0 ||
+ g_intset_size (new_remote_pending) > 0)
+ {
+ GArray *arr_add, *arr_remove, *arr_local, *arr_remote;
+ gchar *add_str, *rem_str, *local_str, *remote_str;
+
+ /* translate intsets to arrays */
+ arr_add = g_intset_to_array (new_add);
+ arr_remove = g_intset_to_array (new_remove);
+ arr_local = g_intset_to_array (new_local_pending);
+ arr_remote = g_intset_to_array (new_remote_pending);
+
+ /* remove any handle owner mappings */
+ remove_handle_owners_if_exist (obj, arr_remove);
+
+ if (DEBUGGING)
+ {
+ add_str = member_array_to_string (mixin->handle_repo, arr_add);
+ rem_str = member_array_to_string (mixin->handle_repo, arr_remove);
+ local_str = member_array_to_string (mixin->handle_repo, arr_local);
+ remote_str = member_array_to_string (mixin->handle_repo, arr_remote);
+
+ g_message (ANSI_BOLD_ON ANSI_FG_CYAN
+ "%s: emitting members changed\n"
+ " message : \"%s\"\n"
+ " added : %s\n"
+ " removed : %s\n"
+ " local_pending : %s\n"
+ " remote_pending: %s\n"
+ " actor : %u\n"
+ " reason : %u: %s\n" ANSI_RESET,
+ G_STRFUNC, message, add_str, rem_str, local_str, remote_str,
+ actor, reason, group_change_reason_str(reason));
+
+ fflush (stdout);
+
+ g_free (add_str);
+ g_free (rem_str);
+ g_free (local_str);
+ g_free (remote_str);
+ }
+
+ if (actor)
+ {
+ handle_set_add (mixin->priv->actors, actor);
+ }
+ /* emit signal */
+ g_signal_emit(obj, mixin_cls->members_changed_signal_id, 0,
+ message,
+ arr_add, arr_remove,
+ arr_local, arr_remote,
+ actor, reason);
+
+ /* free arrays */
+ g_array_free (arr_add, TRUE);
+ g_array_free (arr_remove, TRUE);
+ g_array_free (arr_local, TRUE);
+ g_array_free (arr_remote, TRUE);
+
+ ret = TRUE;
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "not emitting signal, nothing changed");
+
+ ret = FALSE;
+ }
+
+ /* free intsets */
+ g_intset_destroy (new_add);
+ g_intset_destroy (new_remove);
+ g_intset_destroy (new_local_pending);
+ g_intset_destroy (new_remote_pending);
+ g_intset_destroy (empty);
+
+ return ret;
+}
+
+void
+gabble_group_mixin_add_handle_owner (GObject *obj,
+ GabbleHandle local_handle,
+ GabbleHandle owner_handle)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ GabbleGroupMixinPrivate *priv = mixin->priv;
+
+ g_hash_table_insert (priv->handle_owners, GUINT_TO_POINTER (local_handle),
+ GUINT_TO_POINTER (owner_handle));
+
+ gabble_handle_ref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ local_handle);
+ gabble_handle_ref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ owner_handle);
+}
+
+static void
+remove_handle_owners_if_exist (GObject *obj, GArray *array)
+{
+ GabbleGroupMixin *mixin = GABBLE_GROUP_MIXIN (obj);
+ GabbleGroupMixinPrivate *priv = mixin->priv;
+ guint i;
+
+ for (i = 0; i < array->len; i++)
+ {
+ GabbleHandle handle = g_array_index (array, guint32, i);
+ gpointer local_handle, owner_handle;
+
+ if (g_hash_table_lookup_extended (priv->handle_owners,
+ GUINT_TO_POINTER (handle),
+ &local_handle,
+ &owner_handle))
+ {
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ GPOINTER_TO_UINT (local_handle));
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT,
+ GPOINTER_TO_UINT (owner_handle));
+
+ g_hash_table_remove (priv->handle_owners, GUINT_TO_POINTER (handle));
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/handle-set.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,274 @@
+/*
+ * handle-set.c - a set which refs a handle when inserted
+ *
+ * Copyright (C) 2005,2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#include <glib.h>
+#include "gintset.h"
+#include "handles.h"
+
+#include "handle-set.h"
+
+struct _GabbleHandleSet
+{
+ GabbleHandleRepo *repo;
+ GIntSet *intset;
+ TpHandleType type;
+};
+
+/**
+ * handle_set_new:
+ * @repo: #GabbleHandleRepo that holds the handles to be reffed by this set
+ *
+ * Creates a new #GabbleHandleSet
+ *
+ * Returns: A new #GabbleHandleSet
+ */
+
+GabbleHandleSet *
+handle_set_new (GabbleHandleRepo *repo, TpHandleType type)
+{
+ GabbleHandleSet *set = g_new(GabbleHandleSet, 1);
+ set->intset = g_intset_new();
+ set->repo = repo;
+ set->type = type;
+
+ return set;
+}
+
+static void
+freer (GabbleHandleSet *set, GabbleHandle handle, gpointer userdata)
+{
+ handle_set_remove (set, handle);
+}
+
+/**
+ * handle_set_destroy:
+ * @set:#GabbleHandleSet to destroy
+ *
+ * Delete a #GabbleHandleSet and unreference any handles that it holds
+ */
+
+void
+handle_set_destroy (GabbleHandleSet *set)
+{
+ handle_set_foreach (set, freer, NULL);
+ g_intset_destroy (set->intset);
+ g_free (set);
+}
+
+/**
+ * handle_set_peek:
+ * @set:#GabbleHandleSet to peek at
+ *
+ * Get the underlying GIntSet used by this GabbleHandleSet
+ */
+GIntSet *
+handle_set_peek (GabbleHandleSet *set)
+{
+ return set->intset;
+}
+
+/**
+ * handle_set_add:
+ * @set: #GabbleHandleSet to add this handle to
+ * @handle: handle to add
+ *
+ * Add a handle to a #GabbleHandleSet,and reference it in the attched
+ * #GabbleHandleRepo
+ *
+ */
+
+void
+handle_set_add (GabbleHandleSet *set, GabbleHandle handle)
+{
+ g_return_if_fail (set != NULL);
+ g_return_if_fail (handle != 0);
+
+ if (!g_intset_is_member(set->intset, handle))
+ {
+ g_return_if_fail (gabble_handle_ref (set->repo, set->type, handle));
+
+ g_intset_add (set->intset, handle);
+ }
+}
+
+/**
+ * handle_set_remove:
+ * @set: #GabbleHandleSet to remove this handle from
+ * @handle: handle to remove
+ * @type: type of handle
+ *
+ * Remove a handle to a #GabbleHandleSet,and unreference it in the attched
+ * #GabbleHandleRepo
+ *
+ * Returns: FALSE if the (handle,type) pair was invalid, or was not in this set
+ */
+
+
+gboolean
+handle_set_remove (GabbleHandleSet *set, GabbleHandle handle)
+{
+ g_return_val_if_fail (set != NULL, FALSE);
+ g_return_val_if_fail (handle != 0, FALSE);
+
+ if (g_intset_is_member(set->intset, handle))
+ {
+ g_return_val_if_fail (gabble_handle_unref (set->repo, set->type, handle), FALSE);
+
+ g_intset_remove (set->intset, handle);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * handle_set_is_member:
+ * @set: A #GabbleHandleSet
+ * @handle: handle to check
+ * @type: type of handle
+ *
+ * Check if the (handle,type) pair is in this set
+ *
+ * Returns: TRUE if the (handle,type) pair is in this repo
+ *
+ */
+
+gboolean
+handle_set_is_member (GabbleHandleSet *set, GabbleHandle handle)
+{
+ return g_intset_is_member(set->intset, handle);
+}
+
+typedef struct __foreach_data
+{
+ GabbleHandleSet *set;
+ GabbleHandleFunc func;
+ gpointer userdata;
+} _foreach_data;
+
+static void
+foreach_helper(guint i, gpointer userdata)
+{
+ _foreach_data *data = (_foreach_data*) userdata;
+
+ data->func(data->set, i, data->userdata);
+}
+
+void
+handle_set_foreach (GabbleHandleSet *set, GabbleHandleFunc func, gpointer userdata)
+{
+ _foreach_data data; /*= {set, func, userdata};*/
+ data.set = set;
+ data.func = func;
+ data.userdata = userdata;
+ g_intset_foreach (set->intset, foreach_helper, &data);
+}
+
+
+int
+handle_set_size (GabbleHandleSet *set)
+{
+ return g_intset_size (set->intset);
+}
+
+GArray *handle_set_to_array (GabbleHandleSet *set)
+{
+ g_return_val_if_fail (set != NULL, NULL);
+
+ return g_intset_to_array (set->intset);
+}
+
+static void
+ref_one (guint handle, gpointer data)
+{
+ GabbleHandleSet *set = (GabbleHandleSet *) data;
+ gabble_handle_ref (set->repo, set->type, handle);
+}
+
+/**
+ * handle_set_update:
+ * @set: a #GabbleHandleSet to update
+ * @add: a #GIntSet of handles to add
+ *
+ * Add a set of handles to a handle set, referencing those which are not
+ * already members. The GIntSet returned must be freed with g_intset_destroy.
+ *
+ * Returns: the handles which were added
+ */
+
+GIntSet *
+handle_set_update (GabbleHandleSet *set, const GIntSet *add)
+{
+ GIntSet *ret, *tmp;
+
+ g_return_val_if_fail (set != NULL, NULL);
+ g_return_val_if_fail (add != NULL, NULL);
+
+ /* reference each of ADD - CURRENT */
+ ret = g_intset_difference (add, set->intset);
+ g_intset_foreach (ret, ref_one, set);
+
+ /* update CURRENT to be the union of CURRENT and ADD */
+ tmp = g_intset_union (add, set->intset);
+ g_intset_destroy (set->intset);
+ set->intset = tmp;
+
+ return ret;
+}
+
+static void
+unref_one (guint handle, gpointer data)
+{
+ GabbleHandleSet *set = (GabbleHandleSet *) data;
+ gabble_handle_unref (set->repo, set->type, handle);
+}
+
+/**
+ * handle_set_difference_update:
+ * @set: a #GabbleHandleSet to update
+ * @remove: a #GIntSet of handles to remove
+ *
+ * Remove a set of handles from a handle set, dereferencing those which are
+ * members. The GIntSet returned must be freed with g_intset_destroy.
+ *
+ * Returns: the handles which were removed
+ */
+
+GIntSet *
+handle_set_difference_update (GabbleHandleSet *set, const GIntSet *remove)
+{
+ GIntSet *ret, *tmp;
+
+ g_return_val_if_fail (set != NULL, NULL);
+ g_return_val_if_fail (remove != NULL, NULL);
+
+ /* dereference each of REMOVE n CURRENT */
+ ret = g_intset_intersection (remove, set->intset);
+ g_intset_foreach (ret, unref_one, set);
+
+ /* update CURRENT to be CURRENT - REMOVE */
+ tmp = g_intset_difference (set->intset, remove);
+ g_intset_destroy (set->intset);
+ set->intset = tmp;
+
+ return ret;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/handles.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,985 @@
+/*
+ * handles.c - mechanism to store and retrieve handles on a connection
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <string.h>
+
+#include "gheap.h"
+#include "handles.h"
+#include "handle-set.h"
+#include "telepathy-errors.h"
+#include "telepathy-helpers.h"
+#include "util.h"
+
+#include "config.h"
+
+#ifdef ENABLE_HANDLE_LEAK_DEBUG
+#include <stdlib.h>
+#include <stdio.h>
+#include <execinfo.h>
+
+
+typedef struct _HandleLeakTrace HandleLeakTrace;
+
+struct _HandleLeakTrace
+{
+ char **trace;
+ int len;
+};
+
+static void
+handle_leak_trace_free (HandleLeakTrace *hltrace)
+{
+ free (hltrace->trace);
+ g_free (hltrace);
+}
+
+static void
+handle_leak_trace_free_gfunc (gpointer data, gpointer user_data)
+{
+ return handle_leak_trace_free ((HandleLeakTrace *) data);
+}
+
+#endif /* ENABLE_HANDLE_LEAK_DEBUG */
+
+/*#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ gchar** _s_handles_list_handle_strings() { return (gchar**)((libgabble_ImpurePtr()->_s_handles_list_handle_strings)); }
+
+ #define list_handle_strings (GET_WSD_VAR_NAME(list_handle_strings,handles, s)())
+
+#endif*/
+
+
+typedef struct _GabbleHandlePriv GabbleHandlePriv;
+
+struct _GabbleHandlePriv
+{
+ guint refcount;
+ gchar *string;
+#ifdef ENABLE_HANDLE_LEAK_DEBUG
+ GSList *traces;
+#endif /* ENABLE_HANDLE_LEAK_DEBUG */
+ GData *datalist;
+};
+
+struct _GabbleHandleRepo
+{
+ GHashTable *contact_handles;
+ GHashTable *room_handles;
+ GData *list_handles;
+ GHashTable *contact_strings;
+ GHashTable *room_strings;
+ GHeap *free_contact_handles;
+ GHeap *free_room_handles;
+ guint contact_serial;
+ guint room_serial;
+ GData *client_contact_handle_sets;
+ GData *client_room_handle_sets;
+ DBusGProxy *bus_service_proxy;
+};
+
+//#ifndef EMULATOR
+static const char *list_handle_strings[GABBLE_LIST_HANDLE_DENY] =
+{
+ "publish", /* GABBLE_LIST_HANDLE_PUBLISH */
+ "subscribe", /* GABBLE_LIST_HANDLE_SUBSCRIBE */
+ "known", /* GABBLE_LIST_HANDLE_KNOWN */
+ "deny" /* GABBLE_LIST_HANDLE_DENY */
+};
+//#endif
+
+/* private functions */
+
+static GabbleHandlePriv *
+handle_priv_new ()
+{
+ GabbleHandlePriv *priv;
+
+ priv = g_new0 (GabbleHandlePriv, 1);
+
+ g_datalist_init (&(priv->datalist));
+ return priv;
+}
+
+static void
+handle_priv_free (GabbleHandlePriv *priv)
+{
+ g_assert (priv != NULL);
+
+ g_free(priv->string);
+ g_datalist_clear (&(priv->datalist));
+#ifdef ENABLE_HANDLE_LEAK_DEBUG
+ g_slist_foreach (priv->traces, handle_leak_trace_free_gfunc, NULL);
+ g_slist_free (priv->traces);
+#endif /* ENABLE_HANDLE_LEAK_DEBUG */
+ g_free (priv);
+}
+
+static GabbleHandlePriv *
+handle_priv_lookup (GabbleHandleRepo *repo,
+ TpHandleType type,
+ GabbleHandle handle)
+{
+ GabbleHandlePriv *priv = NULL;
+
+ g_assert (repo != NULL);
+ g_assert (gabble_handle_type_is_valid (type, NULL));
+ g_assert (handle != 0);
+
+ switch (type) {
+ case TP_HANDLE_TYPE_CONTACT:
+ priv = g_hash_table_lookup (repo->contact_handles, GINT_TO_POINTER (handle));
+ break;
+ case TP_HANDLE_TYPE_ROOM:
+ priv = g_hash_table_lookup (repo->room_handles, GINT_TO_POINTER (handle));
+ break;
+ case TP_HANDLE_TYPE_LIST:
+ priv = g_datalist_id_get_data (&repo->list_handles, handle);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ return priv;
+}
+
+static GabbleHandle
+gabble_handle_alloc (GabbleHandleRepo *repo, TpHandleType type)
+{
+ GabbleHandle ret = 0;
+
+ g_assert (repo != NULL);
+ g_assert (gabble_handle_type_is_valid (type, NULL));
+
+ switch (type) {
+ case TP_HANDLE_TYPE_CONTACT:
+ if (g_heap_size (repo->free_contact_handles))
+ ret = GPOINTER_TO_UINT (g_heap_extract_first (repo->free_contact_handles));
+ else
+ ret = repo->contact_serial++;
+ break;
+ case TP_HANDLE_TYPE_ROOM:
+ if (g_heap_size (repo->free_room_handles))
+ ret = GPOINTER_TO_UINT (g_heap_extract_first (repo->free_room_handles));
+ else
+ ret = repo->room_serial++;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ return ret;
+}
+
+static gint
+handle_compare_func (gconstpointer a, gconstpointer b)
+{
+ GabbleHandle first = GPOINTER_TO_UINT (a);
+ GabbleHandle second = GPOINTER_TO_UINT (b);
+
+ return (first == second) ? 0 : ((first < second) ? -1 : 1);
+}
+
+static void
+handle_priv_remove (GabbleHandleRepo *repo,
+ TpHandleType type,
+ GabbleHandle handle)
+{
+ GabbleHandlePriv *priv;
+ const gchar *string;
+
+ g_assert (gabble_handle_type_is_valid (type, NULL));
+ g_assert (handle != 0);
+ g_assert (repo != NULL);
+
+ priv = handle_priv_lookup (repo, type, handle);
+
+ g_assert (priv != NULL);
+
+ string = priv->string;
+
+ switch (type) {
+ case TP_HANDLE_TYPE_CONTACT:
+ g_hash_table_remove (repo->contact_strings, string);
+ g_hash_table_remove (repo->contact_handles, GINT_TO_POINTER (handle));
+ if (handle == repo->contact_serial-1)
+ repo->contact_serial--;
+ else
+ g_heap_add (repo->free_contact_handles, GUINT_TO_POINTER (handle));
+ break;
+ case TP_HANDLE_TYPE_ROOM:
+ g_hash_table_remove (repo->room_strings, string);
+ g_hash_table_remove (repo->room_handles, GINT_TO_POINTER (handle));
+ if (handle == repo->room_serial-1)
+ repo->room_serial--;
+ else
+ g_heap_add (repo->free_room_handles, GUINT_TO_POINTER (handle));
+ break;
+ case TP_HANDLE_TYPE_LIST:
+ g_dataset_id_remove_data (&repo->list_handles, handle);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+handles_name_owner_changed_cb (DBusGProxy *proxy,
+ const gchar *name,
+ const gchar *old_owner,
+ const gchar *new_owner,
+ gpointer data)
+{
+ GabbleHandleRepo *repo = (GabbleHandleRepo *) data;
+
+ if (old_owner && strlen (old_owner))
+ {
+ if (!new_owner || !strlen (new_owner))
+ {
+ g_datalist_remove_data (&repo->client_contact_handle_sets, old_owner);
+ g_datalist_remove_data (&repo->client_room_handle_sets, old_owner);
+ }
+ }
+}
+
+/* public API */
+
+/**
+ * gabble_handle_jid_is_valid
+ *
+ * Validates a jid for given handle type and returns TRUE/FALSE
+ * on success/failure. In the latter case further information is
+ * provided through error if set.
+ */
+gboolean
+gabble_handle_jid_is_valid (TpHandleType type, const gchar *jid, GError **error)
+{
+ if (type == TP_HANDLE_TYPE_CONTACT || type == TP_HANDLE_TYPE_ROOM)
+ {
+ if (!strchr (jid, '@'))
+ {
+ g_debug ("%s: jid %s has no @", G_STRFUNC, jid);
+
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "jid %s has no @", jid);
+
+ return FALSE;
+ }
+
+ /* FIXME: do more extensive checking */
+ }
+ else
+ {
+ g_assert_not_reached ();
+ /* FIXME: add checking for other types here */
+ }
+
+ return TRUE;
+}
+
+gboolean
+gabble_handle_type_is_valid (TpHandleType type, GError **error)
+{
+ gboolean ret;
+
+ if (type > TP_HANDLE_TYPE_NONE && type <= TP_HANDLE_TYPE_LIST)
+ {
+ ret = TRUE;
+ }
+ else
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid handle type %u", type);
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
+
+GabbleHandleRepo *
+gabble_handle_repo_new ()
+{
+ GabbleHandleRepo *repo;
+ GabbleHandle publish, subscribe, known, deny;
+
+ repo = g_new0 (GabbleHandleRepo, 1);
+
+ repo->contact_handles = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) handle_priv_free);
+
+ repo->room_handles = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) handle_priv_free);
+
+ repo->contact_strings = g_hash_table_new (g_str_hash, g_str_equal);
+ repo->room_strings = g_hash_table_new (g_str_hash, g_str_equal);
+
+ repo->free_contact_handles = g_heap_new (handle_compare_func);
+ repo->free_room_handles = g_heap_new (handle_compare_func);
+
+ repo->contact_serial = 1;
+ repo->room_serial = 1;
+
+ g_datalist_init (&repo->list_handles);
+
+ publish = GABBLE_LIST_HANDLE_PUBLISH;
+ g_datalist_id_set_data_full (&repo->list_handles, (GQuark) publish,
+ handle_priv_new(), (GDestroyNotify) handle_priv_free);
+
+ subscribe = GABBLE_LIST_HANDLE_SUBSCRIBE;
+ g_datalist_id_set_data_full (&repo->list_handles, (GQuark) subscribe,
+ handle_priv_new(), (GDestroyNotify) handle_priv_free);
+
+ known = GABBLE_LIST_HANDLE_KNOWN;
+ g_datalist_id_set_data_full (&repo->list_handles, (GQuark) known,
+ handle_priv_new(), (GDestroyNotify) handle_priv_free);
+
+ deny = GABBLE_LIST_HANDLE_DENY;
+ g_datalist_id_set_data_full (&repo->list_handles, (GQuark) deny,
+ handle_priv_new(), (GDestroyNotify) handle_priv_free);
+
+ g_datalist_init (&repo->client_contact_handle_sets);
+ g_datalist_init (&repo->client_room_handle_sets);
+
+ repo->bus_service_proxy = dbus_g_proxy_new_for_name (tp_get_bus(),
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ dbus_g_proxy_add_signal (repo->bus_service_proxy,
+ "NameOwnerChanged",
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (repo->bus_service_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (handles_name_owner_changed_cb),
+ repo,
+ NULL);
+
+ return repo;
+}
+
+#ifdef ENABLE_HANDLE_LEAK_DEBUG
+
+static void
+handle_leak_debug_printbt_foreach (gpointer data, gpointer user_data)
+{
+ HandleLeakTrace *hltrace = (HandleLeakTrace *) data;
+ int i;
+
+ for (i = 1; i < hltrace->len; i++)
+ {
+ g_message ("\t\t%s\n", hltrace->trace[i]);
+ }
+
+ g_message ("\n");
+}
+
+static void
+handle_leak_debug_printhandles_foreach (gpointer key, gpointer value, gpointer ignore)
+{
+ GabbleHandle handle = GPOINTER_TO_UINT (key);
+ GabbleHandlePriv *priv = (GabbleHandlePriv *) value;
+
+ g_message ("\t%5u: %s (%u refs), traces:\n", handle, priv->string, priv->refcount);
+
+ g_slist_foreach (priv->traces, handle_leak_debug_printbt_foreach, NULL);
+}
+
+static void
+handle_leak_debug_print_report (GabbleHandleRepo *repo)
+{
+ g_assert (repo != NULL);
+
+ g_message ("The following contact handles were not freed:\n");
+ g_hash_table_foreach (repo->contact_handles, handle_leak_debug_printhandles_foreach, NULL);
+ g_message ("The following room handles were not freed:\n");
+ g_hash_table_foreach (repo->room_handles, handle_leak_debug_printhandles_foreach, NULL);
+}
+
+static HandleLeakTrace *
+handle_leak_debug_bt ()
+{
+ void *bt_addresses[16];
+ HandleLeakTrace *ret = g_new0 (HandleLeakTrace, 1);
+
+ ret->len = backtrace (bt_addresses, 16);
+ ret->trace = backtrace_symbols (bt_addresses, ret->len);
+
+ return ret;
+}
+
+#define HANDLE_LEAK_DEBUG_DO(traces_slist) \
+ { (traces_slist) = g_slist_append ((traces_slist), handle_leak_debug_bt ()); }
+
+#else /* !ENABLE_HANDLE_LEAK_DEBUG */
+
+#define HANDLE_LEAK_DEBUG_DO(traces_slist) {}
+
+#endif /* ENABLE_HANDLE_LEAK_DEBUG */
+
+
+void
+gabble_handle_repo_destroy (GabbleHandleRepo *repo)
+{
+ g_assert (repo != NULL);
+ g_assert (repo->contact_handles);
+ g_assert (repo->room_handles);
+ g_assert (repo->contact_strings);
+ g_assert (repo->room_strings);
+
+ g_datalist_clear (&repo->client_contact_handle_sets);
+ g_datalist_clear (&repo->client_room_handle_sets);
+
+#ifdef ENABLE_HANDLE_LEAK_DEBUG
+ handle_leak_debug_print_report (repo);
+#endif /* ENABLE_HANDLE_LEAK_DEBUG */
+
+ g_hash_table_destroy (repo->contact_handles);
+ g_hash_table_destroy (repo->room_handles);
+ g_hash_table_destroy (repo->contact_strings);
+ g_hash_table_destroy (repo->room_strings);
+ g_heap_destroy (repo->free_contact_handles);
+ g_heap_destroy (repo->free_room_handles);
+ g_datalist_clear (&repo->list_handles);
+
+ dbus_g_proxy_disconnect_signal (repo->bus_service_proxy,
+ "NameOwnerChanged",
+ G_CALLBACK (handles_name_owner_changed_cb),
+ repo);
+ g_object_unref (G_OBJECT (repo->bus_service_proxy));
+
+ g_free (repo);
+}
+
+
+gboolean
+gabble_handle_is_valid (GabbleHandleRepo *repo, TpHandleType type, GabbleHandle handle, GError **error)
+{
+ GArray *arr;
+ gboolean ret;
+
+ arr = g_array_new (FALSE, FALSE, sizeof (GabbleHandle));
+ g_array_insert_val (arr, 0, handle);
+
+ ret = gabble_handles_are_valid (repo, type, arr, FALSE, error);
+
+ g_array_free (arr, TRUE);
+
+ return ret;
+}
+
+gboolean
+gabble_handles_are_valid (GabbleHandleRepo *repo,
+ TpHandleType type,
+ const GArray *array,
+ gboolean allow_zero,
+ GError **error)
+{
+ guint i;
+
+ g_return_val_if_fail (repo != NULL, FALSE);
+ g_return_val_if_fail (array != NULL, FALSE);
+
+ if (!gabble_handle_type_is_valid (type, error))
+ return FALSE;
+
+ for (i = 0; i < array->len; i++)
+ {
+ GabbleHandle handle = g_array_index (array, GabbleHandle, i);
+
+ if (handle == 0)
+ {
+ if (allow_zero)
+ continue;
+
+ g_debug ("someone tried to validate handle zero");
+
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid handle %u", handle);
+ return FALSE;
+ }
+
+ if (handle_priv_lookup (repo, type, handle) == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid handle %u", handle);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
+gboolean
+gabble_handle_ref (GabbleHandleRepo *repo,
+ TpHandleType type,
+ GabbleHandle handle)
+{
+ GabbleHandlePriv *priv;
+
+ if (type == TP_HANDLE_TYPE_LIST)
+ {
+ if (handle >= GABBLE_LIST_HANDLE_PUBLISH && handle <= GABBLE_LIST_HANDLE_DENY)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ priv = handle_priv_lookup (repo, type, handle);
+
+ if (priv == NULL)
+ return FALSE;
+
+ priv->refcount++;
+
+ HANDLE_LEAK_DEBUG_DO (priv->traces);
+
+ return TRUE;
+}
+
+
+gboolean
+gabble_handle_unref (GabbleHandleRepo *repo,
+ TpHandleType type,
+ GabbleHandle handle)
+{
+ GabbleHandlePriv *priv;
+
+ if (type == TP_HANDLE_TYPE_LIST)
+ {
+ if (handle >= GABBLE_LIST_HANDLE_PUBLISH && handle <= GABBLE_LIST_HANDLE_DENY)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ priv = handle_priv_lookup (repo, type, handle);
+
+ if (priv == NULL)
+ return FALSE;
+
+ HANDLE_LEAK_DEBUG_DO (priv->traces);
+
+ g_assert (priv->refcount > 0);
+
+ priv->refcount--;
+
+ if (priv->refcount == 0)
+ handle_priv_remove (repo, type, handle);
+
+ return TRUE;
+}
+
+
+const char *
+gabble_handle_inspect (GabbleHandleRepo *repo,
+ TpHandleType type,
+ GabbleHandle handle)
+{
+ GabbleHandlePriv *priv;
+
+ if (type == TP_HANDLE_TYPE_LIST)
+ {
+ g_assert (handle >= GABBLE_LIST_HANDLE_PUBLISH
+ && handle <= GABBLE_LIST_HANDLE_DENY);
+ return list_handle_strings[handle-1];
+ }
+
+ priv = handle_priv_lookup (repo, type, handle);
+
+ if (priv == NULL)
+ return NULL;
+ else
+ return priv->string;
+}
+
+static GabbleHandle
+_handle_lookup_by_jid (GabbleHandleRepo *repo,
+ const gchar *jid)
+{
+ GabbleHandle handle;
+
+ handle = GPOINTER_TO_UINT (g_hash_table_lookup (repo->contact_strings, jid));
+
+ if (0 == handle)
+ return 0;
+
+ return handle;
+}
+
+
+GabbleHandle
+gabble_handle_for_contact (GabbleHandleRepo *repo,
+ const char *jid,
+ gboolean with_resource)
+{
+ char *username = NULL;
+ char *server = NULL;
+ char *resource = NULL;
+ char *clean_jid = NULL;
+ GabbleHandle handle = 0;
+ GabbleHandlePriv *priv;
+
+ g_assert (repo != NULL);
+ g_assert (jid != NULL);
+ g_assert (*jid != '\0');
+
+ gabble_decode_jid (jid, &username, &server, &resource);
+
+ if (NULL == username || '\0' == *username)
+ goto OUT;
+
+ if (NULL == resource && with_resource)
+ goto OUT;
+
+ if (NULL != resource)
+ {
+ clean_jid = g_strdup_printf ("%s@%s/%s", username, server, resource);
+ handle = _handle_lookup_by_jid (repo, clean_jid);
+
+ if (0 != handle)
+ goto OUT;
+ }
+
+ if (!with_resource)
+ {
+ g_free (clean_jid);
+ clean_jid = g_strdup_printf ("%s@%s", username, server);
+ handle = _handle_lookup_by_jid (repo, clean_jid);
+
+ if (0 != handle)
+ goto OUT;
+ }
+
+ handle = gabble_handle_alloc (repo, TP_HANDLE_TYPE_CONTACT);
+ priv = handle_priv_new ();
+ priv->string = clean_jid;
+ clean_jid = NULL;
+ g_hash_table_insert (repo->contact_handles, GINT_TO_POINTER (handle), priv);
+ g_hash_table_insert (repo->contact_strings, priv->string, GUINT_TO_POINTER (handle));
+
+ HANDLE_LEAK_DEBUG_DO (priv->traces);
+
+OUT:
+
+ g_free (clean_jid);
+ g_free (username);
+ g_free (server);
+ g_free (resource);
+ return handle;
+}
+
+gboolean
+gabble_handle_for_room_exists (GabbleHandleRepo *repo,
+ const gchar *jid,
+ gboolean ignore_nick)
+{
+ GabbleHandle handle;
+ gchar *room, *service, *nick;
+ gchar *clean_jid;
+
+ gabble_decode_jid (jid, &room, &service, &nick);
+
+ if (!room || !service || room[0] == '\0')
+ return FALSE;
+
+ if (ignore_nick || !nick)
+ clean_jid = g_strdup_printf ("%s@%s", room, service);
+ else
+ clean_jid = g_strdup_printf ("%s@%s/%s", room, service, nick);
+
+ handle = GPOINTER_TO_UINT (g_hash_table_lookup (repo->room_strings,
+ clean_jid));
+
+ g_free (clean_jid);
+ g_free (room);
+ g_free (service);
+ g_free (nick);
+
+ if (handle == 0)
+ return FALSE;
+
+ return (handle_priv_lookup (repo, TP_HANDLE_TYPE_ROOM, handle) != NULL);
+}
+
+
+GabbleHandle
+gabble_handle_for_room (GabbleHandleRepo *repo,
+ const gchar *jid)
+{
+ GabbleHandle handle;
+ gchar *room, *service, *clean_jid;
+
+ g_assert (repo != NULL);
+ g_assert (jid != NULL);
+ g_assert (*jid != '\0');
+
+ handle = 0;
+
+ room = service = NULL;
+ gabble_decode_jid (jid, &room, &service, NULL);
+
+ if (room && service && *room != '\0')
+ {
+ clean_jid = g_strdup_printf ("%s@%s", room, service);
+
+ handle = GPOINTER_TO_UINT (g_hash_table_lookup (repo->room_strings, clean_jid));
+
+ if (handle == 0)
+ {
+ GabbleHandlePriv *priv;
+ handle = gabble_handle_alloc (repo, TP_HANDLE_TYPE_ROOM);
+ priv = handle_priv_new ();
+ priv->string = clean_jid;
+ g_hash_table_insert (repo->room_handles, GUINT_TO_POINTER (handle), priv);
+ g_hash_table_insert (repo->room_strings, clean_jid, GUINT_TO_POINTER (handle));
+ HANDLE_LEAK_DEBUG_DO (priv->traces);
+ }
+ else
+ {
+ g_free (clean_jid);
+ }
+ }
+
+ g_free (room);
+ g_free (service);
+
+ return handle;
+}
+
+
+GabbleHandle
+gabble_handle_for_list (GabbleHandleRepo *repo,
+ const gchar *list)
+{
+ GabbleHandle handle = 0;
+ int i;
+
+ g_assert (repo != NULL);
+ g_assert (list != NULL);
+
+ for (i = 0; i < GABBLE_LIST_HANDLE_DENY; i++)
+ {
+ if (0 == strcmp (list_handle_strings[i], list))
+ handle = (GabbleHandle) i + 1;
+ }
+
+ return handle;
+}
+
+/**
+ * gabble_handle_set_qdata:
+ * @repo: A #GabbleHandleRepo
+ * @type: The handle type
+ * @handle: A handle to set data on
+ * @key_id: Key id to associate data with
+ * @data: data to associate with handle
+ * @destroy: A #GDestroyNotify to call to detroy the data,
+ * or NULL if not needed.
+ *
+ * Associates a blob of data with a given handle and a given key
+ *
+ * If @destroy is set, then the data is freed when the handle is freed.
+ */
+
+gboolean
+gabble_handle_set_qdata (GabbleHandleRepo *repo,
+ TpHandleType type, GabbleHandle handle,
+ GQuark key_id, gpointer data, GDestroyNotify destroy)
+{
+ GabbleHandlePriv *priv;
+ priv = handle_priv_lookup (repo, type, handle);
+
+ if (!priv)
+ return FALSE;
+
+ g_datalist_id_set_data_full (&priv->datalist, key_id, data, destroy);
+ return TRUE;
+}
+
+/**
+ * gabble_handle_get_qdata:
+ * @repo: A #GabbleHandleRepo
+ * @type: The handle type
+ * @handle: A handle to get data from
+ * @key_id: Key id of data to fetch
+ *
+ * Gets the data associated with a given key on a given handle
+ */
+gpointer
+gabble_handle_get_qdata (GabbleHandleRepo *repo,
+ TpHandleType type, GabbleHandle handle,
+ GQuark key_id)
+{
+ GabbleHandlePriv *priv;
+ priv = handle_priv_lookup (repo, type, handle);
+
+ if (!priv)
+ return NULL;
+
+ return g_datalist_id_get_data(&priv->datalist, key_id);
+}
+
+/**
+ * gabble_handle_client_hold:
+ * @repo: a #GabbleHandleRepo
+ * @client_name: D-Bus bus name of client to hold the handle for
+ * @handle: the handle to hold
+ * @type: type of handle to hold
+ * @error: used to return a pointer to a GError detailing any error that occurred
+ *
+ * Marks a handle as held by a given client.
+ *
+ * Returns: Whether the handle was succesfully marked as held or an error occurred.
+ */
+
+gboolean
+gabble_handle_client_hold (GabbleHandleRepo *repo,
+ const gchar *client_name,
+ GabbleHandle handle,
+ TpHandleType type,
+ GError **error)
+{
+ GData **handle_set_list;
+ GabbleHandleSet *handle_set;
+
+ g_assert (repo != NULL);
+
+ switch (type)
+ {
+ case TP_HANDLE_TYPE_CONTACT:
+ handle_set_list = &repo->client_contact_handle_sets;
+ break;
+ case TP_HANDLE_TYPE_ROOM:
+ handle_set_list = &repo->client_room_handle_sets;
+ break;
+ case TP_HANDLE_TYPE_LIST:
+ /* no-op */
+ return TRUE;
+ default:
+ g_critical ("%s: called with invalid handle type %u", G_STRFUNC, type);
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid handle type %u", type);
+ return FALSE;
+ }
+
+ if (!client_name || *client_name == '\0')
+ {
+ g_critical ("%s: called with invalid client name", G_STRFUNC);
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid client name");
+ return FALSE;
+ }
+
+ handle_set = (GabbleHandleSet*) g_datalist_get_data (handle_set_list, client_name);
+
+ if (!handle_set)
+ {
+ handle_set = handle_set_new (repo, type);
+ g_datalist_set_data_full (handle_set_list,
+ client_name,
+ handle_set,
+ (GDestroyNotify) handle_set_destroy);
+ }
+
+ handle_set_add (handle_set, handle);
+
+ return TRUE;
+}
+
+/**
+ * gabble_handle_client_release:
+ * @repo: a #GabbleHandleRepo
+ * @client_name: D-Bus bus name of client to release the handle for
+ * @handle: the handle to release
+ * @type: type of handle to release
+ * @error: used to return a pointer to a GError detailing any error that occurred
+ *
+ * Unmarks a handle as held by a given client.
+ *
+ * Returns: Whether the handle had been marked as held by the given client and now unmarked or not.
+ */
+
+gboolean
+gabble_handle_client_release (GabbleHandleRepo *repo,
+ const gchar *client_name,
+ GabbleHandle handle,
+ TpHandleType type,
+ GError **error)
+{
+ GData **handle_set_list;
+ GabbleHandleSet *handle_set;
+
+ g_assert (repo != NULL);
+
+ switch (type)
+ {
+ case TP_HANDLE_TYPE_CONTACT:
+ handle_set_list = &repo->client_contact_handle_sets;
+ break;
+ case TP_HANDLE_TYPE_ROOM:
+ handle_set_list = &repo->client_room_handle_sets;
+ break;
+ case TP_HANDLE_TYPE_LIST:
+ /* no-op */
+ return TRUE;
+ default:
+ g_critical ("%s: called with invalid handle type %u", G_STRFUNC, type);
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid handle type %u", type);
+ return FALSE;
+ }
+
+ if (!client_name || *client_name == '\0')
+ {
+ g_critical ("%s: called with invalid client name", G_STRFUNC);
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid client name");
+ return FALSE;
+ }
+
+ handle_set = (GabbleHandleSet*) g_datalist_get_data (handle_set_list, client_name);
+
+ if (!handle_set)
+ {
+ g_critical ("%s: no handle set found for the given client %s", G_STRFUNC, client_name);
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "the given client %s wasn't holding any handles", client_name);
+ return FALSE;
+ }
+
+ if (!handle_set_remove (handle_set, handle))
+ {
+ g_critical ("%s: the client %s wasn't holding the handle %u", G_STRFUNC,
+ client_name, handle);
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "the given client %s wasn't holding the handle %u", client_name,
+ handle);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/im-factory.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,474 @@
+/*
+ * im-factory.c - Source for GabbleImFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "loudmouth/loudmouth.h"
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "gabble-im-channel.h"
+#include "handles.h"
+#include "telepathy-interfaces.h"
+#include "text-mixin.h"
+#include "tp-channel-factory-iface.h"
+
+#include "im-factory.h"
+
+static void gabble_im_factory_iface_init (gpointer g_iface, gpointer iface_data);
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleImFactory, gabble_im_factory, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE, gabble_im_factory_iface_init));
+#endif
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(gabble_im_factory_parent_class,im_factory,gpointer)
+ #define gabble_im_factory_parent_class (*GET_WSD_VAR_NAME(gabble_im_factory_parent_class,im_factory,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,im_factory,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,im_factory,s)())
+
+static void gabble_im_factory_init (GabbleImFactory *self);
+static void gabble_im_factory_class_init (GabbleImFactoryClass *klass);
+static void gabble_im_factory_class_intern_init (gpointer klass)
+{
+ gabble_im_factory_parent_class = g_type_class_peek_parent (klass);
+ gabble_im_factory_class_init ((GabbleImFactoryClass*) klass);
+ }
+ EXPORT_C GType gabble_im_factory_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleImFactoryClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_im_factory_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleImFactory), 0, (GInstanceInitFunc) gabble_im_factory_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleImFactory"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) gabble_im_factory_iface_init }; g_type_add_interface_static (g_define_type_id, tp_channel_factory_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+
+#endif
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_IM
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+typedef struct _GabbleImFactoryPrivate GabbleImFactoryPrivate;
+struct _GabbleImFactoryPrivate
+{
+ GabbleConnection *conn;
+ LmMessageHandler *message_cb;
+ GHashTable *channels;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_IM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GABBLE_TYPE_IM_FACTORY, GabbleImFactoryPrivate))
+
+static GObject *gabble_im_factory_constructor (GType type, guint n_props, GObjectConstructParam *props);
+
+static void
+gabble_im_factory_init (GabbleImFactory *fac)
+{
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ priv->channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, g_object_unref);
+
+ priv->message_cb = NULL;
+
+ priv->conn = NULL;
+ priv->dispose_has_run = FALSE;
+}
+
+static GObject *
+gabble_im_factory_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ /* GabbleImFactoryPrivate *priv; */
+
+ obj = G_OBJECT_CLASS (gabble_im_factory_parent_class)->
+ constructor (type, n_props, props);
+ /* priv = GABBLE_IM_FACTORY_GET_PRIVATE (obj); */
+
+ return obj;
+}
+
+
+static void
+gabble_im_factory_dispose (GObject *object)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (object);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+ priv->dispose_has_run = TRUE;
+
+ tp_channel_factory_iface_close_all (TP_CHANNEL_FACTORY_IFACE (object));
+ g_assert (priv->channels == NULL);
+
+ if (G_OBJECT_CLASS (gabble_im_factory_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_im_factory_parent_class)->dispose (object);
+}
+
+static void
+gabble_im_factory_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (object);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_im_factory_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (object);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_im_factory_class_init (GabbleImFactoryClass *gabble_im_factory_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_im_factory_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_im_factory_class, sizeof (GabbleImFactoryPrivate));
+
+ object_class->constructor = gabble_im_factory_constructor;
+ object_class->dispose = gabble_im_factory_dispose;
+
+ object_class->get_property = gabble_im_factory_get_property;
+ object_class->set_property = gabble_im_factory_set_property;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "IM channel factory object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+}
+
+static GabbleIMChannel *new_im_channel (GabbleImFactory *fac, GabbleHandle handle);
+
+static void im_channel_closed_cb (GabbleIMChannel *chan, gpointer user_data);
+
+
+/**
+ * im_factory_message_cb:
+ *
+ * Called by loudmouth when we get an incoming <message>.
+ */
+static LmHandlerResult
+im_factory_message_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (user_data);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ const gchar *from, *body, *body_offset;
+ time_t stamp;
+ TpChannelTextMessageType msgtype;
+ GabbleHandle handle;
+ GabbleIMChannel *chan;
+ GabbleTextMixinSendError send_error;
+
+ if (!gabble_text_mixin_parse_incoming_message (message, &from, &stamp, &msgtype, &body, &body_offset, &send_error))
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ if (body == NULL)
+ {
+ NODE_DEBUG (message->node, "got a message without a body field, ignoring");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ handle = gabble_handle_for_contact (priv->conn->handles, from, FALSE);
+ if (handle == 0)
+ {
+ NODE_DEBUG (message->node, "ignoring message node from malformed jid");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ gabble_debug (DEBUG_FLAG, "message from %s (handle %u), msgtype %d, body:\n%s",
+ from, handle, msgtype, body_offset);
+
+ chan = g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle));
+
+ if (chan == NULL)
+ {
+ if (send_error != CHANNEL_TEXT_SEND_NO_ERROR)
+ {
+ gabble_debug (DEBUG_FLAG, "ignoring message error; no sending channel");
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ gabble_debug (DEBUG_FLAG, "found no IM channel, creating one");
+
+ chan = new_im_channel (fac, handle);
+ }
+
+ if (send_error != CHANNEL_TEXT_SEND_NO_ERROR)
+ {
+ _gabble_text_mixin_send_error_signal (G_OBJECT (chan), send_error, stamp,
+ msgtype, body_offset);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ if (_gabble_im_channel_receive (chan, msgtype, handle, from,
+ stamp, body_offset))
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+/**
+ * im_channel_closed_cb:
+ *
+ * Signal callback for when an IM channel is closed. Removes the references
+ * that #GabbleConnection holds to them.
+ */
+static void
+im_channel_closed_cb (GabbleIMChannel *chan, gpointer user_data)
+{
+ GabbleImFactory *conn = GABBLE_IM_FACTORY (user_data);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (conn);
+ GabbleHandle contact_handle;
+
+ if (priv->channels)
+ {
+ g_object_get (chan, "handle", &contact_handle, NULL);
+
+ gabble_debug (DEBUG_FLAG, "removing channel with handle %d", contact_handle);
+
+ g_hash_table_remove (priv->channels, GINT_TO_POINTER (contact_handle));
+ }
+}
+
+/**
+ * new_im_channel
+ */
+static GabbleIMChannel *
+new_im_channel (GabbleImFactory *fac, GabbleHandle handle)
+{
+ GabbleImFactoryPrivate *priv;
+ GabbleIMChannel *chan;
+ char *object_path;
+
+ g_assert (GABBLE_IS_IM_FACTORY (fac));
+
+ priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ object_path = g_strdup_printf ("%s/ImChannel%u", priv->conn->object_path, handle);
+
+ chan = g_object_new (GABBLE_TYPE_IM_CHANNEL,
+ "connection", priv->conn,
+ "object-path", object_path,
+ "handle", handle,
+ NULL);
+
+ gabble_debug (DEBUG_FLAG, "object path %s", object_path);
+
+ g_signal_connect (chan, "closed", (GCallback) im_channel_closed_cb, fac);
+
+ g_hash_table_insert (priv->channels, GINT_TO_POINTER (handle), chan);
+
+ g_signal_emit_by_name (fac, "new-channel", chan);
+
+ g_free (object_path);
+
+ return chan;
+}
+
+static void
+gabble_im_factory_iface_close_all (TpChannelFactoryIface *iface)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (iface);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "closing channels");
+
+ if (priv->channels)
+ {
+ GHashTable *tmp = priv->channels;
+ priv->channels = NULL;
+ g_hash_table_destroy (tmp);
+ }
+}
+
+static void
+gabble_im_factory_iface_connecting (TpChannelFactoryIface *iface)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (iface);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "adding callbacks");
+
+ g_assert (priv->message_cb == NULL);
+
+ priv->message_cb = lm_message_handler_new (im_factory_message_cb, fac, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn, priv->message_cb,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_LAST);
+}
+
+
+
+static void
+gabble_im_factory_iface_connected (TpChannelFactoryIface *iface)
+{
+ /* nothing to do */
+}
+
+static void
+gabble_im_factory_iface_disconnected (TpChannelFactoryIface *iface)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (iface);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "removing callbacks");
+
+ g_assert (priv->message_cb != NULL);
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn, priv->message_cb,
+ LM_MESSAGE_TYPE_MESSAGE);
+ lm_message_handler_unref (priv->message_cb);
+ priv->message_cb = NULL;
+}
+
+struct _ForeachData
+{
+ TpChannelFunc foreach;
+ gpointer user_data;
+};
+
+static void
+_foreach_slave (gpointer key, gpointer value, gpointer user_data)
+{
+ struct _ForeachData *data = (struct _ForeachData *) user_data;
+ TpChannelIface *chan = TP_CHANNEL_IFACE (value);
+
+ data->foreach (chan, data->user_data);
+}
+
+static void
+gabble_im_factory_iface_foreach (TpChannelFactoryIface *iface, TpChannelFunc foreach, gpointer user_data)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (iface);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+ struct _ForeachData data;
+
+ data.user_data = user_data;
+ data.foreach = foreach;
+
+ g_hash_table_foreach (priv->channels, _foreach_slave, &data);
+}
+
+static TpChannelFactoryRequestStatus
+gabble_im_factory_iface_request (TpChannelFactoryIface *iface,
+ const gchar *chan_type,
+ TpHandleType handle_type,
+ guint handle,
+ TpChannelIface **ret,
+ GError **error)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (iface);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+ GabbleIMChannel *chan;
+
+ if (strcmp (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
+
+ if (handle_type != TP_HANDLE_TYPE_CONTACT)
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+
+ if (!gabble_handle_is_valid (priv->conn->handles, handle_type, handle, error))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_ERROR;
+
+ chan = g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle));
+
+ if (!chan)
+ chan = new_im_channel (fac, handle);
+
+ g_assert (chan);
+ *ret = TP_CHANNEL_IFACE (chan);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE;
+}
+
+static void
+gabble_im_factory_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
+
+ klass->close_all = gabble_im_factory_iface_close_all;
+ klass->connecting = gabble_im_factory_iface_connecting;
+ klass->connected = gabble_im_factory_iface_connected;
+ klass->disconnected = gabble_im_factory_iface_disconnected;
+ klass->foreach = gabble_im_factory_iface_foreach;
+ klass->request = gabble_im_factory_iface_request;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/jingle-info.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,238 @@
+/*
+ * jingle-info.c - Source for Jingle info discovery
+ * Copyright (C) 2006 Collabora Ltd.
+ * Portions and/or its subsidiary/subsidiaries.All rights reserved.
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+
+#include "debug.h"
+#include "jingle-info.h"
+#include "gabble-error.h"
+#include "namespaces.h"
+#include "util.h"
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/**
+ * jingle_info_discover_servers:
+ *
+ * Discover available Jingle servers.
+ *
+ * @conn: The GabbleConnection# object initiating the discovery.
+ */
+void
+jingle_info_discover_servers (GabbleConnection *conn)
+{
+ LmMessage *msg = NULL;
+ LmMessageNode *node;
+ GError *error = NULL;
+ GabbleHandle handle = conn->self_handle;
+ const gchar *jid = gabble_handle_inspect (conn->handles, TP_HANDLE_TYPE_CONTACT, handle);
+
+ msg = lm_message_new_with_sub_type (jid, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+
+ node = lm_message_node_add_child (msg->node, "query", NULL);
+ lm_message_node_set_attribute (node, "xmlns", NS_GOOGLE_JINGLE_INFO);
+
+ if (!_gabble_connection_send (conn, msg, &error))
+ {
+ g_warning ("%s: send failed: %s\n", G_STRFUNC, error->message);
+ goto OUT;
+ }
+
+OUT:
+ if (msg)
+ lm_message_unref (msg);
+
+ if (error)
+ g_error_free (error);
+}
+
+
+/**
+ * jingle_info_iq_callback
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler
+ * is concerned only with Jingle info queries.
+ */
+LmHandlerResult
+jingle_info_iq_callback (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+ LmMessageSubType sub_type;
+ LmMessageNode *query_node, *parent_node, *node;
+ const gchar *str;
+ guint port;
+
+ if ( NULL == conn )
+ {
+ g_debug ("%s: accesing after dereferenced connection", G_STRFUNC);
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ query_node = lm_message_node_get_child_with_namespace (message->node,
+ "query", NS_GOOGLE_JINGLE_INFO);
+
+ if (query_node == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ NODE_DEBUG (message->node, "got");
+
+ sub_type = lm_message_get_sub_type (message);
+
+ if (sub_type == LM_MESSAGE_SUB_TYPE_RESULT ||
+ sub_type == LM_MESSAGE_SUB_TYPE_SET)
+ {
+ parent_node = lm_message_node_get_child (query_node, "stun");
+ if (parent_node)
+ {
+ for (node = parent_node->children; node; node = node->next)
+ {
+ if (strcmp (node->name, "server") == 0)
+ {
+ str = lm_message_node_get_attribute (node, "host");
+ if (str)
+ {
+ gabble_debug (DEBUG_FLAG, "setting 'stun-server' to '%s'", str);
+
+ g_object_set (conn, "stun-server", str, NULL);
+ }
+
+ str = lm_message_node_get_attribute (node, "udp");
+ if (str)
+ {
+ port = atoi (str);
+
+ gabble_debug (DEBUG_FLAG, "setting 'stun-port' to %d", port);
+
+ g_object_set (conn, "stun-port", port, NULL);
+ }
+
+ /* only grab the first one for now */
+ break;
+ }
+ }
+ }
+
+ parent_node = lm_message_node_get_child (query_node, "relay");
+ if (parent_node)
+ {
+ gboolean found_server = FALSE;
+
+ for (node = parent_node->children; node; node = node->next)
+ {
+ if (!found_server && strcmp (node->name, "server") == 0)
+ {
+ str = lm_message_node_get_attribute (node, "host");
+ if (str)
+ {
+ gabble_debug (DEBUG_FLAG, "setting 'stun-relay-server' to '%s'",
+ str);
+
+ g_object_set (conn, "stun-relay-server", str, NULL);
+ }
+
+ str = lm_message_node_get_attribute (node, "udp");
+ if (str)
+ {
+ port = atoi (str);
+
+ gabble_debug (DEBUG_FLAG, "setting 'stun-relay-udp-port' to %d",
+ port);
+
+ g_object_set (conn, "stun-relay-udp-port", port, NULL);
+ }
+
+ str = lm_message_node_get_attribute (node, "tcp");
+ if (str)
+ {
+ port = atoi (str);
+
+ gabble_debug (DEBUG_FLAG, "setting 'stun-relay-tcp-port' to %d",
+ port);
+
+ g_object_set (conn, "stun-relay-tcp-port", port, NULL);
+ }
+
+ str = lm_message_node_get_attribute (node, "tcpssl");
+ if (str)
+ {
+ port = atoi (str);
+
+ gabble_debug (DEBUG_FLAG, "setting 'stun-relay-ssltcp-port' to %d",
+ port);
+
+ g_object_set (conn, "stun-relay-ssltcp-port", port, NULL);
+ }
+
+ found_server = TRUE;
+ }
+ else if (strcmp (node->name, "token") == 0)
+ {
+ str = lm_message_node_get_value (node);
+ if (str)
+ {
+ gabble_debug (DEBUG_FLAG, "setting 'stun-relay-magic-cookie' to '%s'",
+ str);
+
+ g_object_set (conn, "stun-relay-magic-cookie", str, NULL);
+ }
+ }
+ }
+ }
+
+ if (sub_type == LM_MESSAGE_SUB_TYPE_SET)
+ {
+ _gabble_connection_acknowledge_set_iq (conn, message);
+ }
+ }
+ else if (sub_type == LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ GabbleXmppError xmpp_error = INVALID_XMPP_ERROR;
+
+ node = lm_message_node_get_child (message->node, "error");
+ if (node)
+ {
+ xmpp_error = gabble_xmpp_error_from_node (node);
+ }
+
+ str = gabble_xmpp_error_string (xmpp_error);
+
+ g_warning ("%s: jingle info error: %s", G_STRFUNC,
+ (str) ? str : "unknown error");
+ }
+ else
+ {
+ NODE_DEBUG (message->node, "unknown message sub type");
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/libgabble_wsd.cpp Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,378 @@
+/*
+ * libgabble_wsd.cpp part of telepathygabble
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <e32std.h>
+#include "libgabble_wsd_solution.h"
+#include "gabble_enums.h"
+#include <string.h>
+#include "telepathy-interfaces.h"
+#include <pls.h> // For emulator WSD API
+
+const TUid KLibGabbleUid3 = {0x2000F852}; // This is the UID of the library
+struct libgabble_global_struct *libgabble_ImpurePtr()
+{
+ #if defined(__WINSCW__) || defined(__WINS__)
+
+ // Access the PLS of this process
+ struct libgabble_global_struct *g = Pls<struct libgabble_global_struct>(KLibGabbleUid3, &libgabble_Init);
+ return g;
+
+ #else
+
+ return NULL;
+
+ #endif
+}
+
+int libgabble_Init(libgabble_global_struct *g)
+{
+
+
+Handler handlers[10] = {
+ {
+ { "initiate", "session-initiate", NULL },
+ JS_STATE_PENDING_CREATED,
+ JS_STATE_PENDING_CREATED,
+ { NULL },
+ JS_STATE_PENDING_INITIATED
+ },
+ {
+ { "accept", "session-accept", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_PENDING_INITIATED,
+ { NULL },
+ JS_STATE_ACTIVE
+ },
+ {
+ { "reject", NULL },
+ JS_STATE_PENDING_INITIATE_SENT,
+ JS_STATE_PENDING_INITIATED,
+ { NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "terminate", "session-terminate", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ENDED,
+ { NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "candidates", "transport-info", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "content-add", NULL },
+ JS_STATE_ACTIVE,
+ JS_STATE_ACTIVE,
+ { NULL },
+ JS_STATE_INVALID,
+ },
+ {
+ { "content-modify", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "content-accept", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { "content-remove", "content-decline", NULL },
+ JS_STATE_PENDING_INITIATED,
+ JS_STATE_ACTIVE,
+ { NULL },
+ JS_STATE_INVALID
+ },
+ {
+ { NULL },
+ JS_STATE_INVALID,
+ JS_STATE_INVALID,
+ { NULL },
+ JS_STATE_INVALID
+ }
+};
+
+GDebugKey keys[] = {
+ { "presence", GABBLE_DEBUG_PRESENCE },
+ { "groups", GABBLE_DEBUG_GROUPS },
+ { "roster", GABBLE_DEBUG_ROSTER },
+ { "disco", GABBLE_DEBUG_DISCO },
+ { "properties", GABBLE_DEBUG_PROPERTIES },
+ { "roomlist", GABBLE_DEBUG_ROOMLIST },
+ { "media-channel", GABBLE_DEBUG_MEDIA },
+ { "muc", GABBLE_DEBUG_MUC },
+ { "connection", GABBLE_DEBUG_CONNECTION },
+ { "persist", GABBLE_DEBUG_PERSIST },
+ { "vcard", GABBLE_DEBUG_VCARD },
+ { 0, },
+};
+
+gchar NO_ALIAS[10] = "none";
+
+gchar assumed_caps[3][150] =
+{
+ TP_IFACE_CHANNEL_TYPE_TEXT,
+ TP_IFACE_CHANNEL_INTERFACE_GROUP,
+ NULL
+};
+
+
+gchar muc_roles[4][20] =
+{
+ "none",
+ "visitor",
+ "participant",
+ "moderator",
+};
+
+gchar muc_affiliations[4][20] =
+{
+ "none",
+ "member",
+ "admin",
+ "owner",
+};
+
+gchar video_codec_params[6][20] = {
+ "x", "y", "width", "height", "layer", "transparent",
+};
+
+
+char list_handle_strings[4][20] =
+{
+ "publish", /* GABBLE_LIST_HANDLE_PUBLISH */
+ "subscribe", /* GABBLE_LIST_HANDLE_SUBSCRIBE */
+ "known", /* GABBLE_LIST_HANDLE_KNOWN */
+ "deny" /* GABBLE_LIST_HANDLE_DENY */
+};
+
+ if(g)
+ {
+
+
+ //g->GET_WSD_VAR_NAME(flags,gabble_debug,s) = flags;
+ g->GET_WSD_VAR_NAME(log_handler, gabble_debug, s) = 0;
+ g->GET_WSD_VAR_NAME(etype,gabble_enum_types,s) = 0;
+
+ g->GET_WSD_VAR_NAME(etype,gabble_media_session_enum_types,s) = 0;
+ g->GET_WSD_VAR_NAME(etype1,gabble_media_session_enum_types,s) = 0;
+ g->GET_WSD_VAR_NAME(etype2,gabble_media_session_enum_types,s) = 0;
+
+
+
+
+ g->GET_WSD_VAR_NAME(quark,gabble_disco,s) = 0;
+ g->GET_WSD_VAR_NAME(quark,gabble_error,s) = 0;
+
+
+ g->GET_WSD_VAR_NAME(ssl,gabble_conmgr,s) = TRUE;
+ g->GET_WSD_VAR_NAME(httpport,gabble_conmgr,s) = 8080;
+ g->GET_WSD_VAR_NAME(httpproxyport,gabble_conmgr,s) = 443;
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_conmgr,s)),0,LAST_SIGNAL_CON_MGR*sizeof(guint));
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_con,s)),0,LAST_SIGNAL_CON*sizeof(guint));
+ g->GET_WSD_VAR_NAME(arguments,gabble_con, s) = NULL;
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_im,s)),0,LAST_SIGNAL_IM*sizeof(guint));
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_search,s)),0,LAST_SIGNAL_SEARCH*sizeof(guint));
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_muc,s)),0,LAST_SIGNAL_MUC*sizeof(guint));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_med_chnl,s)),0,LAST_SIGNAL_MED_CHANNEL*sizeof(guint));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_med_sess,s)),0,LAST_SIGNAL_MED_SESSION*sizeof(guint));
+
+
+
+
+ g->GET_WSD_VAR_NAME(google_audio_caps,gabble_med_sess,s) = PRESENCE_CAP_GOOGLE_VOICE;
+
+ int some = PRESENCE_CAP_JINGLE | PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO |
+ PRESENCE_CAP_GOOGLE_TRANSPORT_P2P;
+
+ g->GET_WSD_VAR_NAME(jingle_audio_caps,gabble_med_sess,s) = (GabblePresenceCapabilities)some;
+
+ some = PRESENCE_CAP_JINGLE | PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO |
+ PRESENCE_CAP_GOOGLE_TRANSPORT_P2P;
+ g->GET_WSD_VAR_NAME(jingle_video_caps,gabble_med_sess,s) =
+ (GabblePresenceCapabilities) some;
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_med_sess,s)),0,MAX_STREAM_NAME_LEN*sizeof(gchar));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_med_stream,s)),0,LAST_SIGNAL_MED_STREAM*sizeof(guint));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_pre_cache,s)),0,LAST_SIGNAL_PRE_CACHE*sizeof(guint));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_register,s)),0,LAST_SIGNAL_REGISTER*sizeof(guint));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_ros_chnl,s)),0,LAST_SIGNAL_ROS_CHNL*sizeof(guint));
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_room_chnl,s)),0,LAST_SIGNAL_ROOM_CHNL*sizeof(guint));
+
+ g->GET_WSD_VAR_NAME(offset_quark1,gabble_mixin,s) = 0;
+ g->GET_WSD_VAR_NAME(offset_quark,gabble_mixin,s) = 0;
+
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_roster,s)),0,LAST_SIGNAL_ROSTER*sizeof(guint));
+
+ g->GET_WSD_VAR_NAME(quark,gabble_errors,s) = 0;
+
+ g->GET_WSD_VAR_NAME(busCon,gabble_helpers,s) = NULL;
+ g->GET_WSD_VAR_NAME(bus_proxy,gabble_helpers,s) = NULL;
+
+ g->GET_WSD_VAR_NAME(offset_quark1,gabble_txt_mixin,s) = 0;
+ g->GET_WSD_VAR_NAME(offset_quark,gabble_txt_mixin,s) = 0;
+
+ memset(&(g->GET_WSD_VAR_NAME(alloc1,gabble_txt_mixin,s)),0,sizeof(GabbleAllocator));
+
+ g->GET_WSD_VAR_NAME(type,gabble_chnl_iface,s) = 0;
+ g->GET_WSD_VAR_NAME(initialized,gabble_chnl_iface,s) = EFalse;
+
+ g->GET_WSD_VAR_NAME(type,gabble_fac_iface,s) = 0;
+ g->GET_WSD_VAR_NAME(initialized,gabble_fac_iface,s) = EFalse;
+
+ memset(&(g->GET_WSD_VAR_NAME(signals,gabble_vcard_mgr,s)),0,LAST_SIGNAL_VCARD_MGR*sizeof(guint));
+
+ g->GET_WSD_VAR_NAME(quark1,gabble_vcard_mgr,s) = 0;
+ g->GET_WSD_VAR_NAME(quark2,gabble_vcard_mgr,s) = 0;
+
+ g->GET_WSD_VAR_NAME(offset_quark1,gabble_grp_mixin,s) = 0;
+ g->GET_WSD_VAR_NAME(offset_quark,gabble_grp_mixin,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_disco_parent_class,gabble_disco,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_disco,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_connection_manager_parent_class,gabble_conmgr,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_conmgr,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_connection_parent_class,gabble_con,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_con,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_im_channel_parent_class,gabble_im,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_im,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_search_channel_parent_class,gabble_search,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_search,s) = 0;
+
+
+ g->GET_WSD_VAR_NAME(gabble_muc_channel_parent_class,gabble_muc,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_muc,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_media_channel_parent_class,gabble_med_chnl,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_med_chnl,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_media_stream_parent_class,gabble_med_stream,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_med_stream,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_presence_parent_class,gabble_presence,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_presence,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_presence_cache_parent_class,gabble_pre_cache,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_pre_cache,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_register_parent_class,gabble_register,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_register,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_roster_channel_parent_class,gabble_ros_chnl,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_ros_chnl,s) = 0;
+
+
+ g->GET_WSD_VAR_NAME(gabble_roomlist_channel_parent_class,gabble_room_chnl,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_room_chnl,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_im_factory_parent_class ,im_factory,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,im_factory,s) = 0;
+
+
+ g->GET_WSD_VAR_NAME(gabble_media_factory_parent_class ,media_factory,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,media_factory,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_muc_factory_parent_class ,muc_factory,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,muc_factory,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_vcard_manager_parent_class ,gabble_vcard_mgr,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_vcard_mgr,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_media_session_parent_class ,gabble_med_sess,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_med_sess,s) = 0;
+
+ g->GET_WSD_VAR_NAME(gabble_roster_parent_class ,gabble_roster,s) = ((void *)0);
+ g->GET_WSD_VAR_NAME(g_define_type_id,gabble_roster,s) = 0;
+
+
+ memcpy (&(g->GET_WSD_VAR_NAME(keys,gabble_debug,s)), keys, 12*sizeof(GDebugKey));
+ strcpy((g->GET_WSD_VAR_NAME(NO_ALIAS,gabble_vcard_mgr,s)), NO_ALIAS);
+
+ memset(&(g->GET_WSD_VAR_NAME(assumed_caps,gabble_con,s)),0,3*150*sizeof(gchar));
+
+ strcpy((g->GET_WSD_VAR_NAME(assumed_caps,gabble_con,s))[0], assumed_caps[0]);
+ strcpy((g->GET_WSD_VAR_NAME(assumed_caps,gabble_con,s))[0], assumed_caps[1]);
+
+ strcpy((g->GET_WSD_VAR_NAME(muc_roles,gabble_muc,s))[0], muc_roles[0]);
+ strcpy((g->GET_WSD_VAR_NAME(muc_roles,gabble_muc,s))[1], muc_roles[1]);
+ strcpy((g->GET_WSD_VAR_NAME(muc_roles,gabble_muc,s))[2], muc_roles[2]);
+ strcpy((g->GET_WSD_VAR_NAME(muc_roles,gabble_muc,s))[3], muc_roles[3]);
+
+
+ strcpy((g->GET_WSD_VAR_NAME(muc_affiliations,gabble_muc,s))[0], muc_affiliations[0]);
+ strcpy((g->GET_WSD_VAR_NAME(muc_affiliations,gabble_muc,s))[1], muc_affiliations[1]);
+ strcpy((g->GET_WSD_VAR_NAME(muc_affiliations,gabble_muc,s))[2], muc_affiliations[2]);
+ strcpy((g->GET_WSD_VAR_NAME(muc_affiliations,gabble_muc,s))[3], muc_affiliations[3]);
+
+ strcpy((g->GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream,s))[0], video_codec_params[0]);
+ strcpy((g->GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream,s))[1], video_codec_params[1]);
+ strcpy((g->GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream,s))[2], video_codec_params[2]);
+ strcpy((g->GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream,s))[3], video_codec_params[3]);
+ strcpy((g->GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream,s))[4], video_codec_params[4]);
+ strcpy((g->GET_WSD_VAR_NAME(video_codec_params,gabble_med_stream,s))[5], video_codec_params[5]);
+
+ strcpy((g->GET_WSD_VAR_NAME(list_handle_strings,handles,s))[0], list_handle_strings[0]);
+ strcpy((g->GET_WSD_VAR_NAME(list_handle_strings,handles,s))[1], list_handle_strings[1]);
+ strcpy((g->GET_WSD_VAR_NAME(list_handle_strings,handles,s))[2], list_handle_strings[2]);
+ strcpy((g->GET_WSD_VAR_NAME(list_handle_strings,handles,s))[3], list_handle_strings[3]);
+
+ memcpy (&(g->GET_WSD_VAR_NAME(handlers,gabble_med_sess,s)), handlers, 10*sizeof(Handler));
+
+ return 0;
+ }
+ return 1;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/media-factory.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,666 @@
+/*
+ * media-factory.c - Source for GabbleMediaFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "loudmouth/loudmouth.h"
+
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "gabble-media-channel.h"
+#include "handles.h"
+#include "media-factory.h"
+#include "namespaces.h"
+#include "telepathy-interfaces.h"
+#include "text-mixin.h"
+#include "tp-channel-factory-iface.h"
+#include "util.h"
+
+static void gabble_media_factory_iface_init (gpointer g_iface, gpointer iface_data);
+static LmHandlerResult media_factory_jingle_cb (LmMessageHandler*, LmConnection*, LmMessage*, gpointer);
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleMediaFactory, gabble_media_factory, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE, gabble_media_factory_iface_init));
+
+#endif
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(gabble_media_factory_parent_class,media_factory,gpointer)
+ #define gabble_media_factory_parent_class (*GET_WSD_VAR_NAME(gabble_media_factory_parent_class,media_factory,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,media_factory,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,media_factory,s)())
+
+static void gabble_media_factory_init (GabbleMediaFactory *self);
+static void gabble_media_factory_class_init (GabbleMediaFactoryClass *klass);
+static void gabble_media_factory_class_intern_init (gpointer klass)
+{
+gabble_media_factory_parent_class = g_type_class_peek_parent (klass);
+ gabble_media_factory_class_init ((GabbleMediaFactoryClass*) klass);
+}
+ EXPORT_C GType gabble_media_factory_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleMediaFactoryClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_media_factory_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleMediaFactory), 0, (GInstanceInitFunc) gabble_media_factory_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleMediaFactory"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) gabble_media_factory_iface_init }; g_type_add_interface_static (g_define_type_id, tp_channel_factory_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+#endif
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+typedef struct _GabbleMediaFactoryPrivate GabbleMediaFactoryPrivate;
+struct _GabbleMediaFactoryPrivate
+{
+ GabbleConnection *conn;
+ LmMessageHandler *jingle_cb;
+
+ GPtrArray *channels;
+ guint channel_index;
+
+ GHashTable *session_chans;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_MEDIA_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GABBLE_TYPE_MEDIA_FACTORY, GabbleMediaFactoryPrivate))
+
+static GObject *gabble_media_factory_constructor (GType type, guint n_props, GObjectConstructParam *props);
+
+static void
+gabble_media_factory_init (GabbleMediaFactory *fac)
+{
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ priv->channels = g_ptr_array_sized_new (1);
+ priv->channel_index = 0;
+
+ priv->jingle_cb = NULL;
+
+ priv->conn = NULL;
+ priv->dispose_has_run = FALSE;
+
+ priv->session_chans = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+}
+
+static GObject *
+gabble_media_factory_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleMediaFactoryPrivate *priv;
+
+ obj = G_OBJECT_CLASS (gabble_media_factory_parent_class)->
+ constructor (type, n_props, props);
+ priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (obj);
+
+ return obj;
+}
+
+
+static void
+gabble_media_factory_dispose (GObject *object)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (object);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+ priv->dispose_has_run = TRUE;
+
+ tp_channel_factory_iface_close_all (TP_CHANNEL_FACTORY_IFACE (object));
+ g_assert (priv->channels == NULL);
+
+ if (priv->session_chans)
+ {
+ g_assert (g_hash_table_size (priv->session_chans) == 0);
+ g_hash_table_destroy (priv->session_chans);
+ priv->session_chans = NULL;
+ }
+
+ if (G_OBJECT_CLASS (gabble_media_factory_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_media_factory_parent_class)->dispose (object);
+}
+
+static void
+gabble_media_factory_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (object);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_media_factory_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (object);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_media_factory_class_init (GabbleMediaFactoryClass *gabble_media_factory_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_media_factory_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_media_factory_class, sizeof (GabbleMediaFactoryPrivate));
+
+ object_class->constructor = gabble_media_factory_constructor;
+ object_class->dispose = gabble_media_factory_dispose;
+
+ object_class->get_property = gabble_media_factory_get_property;
+ object_class->set_property = gabble_media_factory_set_property;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "media channel factory object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+}
+
+static gboolean _gabble_media_factory_sid_in_use (GabbleMediaFactory *fac, const gchar *sid);
+static GabbleMediaChannel *new_media_channel (GabbleMediaFactory *fac, GabbleHandle handle);
+static void media_channel_closed_cb (GabbleMediaChannel *chan, gpointer user_data);
+
+/**
+ * media_factory_jingle_cb
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler
+ * is concerned only with jingle session queries, and allows other
+ * handlers to be called for other queries.
+ */
+static LmHandlerResult
+media_factory_jingle_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (user_data);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ LmMessageNode *iq_node, *session_node;
+ const gchar *from, *id, *action, *sid;
+ gchar *resource;
+ GabbleHandle handle;
+ GabbleMediaChannel *chan = NULL;
+ gboolean chan_is_new = FALSE;
+ GError *error = NULL;
+
+ g_assert (lmconn == priv->conn->lmconn);
+
+ /* all jingle actions are sets */
+ if (LM_MESSAGE_SUB_TYPE_SET != lm_message_get_sub_type (message))
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ /* is it for us? */
+ iq_node = lm_message_get_node (message);
+ session_node = lm_message_node_get_child_with_namespace (message->node,
+ "jingle", NS_JINGLE);
+
+ if (session_node != NULL)
+ {
+ action = lm_message_node_get_attribute (session_node, "action");
+ }
+ else
+ {
+ session_node = lm_message_node_get_child_with_namespace (iq_node,
+ "session", NS_GOOGLE_SESSION);
+
+ if (session_node == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ action = lm_message_node_get_attribute (session_node, "type");
+ }
+
+ if (action == NULL)
+ {
+ NODE_DEBUG (iq_node, "session action not found");
+ goto BAD_REQUEST;
+ }
+
+ from = lm_message_node_get_attribute (iq_node, "from");
+ if (from == NULL)
+ {
+ NODE_DEBUG (iq_node, "'from' attribute not found");
+ goto BAD_REQUEST;
+ }
+
+ handle = gabble_handle_for_contact (priv->conn->handles, from, FALSE);
+ if (handle == 0)
+ {
+ NODE_DEBUG (iq_node, "unable to get handle for sender");
+ goto BAD_REQUEST;
+ }
+
+ id = lm_message_node_get_attribute (iq_node, "id");
+ if (id == NULL)
+ {
+ NODE_DEBUG (iq_node, "'id' attribute not found");
+ goto BAD_REQUEST;
+ }
+
+ /* does the session exist? */
+ sid = lm_message_node_get_attribute (session_node, "sid");
+ if (sid == NULL)
+ sid = lm_message_node_get_attribute (session_node, "id");
+
+ if (sid == NULL)
+ {
+ NODE_DEBUG (iq_node, "unable to get session id");
+ goto BAD_REQUEST;
+ }
+
+ if (_gabble_media_factory_sid_in_use (fac, sid))
+ {
+ /* if it's media session, we should have it in here */
+ chan = g_hash_table_lookup (priv->session_chans, sid);
+ }
+
+ /* it's a new session */
+ if (chan == NULL)
+ {
+ /* if the session is unknown, the only allowed action is "initiate" */
+ if (g_strdiff (action, "initiate") &&
+ g_strdiff (action, "session-initiate"))
+ {
+ NODE_DEBUG (iq_node,
+ "action is not \"initiate\" or \"session-initiate\", rejecting");
+ goto BAD_REQUEST;
+ }
+
+ gabble_debug (DEBUG_FLAG, "creating media channel");
+
+ chan = new_media_channel (fac, handle);
+ chan_is_new = TRUE;
+ }
+
+ g_assert (chan != NULL);
+
+ gabble_debug (DEBUG_FLAG, "dispatching to session %s", sid);
+ g_object_ref (chan);
+ gabble_decode_jid (from, NULL, NULL, &resource);
+
+ if (_gabble_media_channel_dispatch_session_action (chan, handle, resource,
+ sid, message, session_node, action, &error))
+ {
+ if (chan_is_new)
+ g_signal_emit_by_name (fac, "new-channel", chan);
+ }
+ else
+ {
+ if (chan_is_new)
+ gabble_media_channel_close (chan, NULL);
+
+ g_assert (error != NULL);
+ _gabble_connection_send_iq_error (priv->conn, message, error->code,
+ error->message);
+ }
+
+ g_object_unref (chan);
+ g_free (resource);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+
+BAD_REQUEST:
+ _gabble_connection_send_iq_error (
+ priv->conn, message, XMPP_ERROR_BAD_REQUEST, NULL);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static const gchar *
+_gabble_media_factory_get_unique_sid (GabbleMediaFactory *fac)
+{
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ guint32 val;
+ gchar *sid = NULL;
+ gboolean unique = FALSE;
+
+ while (!unique)
+ {
+ val = g_random_int_range (1000000, G_MAXINT);
+
+ g_free (sid);
+ sid = g_strdup_printf ("%u", val);
+
+ unique = !_gabble_media_factory_sid_in_use (fac, sid);
+ }
+
+ g_hash_table_insert (priv->session_chans, sid, NULL);
+
+ return sid;
+}
+
+static gboolean
+_gabble_media_factory_sid_in_use (GabbleMediaFactory *fac, const gchar *sid)
+{
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ gpointer key, value;
+
+ return g_hash_table_lookup_extended (priv->session_chans, sid, &key, &value);
+}
+
+const gchar *
+_gabble_media_factory_allocate_sid (GabbleMediaFactory *fac, GabbleMediaChannel *chan)
+{
+ const gchar *sid = _gabble_media_factory_get_unique_sid (fac);
+
+ g_return_val_if_fail (sid, NULL);
+
+ return _gabble_media_factory_register_sid (fac, sid, chan);
+}
+
+const gchar *
+_gabble_media_factory_register_sid (GabbleMediaFactory *fac,
+ const gchar *sid,
+ GabbleMediaChannel *chan)
+{
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ gchar *sid_copy = g_strdup (sid);
+
+ g_hash_table_replace (priv->session_chans, sid_copy, chan);
+
+ return sid_copy;
+}
+
+void
+_gabble_media_factory_free_sid (GabbleMediaFactory *fac, const gchar *sid)
+{
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ if (g_hash_table_lookup (priv->session_chans, sid))
+ {
+ g_hash_table_remove (priv->session_chans, sid);
+ }
+}
+
+static gboolean
+_remove_sid_mapping (gpointer key, gpointer value, gpointer user_data)
+{
+ GabbleMediaChannel *chan = GABBLE_MEDIA_CHANNEL (value);
+ GabbleMediaChannel *target_chan = GABBLE_MEDIA_CHANNEL (user_data);
+
+ if (chan == target_chan) return TRUE;
+ return FALSE;
+}
+
+/**
+ * media_channel_closed_cb:
+ *
+ * Signal callback for when a media channel is closed. Removes the references
+ * that #GabbleMediaFactory holds to them. Also removes all the sessions for
+ * the closed channel.
+ */
+static void
+media_channel_closed_cb (GabbleMediaChannel *chan, gpointer user_data)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (user_data);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->channels)
+ {
+ gabble_debug (DEBUG_FLAG, "removing media channel %p with ref count %d",
+ chan, G_OBJECT (chan)->ref_count);
+
+ g_ptr_array_remove (priv->channels, chan);
+ g_object_unref (chan);
+ }
+
+ if (priv->session_chans)
+ {
+ g_hash_table_foreach_remove (priv->session_chans, _remove_sid_mapping, chan);
+ }
+}
+
+/**
+ * new_media_channel
+ *
+ * Creates a new empty GabbleMediaChannel.
+ */
+static GabbleMediaChannel *
+new_media_channel (GabbleMediaFactory *fac, GabbleHandle creator)
+{
+ GabbleMediaFactoryPrivate *priv;
+ GabbleMediaChannel *chan;
+ gchar *object_path;
+
+ g_assert (GABBLE_IS_MEDIA_FACTORY (fac));
+
+ priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ object_path = g_strdup_printf ("%s/MediaChannel%u", priv->conn->object_path,
+ priv->channel_index);
+ priv->channel_index += 1;
+
+ chan = g_object_new (GABBLE_TYPE_MEDIA_CHANNEL,
+ "connection", priv->conn,
+ "factory", fac,
+ "object-path", object_path,
+ "creator", creator,
+ NULL);
+
+ gabble_debug (DEBUG_FLAG, "object path %s", object_path);
+
+ g_signal_connect (chan, "closed", (GCallback) media_channel_closed_cb, fac);
+
+ g_ptr_array_add (priv->channels, chan);
+
+ g_free (object_path);
+
+ return chan;
+}
+
+
+static void
+gabble_media_factory_iface_close_all (TpChannelFactoryIface *iface)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (iface);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ guint i;
+
+ gabble_debug (DEBUG_FLAG, "closing channels");
+
+ if (priv->channels)
+ {
+ GPtrArray *tmp = priv->channels;
+ priv->channels = NULL;
+
+
+ for (i = 0; i < tmp->len; i++)
+ {
+ GabbleMediaChannel *chan = g_ptr_array_index (tmp, i);
+
+ gabble_debug (DEBUG_FLAG, "about to unref channel with ref_count %d",
+ G_OBJECT (chan)->ref_count);
+
+ g_object_unref (chan);
+ }
+
+ g_ptr_array_free (tmp, TRUE);
+ }
+
+ if (priv->session_chans)
+ {
+ g_hash_table_destroy (priv->session_chans);
+ priv->session_chans = NULL;
+ }
+}
+
+static void
+gabble_media_factory_iface_connecting (TpChannelFactoryIface *iface)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (iface);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ g_assert(priv->conn != NULL);
+ g_assert(priv->conn->lmconn != NULL);
+
+ gabble_debug (DEBUG_FLAG, "adding callbacks");
+
+ priv->jingle_cb = lm_message_handler_new (media_factory_jingle_cb, fac, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn, priv->jingle_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL);
+}
+
+static void
+gabble_media_factory_iface_connected (TpChannelFactoryIface *iface)
+{
+ /* nothing to do */
+}
+
+static void
+gabble_media_factory_iface_disconnected (TpChannelFactoryIface *iface)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (iface);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+
+ g_assert (priv->jingle_cb != NULL);
+
+ gabble_debug (DEBUG_FLAG, "removing callbacks");
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn, priv->jingle_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (priv->jingle_cb);
+ priv->jingle_cb = NULL;
+}
+
+static void
+gabble_media_factory_iface_foreach (TpChannelFactoryIface *iface, TpChannelFunc foreach, gpointer user_data)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (iface);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ guint i;
+
+ for (i = 0; i < priv->channels->len; i++)
+ {
+ foreach (TP_CHANNEL_IFACE (g_ptr_array_index (priv->channels, i)), user_data);
+ }
+}
+
+static TpChannelFactoryRequestStatus
+gabble_media_factory_iface_request (TpChannelFactoryIface *iface,
+ const gchar *chan_type,
+ TpHandleType handle_type,
+ guint handle,
+ TpChannelIface **ret,
+ GError **error)
+{
+ GabbleMediaFactory *fac = GABBLE_MEDIA_FACTORY (iface);
+ GabbleMediaFactoryPrivate *priv = GABBLE_MEDIA_FACTORY_GET_PRIVATE (fac);
+ GabbleMediaChannel *chan = NULL;
+
+ if (strcmp (chan_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
+
+ if (handle_type == 0)
+ {
+ /* create an empty channel */
+ chan = new_media_channel (fac, priv->conn->self_handle);
+ }
+ else if (handle_type == TP_HANDLE_TYPE_CONTACT)
+ {
+ chan = new_media_channel (fac, priv->conn->self_handle);
+
+ if (!_gabble_media_channel_add_member (G_OBJECT (chan), handle, "", error))
+ {
+ gboolean close_ret;
+
+ close_ret = gabble_media_channel_close (chan, NULL);
+ g_assert (close_ret);
+
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_ERROR;
+ }
+ }
+ else
+ {
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE;
+ }
+
+ g_assert (chan != NULL);
+ g_signal_emit_by_name (fac, "new-channel", chan);
+
+ *ret = TP_CHANNEL_IFACE (chan);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE;
+}
+
+static void
+gabble_media_factory_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
+
+ klass->close_all = gabble_media_factory_iface_close_all;
+ klass->connected = gabble_media_factory_iface_connected;
+ klass->connecting = gabble_media_factory_iface_connecting;
+ klass->disconnected = gabble_media_factory_iface_disconnected;
+ klass->foreach = gabble_media_factory_iface_foreach;
+ klass->request = gabble_media_factory_iface_request;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/muc-factory.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,879 @@
+/*
+ * muc-factory.c - Source for GabbleMucFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "loudmouth/loudmouth.h"
+
+#include "debug.h"
+#include "disco.h"
+#include "gabble-connection.h"
+#include "gabble-presence-cache.h"
+#include "gabble-muc-channel.h"
+#include "gabble-roomlist-channel.h"
+#include "handles.h"
+#include "muc-factory.h"
+#include "namespaces.h"
+#include "telepathy-interfaces.h"
+#include "text-mixin.h"
+#include "tp-channel-factory-iface.h"
+#include "util.h"
+
+static void gabble_muc_factory_iface_init (gpointer g_iface, gpointer iface_data);
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleMucFactory, gabble_muc_factory, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE, gabble_muc_factory_iface_init));
+#endif
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(gabble_muc_factory_parent_class,muc_factory,gpointer)
+ #define gabble_muc_factory_parent_class (*GET_WSD_VAR_NAME(gabble_muc_factory_parent_class,muc_factory,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,muc_factory,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,muc_factory,s)())
+
+static void gabble_muc_factory_init (GabbleMucFactory *self);
+static void gabble_muc_factory_class_init (GabbleMucFactoryClass *klass);
+static void gabble_muc_factory_class_intern_init (gpointer klass)
+{
+ gabble_muc_factory_parent_class = g_type_class_peek_parent (klass);
+ gabble_muc_factory_class_init ((GabbleMucFactoryClass*) klass);
+ }
+ EXPORT_C GType gabble_muc_factory_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleMucFactoryClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_muc_factory_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleMucFactory), 0, (GInstanceInitFunc) gabble_muc_factory_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleMucFactory"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) gabble_muc_factory_iface_init }; g_type_add_interface_static (g_define_type_id, tp_channel_factory_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+
+#endif
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_MUC
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+typedef struct _GabbleMucFactoryPrivate GabbleMucFactoryPrivate;
+struct _GabbleMucFactoryPrivate
+{
+ GabbleConnection *conn;
+
+ LmMessageHandler *message_cb;
+ LmMessageHandler *presence_cb;
+
+ GHashTable *channels;
+ GabbleRoomlistChannel *roomlist_channel;
+
+ GHashTable *disco_requests;
+
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_MUC_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GABBLE_TYPE_MUC_FACTORY, GabbleMucFactoryPrivate))
+
+static GObject *gabble_muc_factory_constructor (GType type, guint n_props, GObjectConstructParam *props);
+
+static void
+gabble_muc_factory_init (GabbleMucFactory *fac)
+{
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ priv->channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, g_object_unref);
+
+ priv->disco_requests = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, NULL);
+
+ priv->message_cb = NULL;
+ priv->presence_cb = NULL;
+
+ priv->conn = NULL;
+ priv->dispose_has_run = FALSE;
+}
+
+static GObject *
+gabble_muc_factory_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ /* GabbleMucFactoryPrivate *priv; */
+
+ obj = G_OBJECT_CLASS (gabble_muc_factory_parent_class)->
+ constructor (type, n_props, props);
+ /* priv = GABBLE_MUC_FACTORY_GET_PRIVATE (obj); */
+
+ return obj;
+}
+
+static void
+cancel_disco_request (gpointer key, gpointer value, gpointer user_data)
+{
+ GabbleDisco *disco = GABBLE_DISCO (user_data);
+ GabbleDiscoRequest *request = (GabbleDiscoRequest *) key;
+
+ gabble_disco_cancel_request (disco, request);
+}
+
+static void
+gabble_muc_factory_dispose (GObject *object)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (object);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+ priv->dispose_has_run = TRUE;
+
+ tp_channel_factory_iface_close_all (TP_CHANNEL_FACTORY_IFACE (object));
+
+ g_hash_table_foreach (priv->disco_requests, cancel_disco_request, priv->conn->disco);
+ g_hash_table_destroy (priv->disco_requests);
+
+ if (G_OBJECT_CLASS (gabble_muc_factory_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_muc_factory_parent_class)->dispose (object);
+}
+
+static void
+gabble_muc_factory_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (object);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_muc_factory_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (object);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_muc_factory_class_init (GabbleMucFactoryClass *gabble_muc_factory_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_muc_factory_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_muc_factory_class, sizeof (GabbleMucFactoryPrivate));
+
+ object_class->constructor = gabble_muc_factory_constructor;
+ object_class->dispose = gabble_muc_factory_dispose;
+
+ object_class->get_property = gabble_muc_factory_get_property;
+ object_class->set_property = gabble_muc_factory_set_property;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "MUC factory object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+}
+
+
+static GabbleMucChannel *
+get_muc_from_jid (GabbleMucFactory *fac, const gchar *jid)
+{
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ GabbleHandle handle;
+ GabbleMucChannel *chan = NULL;
+
+ if (gabble_handle_for_room_exists (priv->conn->handles, jid, TRUE))
+ {
+ handle = gabble_handle_for_room (priv->conn->handles, jid);
+
+ chan = g_hash_table_lookup (priv->channels, GUINT_TO_POINTER (handle));
+ }
+
+ return chan;
+}
+
+
+/**
+ * muc_channel_closed_cb:
+ *
+ * Signal callback for when a MUC channel is closed. Removes the references
+ * that MucFactory holds to them.
+ */
+static void
+muc_channel_closed_cb (GabbleMucChannel *chan, gpointer user_data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (user_data);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ GabbleHandle room_handle;
+
+ if (priv->channels != NULL)
+ {
+ g_object_get (chan, "handle", &room_handle, NULL);
+
+ gabble_debug (DEBUG_FLAG, "removing MUC channel with handle %d", room_handle);
+
+ g_hash_table_remove (priv->channels, GINT_TO_POINTER (room_handle));
+ }
+}
+
+static void
+muc_ready_cb (GabbleMucChannel *chan,
+ gpointer data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (data);
+
+ gabble_debug (DEBUG_FLAG, "chan=%p", chan);
+
+ g_signal_emit_by_name (fac, "new-channel", chan);
+}
+
+static void
+muc_join_error_cb (GabbleMucChannel *chan,
+ GError *error,
+ gpointer data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (data);
+
+ gabble_debug (DEBUG_FLAG, "error->code=%u, error->message=\"%s\"", error->code, error->message);
+
+ g_signal_emit_by_name (fac, "channel-error", chan, error);
+}
+
+/**
+ * new_muc_channel
+ */
+static GabbleMucChannel *
+new_muc_channel (GabbleMucFactory *fac, GabbleHandle handle, gboolean invite_self)
+{
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ GabbleMucChannel *chan;
+ char *object_path;
+
+ g_assert (g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle)) == NULL);
+
+ object_path = g_strdup_printf ("%s/MucChannel%u", priv->conn->object_path, handle);
+
+ gabble_debug (DEBUG_FLAG, "creating new chan, object path %s", object_path);
+
+ chan = g_object_new (GABBLE_TYPE_MUC_CHANNEL,
+ "connection", priv->conn,
+ "object-path", object_path,
+ "handle", handle,
+ "invite-self", invite_self,
+ NULL);
+
+ g_signal_connect (chan, "closed", (GCallback) muc_channel_closed_cb, fac);
+
+ g_hash_table_insert (priv->channels, GINT_TO_POINTER (handle), chan);
+
+ g_free (object_path);
+
+ g_signal_connect (chan, "ready", G_CALLBACK (muc_ready_cb), fac);
+ g_signal_connect (chan, "join-error", G_CALLBACK (muc_join_error_cb),
+ fac);
+
+ return chan;
+}
+
+
+struct DiscoInviteData {
+ GabbleMucFactory *factory;
+ gchar *reason;
+ GabbleHandle inviter;
+};
+
+/**
+ * obsolete_invite_disco_cb:
+ *
+ * Callback for disco request we fired upon encountering obsolete disco.
+ * If the object is in fact MUC room, create a channel for it.
+ */
+static void
+obsolete_invite_disco_cb (GabbleDisco *self,
+ GabbleDiscoRequest *request,
+ const gchar *jid,
+ const gchar *node,
+ LmMessageNode *query_result,
+ GError* error,
+ gpointer user_data)
+{
+ struct DiscoInviteData *data = (struct DiscoInviteData *) user_data;
+
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (data->factory);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ LmMessageNode *identity;
+ const char *category, *type;
+ GabbleHandle handle;
+
+ g_hash_table_remove (priv->disco_requests, request);
+
+ identity = lm_message_node_get_child (query_result, "identity");
+ if (NULL == identity)
+ return;
+
+ category = lm_message_node_get_attribute (identity, "category");
+ if (NULL == category)
+ return;
+
+ type = lm_message_node_get_attribute (identity, "type");
+ if (NULL == type)
+ return;
+
+ if (0 != strcmp (category, "conference") ||
+ 0 != strcmp (type, "text"))
+ {
+ gabble_debug (DEBUG_FLAG, "obsolete invite request specified invalid jid '%s', ignoring", jid);
+ }
+
+ /* OK, it's MUC after all, create a new channel */
+ handle = gabble_handle_for_room (priv->conn->handles, jid);
+
+ if (g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle)) == NULL)
+ {
+ GabbleMucChannel *chan;
+ chan = new_muc_channel (fac, handle, FALSE);
+ _gabble_muc_channel_handle_invited (chan, data->inviter, data->reason);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "ignoring invite to a room '%s' we're already in", jid);
+ }
+
+ g_free (data->reason);
+ g_free (data);
+}
+
+
+/**
+ * muc_factory_message_cb:
+ *
+ * Called by loudmouth when we get an incoming <message>.
+ * We filter only groupchat and MUC messages, ignoring the rest.
+ */
+static LmHandlerResult
+muc_factory_message_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (user_data);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ const gchar *from, *body, *body_offset;
+ time_t stamp;
+ TpChannelTextMessageType msgtype;
+ LmMessageNode *node;
+ TpHandleType handle_type;
+ GabbleHandle room_handle, handle;
+ GabbleMucChannel *chan;
+ GabbleTextMixinSendError send_error;
+
+ if (!gabble_text_mixin_parse_incoming_message (message, &from, &stamp,
+ &msgtype, &body, &body_offset, &send_error))
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ /* does it have a muc subnode? */
+ node = lm_message_node_get_child_with_namespace (message->node, "x",
+ NS_MUC_USER);
+ if (node != NULL)
+ {
+ /* and an invitation? */
+ node = lm_message_node_get_child (node, "invite");
+ if (node != NULL)
+ {
+ LmMessageNode *reason_node;
+ const gchar *invite_from, *reason;
+ GabbleHandle inviter_handle;
+
+ if (send_error != CHANNEL_TEXT_SEND_NO_ERROR)
+ {
+ NODE_DEBUG (message->node, "got a MUC invitation message "
+ "with a send error; ignoring");
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ invite_from = lm_message_node_get_attribute (node, "from");
+ if (invite_from == NULL)
+ {
+ NODE_DEBUG (message->node, "got a MUC invitation message "
+ "without a from field on the invite node, "
+ "ignoring");
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ inviter_handle = gabble_handle_for_contact (priv->conn->handles,
+ invite_from, FALSE);
+
+ reason_node = lm_message_node_get_child (node, "reason");
+ if (reason_node != NULL)
+ {
+ reason = lm_message_node_get_value (reason_node);
+ }
+ else
+ {
+ reason = "";
+ NODE_DEBUG (message->node, "no MUC invite reason specified");
+ }
+
+ /* create the channel */
+ handle = gabble_handle_for_room (priv->conn->handles, from);
+
+ if (g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle)) == NULL)
+ {
+ chan = new_muc_channel (fac, handle, FALSE);
+ _gabble_muc_channel_handle_invited (chan, inviter_handle, reason);
+ }
+ else
+ {
+ NODE_DEBUG (message->node, "ignoring invite to a room we're already in");
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ }
+ else
+ {
+ GabbleHandle inviter_handle;
+ GabbleDiscoRequest *request;
+ const gchar *reason;
+ struct DiscoInviteData *disco_udata;
+
+ /* check for obsolete invite method */
+ for (node = message->node->children; node != NULL; node = node->next)
+ if (strcmp (node->name, "x") == 0)
+ if (lm_message_node_has_namespace (node, NS_X_CONFERENCE, NULL))
+ break;
+
+ if (node == NULL)
+ goto HANDLE_MESSAGE;
+
+ /* the room JID is in x */
+ from = lm_message_node_get_attribute (node, "jid");
+ if (from == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ /* the inviter JID is in "from" */
+ inviter_handle = gabble_handle_for_contact (priv->conn->handles,
+ from, FALSE);
+
+ /* reason is the body */
+ reason = body;
+
+ disco_udata = g_new0 (struct DiscoInviteData, 1);
+ disco_udata->factory = fac;
+ disco_udata->reason = g_strdup (reason);
+ disco_udata->inviter = inviter_handle;
+
+ NODE_DEBUG (message->node, "received obsolete invite method");
+
+ request = gabble_disco_request (priv->conn->disco, GABBLE_DISCO_TYPE_INFO,
+ from, NULL, obsolete_invite_disco_cb, disco_udata, G_OBJECT (fac), NULL);
+
+ if (request != NULL)
+ g_hash_table_insert (priv->disco_requests, request, NULL);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+HANDLE_MESSAGE:
+
+ /* check if a room with the jid exists */
+ if (!gabble_handle_for_room_exists (priv->conn->handles, from, TRUE))
+ {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ room_handle = gabble_handle_for_room (priv->conn->handles, from);
+
+ /* find the MUC channel */
+ chan = g_hash_table_lookup (priv->channels, GUINT_TO_POINTER (room_handle));
+
+ if (chan == NULL)
+ {
+ g_warning ("%s: ignoring groupchat message from known handle with "
+ "no MUC channel", G_STRFUNC);
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ /* get the handle of the sender, which is either the room
+ * itself or one of its members */
+ if (gabble_handle_for_room_exists (priv->conn->handles, from, FALSE))
+ {
+ handle_type = TP_HANDLE_TYPE_ROOM;
+ handle = room_handle;
+ }
+ else
+ {
+ handle_type = TP_HANDLE_TYPE_CONTACT;
+ handle = gabble_handle_for_contact (priv->conn->handles, from, TRUE);
+ }
+
+ if (send_error != CHANNEL_TEXT_SEND_NO_ERROR)
+ {
+ _gabble_text_mixin_send_error_signal (G_OBJECT (chan), send_error, stamp,
+ msgtype, body_offset);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ if (_gabble_muc_channel_receive (chan, msgtype, handle_type, handle, stamp,
+ body_offset, message))
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+
+/**
+ * connection_presence_muc_cb:
+ * @handler: #LmMessageHandler for this message
+ * @connection: #LmConnection that originated the message
+ * @message: the presence message
+ * @user_data: callback data
+ *
+ * Called by loudmouth when we get an incoming <presence>.
+ */
+static LmHandlerResult
+muc_factory_presence_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *msg,
+ gpointer user_data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (user_data);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ const char *from;
+ LmMessageSubType sub_type;
+ GabbleMucChannel *muc_chan;
+ LmMessageNode *x_node;
+
+ g_assert (lmconn == priv->conn->lmconn);
+
+ from = lm_message_node_get_attribute (msg->node, "from");
+
+ if (from == NULL)
+ {
+ NODE_DEBUG (msg->node, "presence stanza without from attribute, ignoring");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ sub_type = lm_message_get_sub_type (msg);
+
+ muc_chan = get_muc_from_jid (fac, from);
+
+ /* is it an error and for a MUC? */
+ if (sub_type == LM_MESSAGE_SUB_TYPE_ERROR
+ && muc_chan != NULL)
+ {
+ _gabble_muc_channel_presence_error (muc_chan, from, msg->node);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ x_node = lm_message_node_get_child_with_namespace (msg->node, "x", NS_MUC_USER);
+
+ /* is it a MUC member presence? */
+ if (x_node != NULL)
+ {
+ if (muc_chan != NULL)
+ {
+ GabbleHandle handle;
+
+ handle = gabble_handle_for_contact (priv->conn->handles, from, TRUE);
+ if (handle == 0)
+ {
+ NODE_DEBUG (msg->node, "discarding MUC presence from malformed jid");
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+
+ _gabble_muc_channel_member_presence_updated (muc_chan, handle,
+ msg, x_node);
+ }
+ else
+ {
+ NODE_DEBUG (msg->node, "discarding unexpected MUC member presence");
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ }
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+}
+
+static void
+roomlist_channel_closed_cb (GabbleRoomlistChannel *chan, gpointer data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (data);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->roomlist_channel != NULL)
+ {
+ g_object_unref (priv->roomlist_channel);
+ priv->roomlist_channel = NULL;
+ }
+}
+
+static gboolean
+make_roomlist_channel (GabbleMucFactory *fac)
+{
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->roomlist_channel == NULL)
+ {
+ const gchar *server;
+ gchar *object_path;
+
+ server = _gabble_connection_find_conference_server (priv->conn);
+
+ if (server == NULL)
+ return FALSE;
+
+ object_path = g_strdup_printf ("%s/RoomlistChannel", priv->conn->object_path);
+
+ priv->roomlist_channel = _gabble_roomlist_channel_new (priv->conn,
+ object_path, server);
+
+ g_signal_connect (priv->roomlist_channel, "closed",
+ (GCallback) roomlist_channel_closed_cb, fac);
+
+ g_signal_emit_by_name (fac, "new-channel", priv->roomlist_channel);
+
+ g_free (object_path);
+ }
+
+ return TRUE;
+}
+
+
+
+static void
+gabble_muc_factory_iface_close_all (TpChannelFactoryIface *iface)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (iface);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "closing channels");
+
+ if (priv->channels != NULL)
+ {
+ GHashTable *tmp = priv->channels;
+ priv->channels = NULL;
+ g_hash_table_destroy (tmp);
+ }
+
+ if (priv->roomlist_channel != NULL)
+ {
+ GObject *tmp = G_OBJECT (priv->roomlist_channel);
+ priv->roomlist_channel = NULL;
+ g_object_unref (tmp);
+ }
+}
+
+static void
+gabble_muc_factory_iface_connecting (TpChannelFactoryIface *iface)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (iface);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "adding callbacks");
+
+ g_assert (priv->message_cb == NULL);
+ g_assert (priv->presence_cb == NULL);
+
+ priv->message_cb = lm_message_handler_new (muc_factory_message_cb, fac, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn, priv->message_cb,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_NORMAL);
+
+ priv->presence_cb = lm_message_handler_new (muc_factory_presence_cb, fac, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn, priv->presence_cb,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_HANDLER_PRIORITY_NORMAL);
+}
+
+
+static void
+gabble_muc_factory_iface_connected (TpChannelFactoryIface *iface)
+{
+ /* nothing to do */
+}
+
+static void
+gabble_muc_factory_iface_disconnected (TpChannelFactoryIface *iface)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (iface);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "removing callbacks");
+
+ g_assert (priv->message_cb != NULL);
+ g_assert (priv->presence_cb != NULL);
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn, priv->message_cb,
+ LM_MESSAGE_TYPE_MESSAGE);
+ lm_message_handler_unref (priv->message_cb);
+ priv->message_cb = NULL;
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn, priv->presence_cb,
+ LM_MESSAGE_TYPE_PRESENCE);
+ lm_message_handler_unref (priv->presence_cb);
+ priv->presence_cb = NULL;
+}
+
+struct _ForeachData
+{
+ TpChannelFunc foreach;
+ gpointer user_data;
+};
+
+static void
+_foreach_slave (gpointer key, gpointer value, gpointer user_data)
+{
+ struct _ForeachData *data = (struct _ForeachData *) user_data;
+ TpChannelIface *chan = TP_CHANNEL_IFACE (value);
+
+ data->foreach (chan, data->user_data);
+}
+
+static void
+gabble_muc_factory_iface_foreach (TpChannelFactoryIface *iface, TpChannelFunc foreach, gpointer user_data)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (iface);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ struct _ForeachData data;
+
+ data.user_data = user_data;
+ data.foreach = foreach;
+
+ g_hash_table_foreach (priv->channels, _foreach_slave, &data);
+
+ if (priv->roomlist_channel != NULL)
+ foreach (TP_CHANNEL_IFACE (priv->roomlist_channel), user_data);
+}
+
+static TpChannelFactoryRequestStatus
+gabble_muc_factory_iface_request (TpChannelFactoryIface *iface,
+ const gchar *chan_type,
+ TpHandleType handle_type,
+ guint handle,
+ TpChannelIface **ret,
+ GError **error)
+{
+ GabbleMucFactory *fac = GABBLE_MUC_FACTORY (iface);
+ GabbleMucFactoryPrivate *priv = GABBLE_MUC_FACTORY_GET_PRIVATE (fac);
+ GabbleMucChannel *chan;
+
+ if (!g_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_ROOM_LIST))
+ {
+ /* FIXME - delay if services aren't discovered yet? */
+ if (!make_roomlist_channel (fac))
+ {
+ gabble_debug (DEBUG_FLAG, "no conference server available for roomlist request");
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+ }
+ *ret = TP_CHANNEL_IFACE (priv->roomlist_channel);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE;
+ }
+
+ if (strcmp (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
+
+ if (handle_type != TP_HANDLE_TYPE_ROOM)
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+
+ if (!gabble_handle_is_valid (priv->conn->handles, TP_HANDLE_TYPE_ROOM, handle, NULL))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE;
+
+ chan = g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle));
+ if (!chan)
+ {
+ chan = new_muc_channel (fac, handle, TRUE);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED;
+ }
+
+ if (_gabble_muc_channel_is_ready (chan))
+ {
+ *ret = TP_CHANNEL_IFACE (chan);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE;
+ }
+ else
+ {
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED;
+ }
+}
+
+static void
+gabble_muc_factory_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
+
+ klass->close_all = gabble_muc_factory_iface_close_all;
+ klass->connecting = gabble_muc_factory_iface_connecting;
+ klass->connected = gabble_muc_factory_iface_connected;
+ klass->disconnected = gabble_muc_factory_iface_disconnected;
+ klass->foreach = gabble_muc_factory_iface_foreach;
+ klass->request = gabble_muc_factory_iface_request;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/properties-mixin-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,67 @@
+/*
+ * properties-mixin-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/properties-mixin.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,830 @@
+/*
+ * properties-mixin.c - Source for GabblePropertiesMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_PROPERTIES
+
+#include "ansi.h"
+#include "debug.h"
+#include "properties-mixin.h"
+#include "properties-mixin-signals-marshal.h"
+#include "telepathy-errors.h"
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark1,gabble_mixin,GQuark)
+ #define offset_quark1 (*GET_WSD_VAR_NAME(offset_quark1,gabble_mixin, s)())
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark,gabble_mixin,GQuark)
+ #define offset_quark (*GET_WSD_VAR_NAME(offset_quark,gabble_mixin, s)())
+
+
+#endif
+
+struct _GabblePropertiesContext {
+ GabblePropertiesMixinClass *mixin_cls;
+ GabblePropertiesMixin *mixin;
+
+ DBusGMethodInvocation *dbus_ctx;
+ guint32 remaining;
+ GValue **values;
+};
+
+struct _GabblePropertiesMixinPrivate {
+ GObject *object;
+ GabblePropertiesContext context;
+};
+
+/**
+ * gabble_properties_mixin_class_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObjectClass
+ */
+GQuark
+gabble_properties_mixin_class_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark1= 0;
+#endif
+ if (!offset_quark1)
+ offset_quark1 = g_quark_from_static_string("PropertiesMixinClassOffsetQuark");
+ return offset_quark1;
+}
+
+/**
+ * gabble_properties_mixin_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObject
+ */
+GQuark
+gabble_properties_mixin_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark = 0;
+#endif
+ if (!offset_quark)
+ offset_quark = g_quark_from_static_string("PropertiesMixinOffsetQuark");
+ return offset_quark;
+}
+
+void gabble_properties_mixin_class_init (GObjectClass *obj_cls,
+ glong offset,
+ const GabblePropertySignature *signatures,
+ guint num_properties,
+ GabblePropertiesSetFunc set_func)
+{
+ GabblePropertiesMixinClass *mixin_cls;
+
+ g_assert (G_IS_OBJECT_CLASS (obj_cls));
+
+ g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls),
+ GABBLE_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (obj_cls);
+
+ mixin_cls->signatures = signatures;
+ mixin_cls->num_props = num_properties;
+
+ mixin_cls->set_properties = set_func;
+
+ mixin_cls->properties_changed_signal_id =
+ g_signal_new ("properties-changed",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID)))));
+
+ mixin_cls->property_flags_changed_signal_id =
+ g_signal_new ("property-flags-changed",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)))));
+}
+
+void gabble_properties_mixin_init (GObject *obj, glong offset)
+{
+ GabblePropertiesMixinClass *mixin_cls;
+ GabblePropertiesMixin *mixin;
+ GabblePropertiesContext *ctx;
+
+ g_assert (G_IS_OBJECT (obj));
+
+ g_type_set_qdata (G_OBJECT_TYPE (obj),
+ GABBLE_PROPERTIES_MIXIN_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+
+ mixin->properties = g_new0 (GabbleProperty, mixin_cls->num_props);
+
+ mixin->priv = g_new0 (GabblePropertiesMixinPrivate, 1);
+ mixin->priv->object = obj;
+
+ ctx = &mixin->priv->context;
+ ctx->mixin_cls = mixin_cls;
+ ctx->mixin = mixin;
+ ctx->values = g_new0 (GValue *, mixin_cls->num_props);
+}
+
+void gabble_properties_mixin_finalize (GObject *obj)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ GabblePropertiesContext *ctx = &mixin->priv->context;
+ guint i;
+
+ for (i = 0; i < mixin_cls->num_props; i++)
+ {
+ GabbleProperty *prop = &mixin->properties[i];
+
+ if (prop->value)
+ {
+ g_value_unset (prop->value);
+ g_free (prop->value);
+ }
+
+ if (ctx->values[i])
+ {
+ g_value_unset (ctx->values[i]);
+ }
+ }
+
+ g_free (ctx->values);
+
+ g_free (mixin->priv);
+
+ g_free (mixin->properties);
+}
+
+gboolean
+gabble_properties_mixin_list_properties (GObject *obj, GPtrArray **ret, GError **error)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ guint i;
+
+ *ret = g_ptr_array_sized_new (mixin_cls->num_props);
+
+ for (i = 0; i < mixin_cls->num_props; i++)
+ {
+ const GabblePropertySignature *sig = &mixin_cls->signatures[i];
+ GabbleProperty *prop = &mixin->properties[i];
+ const gchar *dbus_sig;
+ GValue val = { 0, };
+
+ switch (sig->type) {
+ case G_TYPE_BOOLEAN:
+ dbus_sig = "b";
+ break;
+ case G_TYPE_INT:
+ dbus_sig = "i";
+ break;
+ case G_TYPE_UINT:
+ dbus_sig = "u";
+ break;
+ case G_TYPE_STRING:
+ dbus_sig = "s";
+ break;
+ default:
+ g_assert_not_reached ();
+ continue;
+ };
+
+ g_value_init (&val, TP_TYPE_PROPERTY_INFO_STRUCT);
+ g_value_take_boxed (&val,
+ dbus_g_type_specialized_construct (TP_TYPE_PROPERTY_INFO_STRUCT));
+
+ dbus_g_type_struct_set (&val,
+ 0, i,
+ 1, sig->name,
+ 2, dbus_sig,
+ 3, prop->flags,
+ G_MAXUINT);
+
+ g_ptr_array_add (*ret, g_value_get_boxed (&val));
+ }
+
+ return TRUE;
+}
+
+gboolean
+gabble_properties_mixin_get_properties (GObject *obj, const GArray *properties, GPtrArray **ret, GError **error)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ guint i;
+
+ /* Check input property identifiers */
+ for (i = 0; i < properties->len; i++)
+ {
+ guint prop_id = g_array_index (properties, guint, i);
+
+ /* Valid? */
+ if (prop_id >= mixin_cls->num_props)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid property identifier %d", prop_id);
+
+ return FALSE;
+ }
+
+ /* Permitted? */
+ if (!gabble_properties_mixin_is_readable (obj, prop_id))
+ {
+ g_set_error (error, TELEPATHY_ERRORS, PermissionDenied,
+ "permission denied for property identifier %d", prop_id);
+
+ return FALSE;
+ }
+ }
+
+ /* If we got this far, return the actual values */
+ *ret = g_ptr_array_sized_new (properties->len);
+
+ for (i = 0; i < properties->len; i++)
+ {
+ guint prop_id = g_array_index (properties, guint, i);
+ GValue val_struct = { 0, };
+
+ /* id/value struct */
+ g_value_init (&val_struct, TP_TYPE_PROPERTY_VALUE_STRUCT);
+ g_value_take_boxed (&val_struct,
+ dbus_g_type_specialized_construct (TP_TYPE_PROPERTY_VALUE_STRUCT));
+
+ dbus_g_type_struct_set (&val_struct,
+ 0, prop_id,
+ 1, mixin->properties[prop_id].value,
+ G_MAXUINT);
+
+ g_ptr_array_add (*ret, g_value_get_boxed (&val_struct));
+ }
+
+ return TRUE;
+}
+
+void
+gabble_properties_mixin_set_properties (GObject *obj,
+ const GPtrArray *properties,
+ DBusGMethodInvocation *context)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ GabblePropertiesContext *ctx = &mixin->priv->context;
+ GError *error = NULL;
+ guint i;
+
+ /* Is another SetProperties request already in progress? */
+ if (ctx->dbus_ctx)
+ {
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "A SetProperties request is already in progress");
+ goto ERROR;
+ }
+
+ ctx->dbus_ctx = context;
+ error = NULL;
+
+ /* Check input property identifiers */
+ for (i = 0; i < properties->len; i++)
+ {
+ GValue val_struct = { 0, };
+ guint prop_id;
+ GValue *prop_val;
+
+ g_value_init (&val_struct, TP_TYPE_PROPERTY_VALUE_STRUCT);
+ g_value_set_static_boxed (&val_struct, g_ptr_array_index (properties, i));
+
+ dbus_g_type_struct_get (&val_struct,
+ 0, &prop_id,
+ 1, &prop_val,
+ G_MAXUINT);
+
+ /* Valid? */
+ if (prop_id >= mixin_cls->num_props)
+ {
+ g_value_unset (prop_val);
+
+ error = g_error_new (TELEPATHY_ERRORS, InvalidArgument,
+ "invalid property identifier %d", prop_id);
+ goto ERROR;
+ }
+
+ /* Store the value in the context */
+ ctx->remaining |= 1 << prop_id;
+ ctx->values[prop_id] = prop_val;
+
+ /* Permitted? */
+ if (!gabble_properties_mixin_is_writable (obj, prop_id))
+ {
+ error = g_error_new (TELEPATHY_ERRORS, PermissionDenied,
+ "permission denied for property identifier %d", prop_id);
+ goto ERROR;
+ }
+
+ /* Compatible type? */
+ if (!g_value_type_compatible (G_VALUE_TYPE (prop_val),
+ mixin_cls->signatures[prop_id].type))
+ {
+ error = g_error_new (TELEPATHY_ERRORS, NotAvailable,
+ "incompatible value type for property identifier %d",
+ prop_id);
+ goto ERROR;
+ }
+ }
+
+ if (mixin_cls->set_properties)
+ {
+ if (mixin_cls->set_properties (obj, ctx, &error))
+ return;
+ }
+ else
+ {
+ gabble_properties_context_return (ctx, NULL);
+ return;
+ }
+
+ERROR:
+ gabble_properties_context_return (ctx, error);
+}
+
+gboolean
+gabble_properties_mixin_has_property (GObject *obj, const gchar *name,
+ guint *property)
+{
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ guint i;
+
+ for (i = 0; i < mixin_cls->num_props; i++)
+ {
+ if (strcmp (mixin_cls->signatures[i].name, name) == 0)
+ {
+ if (property)
+ *property = i;
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+gboolean
+gabble_properties_context_has (GabblePropertiesContext *ctx, guint property)
+{
+ g_assert (property < ctx->mixin_cls->num_props);
+
+ return (ctx->values[property] != NULL);
+}
+
+gboolean
+gabble_properties_context_has_other_than (GabblePropertiesContext *ctx, guint property)
+{
+ g_assert (property < ctx->mixin_cls->num_props);
+
+ return ((ctx->remaining & ~(1 << property)) != 0);
+}
+
+const GValue *
+gabble_properties_context_get (GabblePropertiesContext *ctx, guint property)
+{
+ g_assert (property < ctx->mixin_cls->num_props);
+
+ return ctx->values[property];
+}
+
+guint
+gabble_properties_context_get_value_count (GabblePropertiesContext *ctx)
+{
+ guint i, n;
+
+ n = 0;
+ for (i = 0; i < ctx->mixin_cls->num_props; i++)
+ {
+ if (ctx->values[i])
+ n++;
+ }
+
+ return n;
+}
+
+void
+gabble_properties_context_remove (GabblePropertiesContext *ctx, guint property)
+{
+ g_assert (property < ctx->mixin_cls->num_props);
+
+ ctx->remaining &= ~(1 << property);
+}
+
+void
+gabble_properties_context_return (GabblePropertiesContext *ctx, GError *error)
+{
+ GObject *obj = ctx->mixin->priv->object;
+ GArray *changed_props_val, *changed_props_flags;
+ guint i;
+
+ gabble_debug (DEBUG_FLAG, "%s", (error) ? "failure" : "success");
+
+ changed_props_val = changed_props_flags = NULL;
+
+ for (i = 0; i < ctx->mixin_cls->num_props; i++)
+ {
+ if (ctx->values[i])
+ {
+ if (!error)
+ {
+ gabble_properties_mixin_change_value (obj, i, ctx->values[i],
+ &changed_props_val);
+
+ gabble_properties_mixin_change_flags (obj, i,
+ TP_PROPERTY_FLAG_READ, 0, &changed_props_flags);
+ }
+
+ g_value_unset (ctx->values[i]);
+ ctx->values[i] = NULL;
+ }
+ }
+
+ if (!error)
+ {
+ gabble_properties_mixin_emit_changed (obj, &changed_props_val);
+ gabble_properties_mixin_emit_flags (obj, &changed_props_flags);
+
+ dbus_g_method_return (ctx->dbus_ctx);
+ }
+ else
+ {
+ dbus_g_method_return_error (ctx->dbus_ctx, error);
+ g_error_free (error);
+ }
+
+ ctx->dbus_ctx = NULL;
+ ctx->remaining = 0;
+}
+
+gboolean
+gabble_properties_context_return_if_done (GabblePropertiesContext *ctx)
+{
+ if (ctx->remaining == 0)
+ {
+ gabble_properties_context_return (ctx, NULL);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#define RPTS_APPEND_FLAG_IF_SET(flag) \
+ if (flags & flag) \
+ { \
+ if (i++ > 0) \
+ g_string_append (str, "|"); \
+ g_string_append (str, #flag + 17); \
+ }
+
+static gchar *
+property_flags_to_string (TpPropertyFlags flags)
+{
+ gint i = 0;
+ GString *str;
+
+ str = g_string_new ("[" ANSI_BOLD_OFF);
+
+ RPTS_APPEND_FLAG_IF_SET (TP_PROPERTY_FLAG_READ);
+ RPTS_APPEND_FLAG_IF_SET (TP_PROPERTY_FLAG_WRITE);
+
+ g_string_append (str, ANSI_BOLD_ON "]");
+
+ return g_string_free (str, FALSE);
+}
+
+static gboolean
+values_are_equal (const GValue *v1, const GValue *v2)
+{
+ GType type = G_VALUE_TYPE (v1);
+ const gchar *s1, *s2;
+
+ switch (type) {
+ case G_TYPE_BOOLEAN:
+ return (g_value_get_boolean (v1) == g_value_get_boolean (v2));
+
+ case G_TYPE_STRING:
+ s1 = g_value_get_string (v1);
+ s2 = g_value_get_string (v2);
+
+ /* are they both NULL? */
+ if (s1 == s2)
+ return TRUE;
+
+ /* is one of them NULL? */
+ if (s1 == NULL || s2 == NULL)
+ return FALSE;
+
+ return (strcmp (s1, s2) == 0);
+
+ case G_TYPE_UINT:
+ return (g_value_get_uint (v1) == g_value_get_uint (v2));
+
+ case G_TYPE_INT:
+ return (g_value_get_int (v1) == g_value_get_int (v2));
+ }
+
+ return FALSE;
+}
+
+void
+gabble_properties_mixin_change_value (GObject *obj, guint prop_id,
+ const GValue *new_value,
+ GArray **props)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ GabbleProperty *prop;
+
+ g_assert (prop_id < mixin_cls->num_props);
+
+ prop = &mixin->properties[prop_id];
+
+ if (prop->value)
+ {
+ if (values_are_equal (prop->value, new_value))
+ return;
+ }
+ else
+ {
+ prop->value = g_new0 (GValue, 1);
+ g_value_init (prop->value, mixin_cls->signatures[prop_id].type);
+ }
+
+ g_value_copy (new_value, prop->value);
+
+ if (props)
+ {
+ guint i;
+
+ if (*props == NULL)
+ {
+ *props = g_array_sized_new (FALSE, FALSE, sizeof (guint),
+ mixin_cls->num_props);
+ }
+
+ for (i = 0; i < (*props)->len; i++)
+ {
+ if (g_array_index (*props, guint, i) == prop_id)
+ return;
+ }
+
+ g_array_append_val (*props, prop_id);
+ }
+ else
+ {
+ GArray *changed_props = g_array_sized_new (FALSE, FALSE,
+ sizeof (guint), 1);
+ g_array_append_val (changed_props, prop_id);
+
+ gabble_properties_mixin_emit_changed (obj, &changed_props);
+ }
+}
+
+void
+gabble_properties_mixin_change_flags (GObject *obj, guint prop_id,
+ TpPropertyFlags add,
+ TpPropertyFlags remove,
+ GArray **props)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ GabbleProperty *prop;
+ guint prev_flags;
+
+ g_assert (prop_id < mixin_cls->num_props);
+
+ prop = &mixin->properties[prop_id];
+
+ prev_flags = prop->flags;
+
+ prop->flags |= add;
+ prop->flags &= ~remove;
+
+ if (prop->flags == prev_flags)
+ return;
+
+ if (props)
+ {
+ guint i;
+
+ if (*props == NULL)
+ {
+ *props = g_array_sized_new (FALSE, FALSE, sizeof (guint),
+ mixin_cls->num_props);
+ }
+
+ for (i = 0; i < (*props)->len; i++)
+ {
+ if (g_array_index (*props, guint, i) == prop_id)
+ return;
+ }
+
+ g_array_append_val (*props, prop_id);
+ }
+ else
+ {
+ GArray *changed_props = g_array_sized_new (FALSE, FALSE,
+ sizeof (guint), 1);
+ g_array_append_val (changed_props, prop_id);
+
+ gabble_properties_mixin_emit_flags (obj, &changed_props);
+ }
+}
+
+void
+gabble_properties_mixin_emit_changed (GObject *obj, GArray **props)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ GPtrArray *prop_arr;
+ GValue prop_list = { 0, };
+ guint i;
+
+ if (*props == NULL)
+ return;
+
+ if ((*props)->len == 0)
+ return;
+
+ prop_arr = g_ptr_array_sized_new ((*props)->len);
+
+ if (DEBUGGING)
+ g_message (ANSI_BOLD_ON ANSI_FG_CYAN
+ "%s: emitting properties changed for propert%s:\n",
+ G_STRFUNC, ((*props)->len > 1) ? "ies" : "y");
+
+ for (i = 0; i < (*props)->len; i++)
+ {
+ GValue prop_val = { 0, };
+ guint prop_id = g_array_index (*props, guint, i);
+
+ g_value_init (&prop_val, TP_TYPE_PROPERTY_VALUE_STRUCT);
+ g_value_take_boxed (&prop_val,
+ dbus_g_type_specialized_construct (TP_TYPE_PROPERTY_VALUE_STRUCT));
+
+ dbus_g_type_struct_set (&prop_val,
+ 0, prop_id,
+ 1, mixin->properties[prop_id].value,
+ G_MAXUINT);
+
+ g_ptr_array_add (prop_arr, g_value_get_boxed (&prop_val));
+
+ if (DEBUGGING)
+ g_message (" %s\n", mixin_cls->signatures[prop_id].name);
+ }
+
+ if (DEBUGGING)
+ {
+ g_message (ANSI_RESET);
+ fflush (stdout);
+ }
+
+ g_signal_emit (obj, mixin_cls->properties_changed_signal_id, 0, prop_arr);
+
+ g_value_init (&prop_list, TP_TYPE_PROPERTY_VALUE_LIST);
+ g_value_take_boxed (&prop_list, prop_arr);
+ g_value_unset (&prop_list);
+
+ g_array_free (*props, TRUE);
+ *props = NULL;
+}
+
+void
+gabble_properties_mixin_emit_flags (GObject *obj, GArray **props)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+ GPtrArray *prop_arr;
+ GValue prop_list = { 0, };
+ guint i;
+
+ if (*props == NULL)
+ return;
+
+ if ((*props)->len == 0)
+ return;
+
+ prop_arr = g_ptr_array_sized_new ((*props)->len);
+
+ if (DEBUGGING)
+ g_message (ANSI_BOLD_ON ANSI_FG_WHITE
+ "%s: emitting properties flags changed for propert%s:\n",
+ G_STRFUNC, ((*props)->len > 1) ? "ies" : "y");
+
+ for (i = 0; i < (*props)->len; i++)
+ {
+ GValue prop_val = { 0, };
+ guint prop_id = g_array_index (*props, guint, i);
+ guint prop_flags;
+
+ prop_flags = mixin->properties[prop_id].flags;
+
+ g_value_init (&prop_val, TP_TYPE_PROPERTY_FLAGS_STRUCT);
+ g_value_take_boxed (&prop_val,
+ dbus_g_type_specialized_construct (TP_TYPE_PROPERTY_FLAGS_STRUCT));
+
+ dbus_g_type_struct_set (&prop_val,
+ 0, prop_id,
+ 1, prop_flags,
+ G_MAXUINT);
+
+ g_ptr_array_add (prop_arr, g_value_get_boxed (&prop_val));
+
+ if (DEBUGGING)
+ {
+ gchar *str_flags = property_flags_to_string (prop_flags);
+
+ g_message (" %s's flags now: %s\n",
+ mixin_cls->signatures[prop_id].name, str_flags);
+
+ g_free (str_flags);
+ }
+ }
+
+ if (DEBUGGING)
+ {
+ g_message (ANSI_RESET);
+ fflush (stdout);
+ }
+
+ g_signal_emit (obj, mixin_cls->property_flags_changed_signal_id, 0, prop_arr);
+
+ g_value_init (&prop_list, TP_TYPE_PROPERTY_FLAGS_LIST);
+ g_value_take_boxed (&prop_list, prop_arr);
+ g_value_unset (&prop_list);
+
+ g_array_free (*props, TRUE);
+ *props = NULL;
+}
+
+gboolean
+gabble_properties_mixin_is_readable (GObject *obj, guint prop_id)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+
+ if (prop_id >= mixin_cls->num_props)
+ return FALSE;
+
+ return ((mixin->properties[prop_id].flags & TP_PROPERTY_FLAG_READ) != 0);
+}
+
+gboolean
+gabble_properties_mixin_is_writable (GObject *obj, guint prop_id)
+{
+ GabblePropertiesMixin *mixin = GABBLE_PROPERTIES_MIXIN (obj);
+ GabblePropertiesMixinClass *mixin_cls = GABBLE_PROPERTIES_MIXIN_CLASS (
+ G_OBJECT_GET_CLASS (obj));
+
+ if (prop_id >= mixin_cls->num_props)
+ return FALSE;
+
+ return ((mixin->properties[prop_id].flags & TP_PROPERTY_FLAG_WRITE) != 0);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/roster.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,1653 @@
+/*
+ * roster.c - Source for Gabble roster helper
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <dbus/dbus-glib.h>
+#include <string.h>
+
+#include "telepathy-interfaces.h"
+#include "tp-channel-factory-iface.h"
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "gabble-roster-channel.h"
+#include "namespaces.h"
+#include "roster.h"
+#include "util.h"
+
+#include "gabble_enums.h"
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_ROSTER
+#define GOOGLE_ROSTER_VERSION "2"
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/* Properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+/* signal enum */
+enum
+{
+ NICKNAME_UPDATE,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_ROSTER
+#endif
+
+};
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_roster,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_roster, s)())
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+#endif
+
+
+typedef struct _GabbleRosterPrivate GabbleRosterPrivate;
+struct _GabbleRosterPrivate
+{
+ GabbleConnection *conn;
+
+ LmMessageHandler *iq_cb;
+ LmMessageHandler *presence_cb;
+
+ GHashTable *channels;
+ GHashTable *items;
+
+ gboolean roster_received;
+ gboolean dispose_has_run;
+};
+
+typedef enum
+{
+ GOOGLE_ITEM_TYPE_NORMAL = 0,
+ GOOGLE_ITEM_TYPE_BLOCKED,
+ GOOGLE_ITEM_TYPE_HIDDEN,
+ GOOGLE_ITEM_TYPE_PINNED
+} GoogleItemType;
+
+typedef struct _GabbleRosterItem GabbleRosterItem;
+struct _GabbleRosterItem
+{
+ GabbleRosterSubscription subscription;
+ gboolean ask_subscribe;
+ GoogleItemType google_type;
+ gchar *name;
+ gchar **groups;
+};
+
+static void gabble_roster_factory_iface_init ();
+static void gabble_roster_init (GabbleRoster *roster);
+static GObject * gabble_roster_constructor (GType type, guint n_props, GObjectConstructParam *props);
+static void gabble_roster_dispose (GObject *object);
+static void gabble_roster_finalize (GObject *object);
+static void gabble_roster_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec);
+static void gabble_roster_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec);
+
+static void _gabble_roster_item_free (GabbleRosterItem *item);
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleRoster, gabble_roster, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE, gabble_roster_factory_iface_init));
+#else
+ GET_STATIC_VAR_FROM_TLS(gabble_roster_parent_class,gabble_roster,gpointer)
+ #define gabble_roster_parent_class (*GET_WSD_VAR_NAME(gabble_roster_parent_class,gabble_roster,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_roster,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_roster,s)())
+
+
+ static void gabble_roster_init (GabbleRoster *self);
+ static void gabble_roster_class_init (GabbleRosterClass *klass);
+ static void gabble_roster_class_intern_init (gpointer klass) { gabble_roster_parent_class = g_type_class_peek_parent (klass); gabble_roster_class_init ((GabbleRosterClass*) klass); } EXPORT_C GType gabble_roster_get_type (void) { if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleRosterClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_roster_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleRoster), 0, (GInstanceInitFunc) gabble_roster_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleRoster"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) gabble_roster_factory_iface_init }; g_type_add_interface_static (g_define_type_id, tp_channel_factory_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+
+#endif
+
+#define GABBLE_ROSTER_GET_PRIVATE(o) ((GabbleRosterPrivate*) ((o)->priv));
+
+static void
+gabble_roster_class_init (GabbleRosterClass *gabble_roster_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_roster_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_roster_class, sizeof (GabbleRosterPrivate));
+
+ object_class->constructor = gabble_roster_constructor;
+
+ object_class->dispose = gabble_roster_dispose;
+ object_class->finalize = gabble_roster_finalize;
+
+ object_class->get_property = gabble_roster_get_property;
+ object_class->set_property = gabble_roster_set_property;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "XMPP roster object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class,
+ PROP_CONNECTION,
+ param_spec);
+
+ signals[NICKNAME_UPDATE] = g_signal_new (
+ "nickname-update",
+ G_TYPE_FROM_CLASS (gabble_roster_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+}
+
+static void
+gabble_roster_init (GabbleRoster *obj)
+{
+ GabbleRosterPrivate *priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (obj, GABBLE_TYPE_ROSTER, GabbleRosterPrivate);
+
+ obj->priv = priv;
+
+ priv->channels = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ g_object_unref);
+
+ priv->items = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ (GDestroyNotify) _gabble_roster_item_free);
+}
+
+static GObject *
+gabble_roster_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ /* GabbleRosterPrivate *priv; */
+
+ obj = G_OBJECT_CLASS (gabble_roster_parent_class)->
+ constructor (type, n_props, props);
+ /* priv = GABBLE_ROSTER_GET_PRIVATE (GABBLE_ROSTER (obj)); */
+
+ return obj;
+}
+
+void
+gabble_roster_dispose (GObject *object)
+{
+ GabbleRoster *self = GABBLE_ROSTER (object);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+
+ priv->dispose_has_run = TRUE;
+
+ g_assert (priv->iq_cb == NULL);
+ g_assert (priv->presence_cb == NULL);
+
+ tp_channel_factory_iface_close_all (TP_CHANNEL_FACTORY_IFACE (object));
+ g_assert (priv->channels == NULL);
+
+ if (G_OBJECT_CLASS (gabble_roster_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_roster_parent_class)->dispose (object);
+}
+
+static void
+item_handle_unref_foreach (gpointer key, gpointer data, gpointer user_data)
+{
+ GabbleHandle handle = (GabbleHandle) key;
+ GabbleRosterPrivate *priv = (GabbleRosterPrivate *) user_data;
+
+ gabble_handle_unref (priv->conn->handles, TP_HANDLE_TYPE_CONTACT, handle);
+}
+
+void
+gabble_roster_finalize (GObject *object)
+{
+ GabbleRoster *self = GABBLE_ROSTER (object);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (self);
+
+ gabble_debug (DEBUG_FLAG, "called with %p", object);
+
+ g_hash_table_foreach (priv->items, item_handle_unref_foreach, priv);
+ g_hash_table_destroy (priv->items);
+
+ G_OBJECT_CLASS (gabble_roster_parent_class)->finalize (object);
+}
+
+static void
+gabble_roster_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (object);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_roster_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (object);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+_gabble_roster_item_free (GabbleRosterItem *item)
+{
+ g_assert (item != NULL);
+
+ g_strfreev (item->groups);
+ g_free (item->name);
+ g_free (item);
+}
+
+static const gchar *
+_subscription_to_string (GabbleRosterSubscription subscription)
+{
+ switch (subscription)
+ {
+ case GABBLE_ROSTER_SUBSCRIPTION_NONE:
+ return "none";
+ case GABBLE_ROSTER_SUBSCRIPTION_FROM:
+ return "from";
+ case GABBLE_ROSTER_SUBSCRIPTION_TO:
+ return "to";
+ case GABBLE_ROSTER_SUBSCRIPTION_BOTH:
+ return "both";
+ case GABBLE_ROSTER_SUBSCRIPTION_REMOVE:
+ return "remove";
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+}
+
+static GabbleRosterSubscription
+_parse_item_subscription (LmMessageNode *item_node)
+{
+ const gchar *subscription;
+
+ g_assert (item_node != NULL);
+
+ subscription = lm_message_node_get_attribute (item_node, "subscription");
+
+ if (NULL == subscription || 0 == strcmp (subscription, "none"))
+ return GABBLE_ROSTER_SUBSCRIPTION_NONE;
+ else if (0 == strcmp (subscription, "from"))
+ return GABBLE_ROSTER_SUBSCRIPTION_FROM;
+ else if (0 == strcmp (subscription, "to"))
+ return GABBLE_ROSTER_SUBSCRIPTION_TO;
+ else if (0 == strcmp (subscription, "both"))
+ return GABBLE_ROSTER_SUBSCRIPTION_BOTH;
+ else if (0 == strcmp (subscription, "remove"))
+ return GABBLE_ROSTER_SUBSCRIPTION_REMOVE;
+ else
+ {
+ NODE_DEBUG (item_node, "got unexpected subscription value");
+ return GABBLE_ROSTER_SUBSCRIPTION_NONE;
+ }
+}
+
+static gchar **
+_parse_item_groups (LmMessageNode *item_node)
+{
+ LmMessageNode *group_node;
+ GPtrArray *strv;
+
+ strv = g_ptr_array_new ();
+
+ for (group_node = item_node->children;
+ NULL != group_node;
+ group_node = group_node->next)
+ {
+ if (0 != strcmp (group_node->name, "group"))
+ continue;
+
+ if (NULL == group_node->value)
+ continue;
+
+ g_ptr_array_add (strv, g_strdup (group_node->value));
+ }
+
+ g_ptr_array_add (strv, NULL);
+
+ return (gchar **) g_ptr_array_free (strv, FALSE);
+}
+
+static const gchar *
+_google_item_type_to_string (GoogleItemType google_type)
+{
+ switch (google_type)
+ {
+ case GOOGLE_ITEM_TYPE_NORMAL:
+ return NULL;
+ case GOOGLE_ITEM_TYPE_BLOCKED:
+ return "B";
+ case GOOGLE_ITEM_TYPE_HIDDEN:
+ return "H";
+ case GOOGLE_ITEM_TYPE_PINNED:
+ return "P";
+ }
+
+ g_assert_not_reached ();
+
+ return NULL;
+}
+
+static GoogleItemType
+_parse_google_item_type (LmMessageNode *item_node)
+{
+ const gchar *google_type;
+
+ g_assert (item_node != NULL);
+
+ google_type = lm_message_node_get_attribute (item_node, "gr:t");
+
+ if (NULL == google_type)
+ return GOOGLE_ITEM_TYPE_NORMAL;
+ else if (!g_strdiff (google_type, "B"))
+ return GOOGLE_ITEM_TYPE_BLOCKED;
+ else if (!g_strdiff (google_type, "H"))
+ return GOOGLE_ITEM_TYPE_HIDDEN;
+ else if (!g_strdiff (google_type, "P"))
+ return GOOGLE_ITEM_TYPE_PINNED;
+
+ NODE_DEBUG (item_node, "got unexpected google contact type value");
+
+ return GOOGLE_ITEM_TYPE_NORMAL;
+}
+
+static gboolean
+_google_roster_item_should_keep (LmMessageNode *item_node,
+ GabbleRosterItem *item)
+{
+ const gchar *attr;
+
+ /* skip automatically subscribed Google roster items */
+ attr = lm_message_node_get_attribute (item_node, "gr:autosub");
+
+ if (!g_strdiff (attr, "true"))
+ return FALSE;
+
+ /* skip email addresses that replied to an invite */
+ attr = lm_message_node_get_attribute (item_node, "gr:alias-for");
+
+ if (attr != NULL)
+ return FALSE;
+
+ /* allow items that we've requested a subscription from */
+ if (item->ask_subscribe)
+ return TRUE;
+
+ if (item->subscription != GABBLE_ROSTER_SUBSCRIPTION_NONE)
+ return TRUE;
+
+ /* discard anything else */
+ return FALSE;
+}
+
+static GabbleRosterItem *
+_gabble_roster_item_get (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ GabbleRosterItem *item;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (roster != NULL);
+ g_assert (GABBLE_IS_ROSTER (roster));
+ g_assert (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL));
+
+ item = g_hash_table_lookup (priv->items, GINT_TO_POINTER (handle));
+
+ if (NULL == item)
+ {
+ item = g_new0 (GabbleRosterItem, 1);
+ gabble_handle_ref (priv->conn->handles, TP_HANDLE_TYPE_CONTACT, handle);
+ g_hash_table_insert (priv->items, GINT_TO_POINTER (handle), item);
+ }
+
+ return item;
+}
+
+static void
+_gabble_roster_item_remove (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (roster != NULL);
+ g_assert (GABBLE_IS_ROSTER (roster));
+ g_assert (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL));
+
+ g_hash_table_remove (priv->items, GINT_TO_POINTER (handle));
+ gabble_handle_unref (priv->conn->handles, TP_HANDLE_TYPE_CONTACT, handle);
+}
+
+static GabbleRosterItem *
+_gabble_roster_item_update (GabbleRoster *roster,
+ GabbleHandle handle,
+ LmMessageNode *node,
+ gboolean google_roster_mode)
+{
+ GabbleRosterItem *item;
+ const gchar *ask, *name;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (roster != NULL);
+ g_assert (GABBLE_IS_ROSTER (roster));
+ g_assert (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL));
+ g_assert (node != NULL);
+
+ item = _gabble_roster_item_get (roster, handle);
+
+ item->subscription = _parse_item_subscription (node);
+
+ ask = lm_message_node_get_attribute (node, "ask");
+ if (NULL != ask && 0 == strcmp (ask, "subscribe"))
+ item->ask_subscribe = TRUE;
+ else
+ item->ask_subscribe = FALSE;
+
+ if (google_roster_mode)
+ {
+ item->google_type = _parse_google_item_type (node);
+
+ /* discard roster item if strange, just hide it if it's hidden */
+ if (item->google_type == GOOGLE_ITEM_TYPE_HIDDEN)
+ {
+ gabble_debug (DEBUG_FLAG, "Google roster: caching hidden contact %d (%s)", handle,
+ lm_message_node_get_attribute (node, "jid"));
+ item->subscription = GABBLE_ROSTER_SUBSCRIPTION_NONE;
+ }
+ else if (!_google_roster_item_should_keep (node, item))
+ {
+ gabble_debug (DEBUG_FLAG, "Google roster: discarding odd contact %d (%s)", handle,
+ lm_message_node_get_attribute (node, "jid"));
+ item->subscription = GABBLE_ROSTER_SUBSCRIPTION_REMOVE;
+ }
+ }
+
+ if (item->subscription == GABBLE_ROSTER_SUBSCRIPTION_REMOVE)
+ name = NULL;
+ else
+ name = lm_message_node_get_attribute (node, "name");
+
+ if (g_strdiff (item->name, name))
+ {
+ g_free (item->name);
+ item->name = g_strdup (name);
+
+ gabble_debug (DEBUG_FLAG, "name for handle %d changed to %s", handle, name);
+ g_signal_emit (G_OBJECT (roster), signals[NICKNAME_UPDATE], 0, handle);
+ }
+
+ g_strfreev (item->groups);
+ item->groups = _parse_item_groups (node);
+
+ return item;
+}
+
+
+#ifdef ENABLE_DEBUG
+static gchar *
+_gabble_roster_item_dump (GabbleRosterItem *item)
+{
+ GString *str;
+
+ g_assert (item != NULL);
+
+ str = g_string_new ("subscription: ");
+
+ g_string_append (str, _subscription_to_string (item->subscription));
+
+ if (item->ask_subscribe)
+ g_string_append (str, ", ask: subscribe");
+
+ if (item->google_type != GOOGLE_ITEM_TYPE_NORMAL)
+ g_string_append_printf (str, ", google_type: %s",
+ _google_item_type_to_string (item->google_type));
+
+ if (item->name)
+ g_string_append_printf (str, ", name: %s", item->name);
+
+ if (item->groups)
+ {
+ gchar **tmp;
+ g_string_append (str, ", groups: { ");
+ for (tmp = item->groups; *tmp; tmp++)
+ {
+ g_string_append (str, *tmp);
+ g_string_append_c (str, ' ');
+ }
+ g_string_append (str, "}");
+ }
+
+ return g_string_free (str, FALSE);
+}
+#endif /* ENABLE_DEBUG */
+
+
+static LmMessage *
+_gabble_roster_message_new (GabbleRoster *roster,
+ LmMessageSubType sub_type,
+ LmMessageNode **query_return)
+{
+ LmMessage *message;
+ LmMessageNode *query_node;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (roster != NULL);
+ g_assert (GABBLE_IS_ROSTER (roster));
+
+ message = lm_message_new_with_sub_type (NULL,
+ LM_MESSAGE_TYPE_IQ,
+ sub_type);
+
+ query_node = lm_message_node_add_child (message->node, "query", NULL);
+
+ if (NULL != query_return)
+ *query_return = query_node;
+
+ lm_message_node_set_attribute (query_node, "xmlns", NS_ROSTER);
+
+ if (priv->conn->features & GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER)
+ {
+ lm_message_node_set_attributes (query_node,
+ "xmlns:gr", NS_GOOGLE_ROSTER,
+ "gr:ext", GOOGLE_ROSTER_VERSION,
+ "gr:include", "all",
+ NULL);
+ }
+
+ return message;
+}
+
+
+static LmMessage *
+_gabble_roster_item_to_message (GabbleRoster *roster,
+ GabbleHandle handle,
+ LmMessageNode **item_return)
+{
+ const gchar *jid;
+
+ LmMessage *message;
+ LmMessageNode *query_node, *item_node;
+ GabbleRosterItem *item;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (roster != NULL);
+ g_assert (GABBLE_IS_ROSTER (roster));
+ g_assert (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL));
+
+ item = _gabble_roster_item_get (roster, handle);
+
+ message = _gabble_roster_message_new (roster, LM_MESSAGE_SUB_TYPE_SET,
+ &query_node);
+
+ item_node = lm_message_node_add_child (query_node, "item", NULL);
+
+ if (NULL != item_return)
+ *item_return = item_node;
+
+ jid = gabble_handle_inspect (priv->conn->handles, TP_HANDLE_TYPE_CONTACT,
+ handle);
+ lm_message_node_set_attribute (item_node, "jid", jid);
+
+ if (item->subscription != GABBLE_ROSTER_SUBSCRIPTION_NONE)
+ {
+ const gchar *subscription = _subscription_to_string (item->subscription);
+ lm_message_node_set_attribute (item_node, "subscription", subscription);
+ }
+
+ if (item->subscription == GABBLE_ROSTER_SUBSCRIPTION_REMOVE)
+ goto DONE;
+
+ if ((priv->conn->features & GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER) &&
+ item->google_type != GOOGLE_ITEM_TYPE_NORMAL)
+ lm_message_node_set_attribute (item_node, "gr:t",
+ _google_item_type_to_string (item->google_type));
+
+ if (item->ask_subscribe)
+ lm_message_node_set_attribute (item_node, "ask", "subscribe");
+
+ if (item->name)
+ lm_message_node_set_attribute (item_node, "name", item->name);
+
+ if (item->groups)
+ {
+ gchar **tmp;
+
+ for (tmp = item->groups; *tmp; tmp++)
+ {
+ lm_message_node_add_child (item_node, "group", *tmp);
+ }
+ }
+
+DONE:
+ return message;
+}
+
+static GabbleRosterChannel *
+_gabble_roster_create_channel (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ const char *name;
+ char *object_path;
+
+ GabbleRosterChannel *chan;
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (priv->channels != NULL);
+ g_assert (g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle)) == NULL);
+
+ name = gabble_handle_inspect (priv->conn->handles, TP_HANDLE_TYPE_LIST, handle);
+ object_path = g_strdup_printf ("%s/RosterChannel/%s", priv->conn->object_path, name);
+ chan = g_object_new (GABBLE_TYPE_ROSTER_CHANNEL,
+ "connection", priv->conn,
+ "object-path", object_path,
+ "handle", handle,
+ NULL);
+
+ gabble_debug (DEBUG_FLAG, "created %s", object_path);
+ g_free (object_path);
+
+ g_hash_table_insert (priv->channels, GINT_TO_POINTER (handle), chan);
+
+ if (priv->roster_received)
+ {
+ gabble_debug (DEBUG_FLAG, "roster already received, emitting signal for %s list channel",
+ name);
+
+ g_signal_emit_by_name (roster, "new-channel", chan);
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "roster not yet received, not emitting signal for %s list channel",
+ name);
+ }
+
+ return chan;
+}
+
+static GabbleRosterChannel *
+_gabble_roster_get_channel (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ GabbleRosterChannel *chan;
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (priv->channels != NULL);
+ g_assert (gabble_handle_is_valid (priv->conn->handles, TP_HANDLE_TYPE_LIST, handle, NULL));
+
+ chan = g_hash_table_lookup (priv->channels, GINT_TO_POINTER (handle));
+
+ if (chan == NULL)
+ chan = _gabble_roster_create_channel (roster, handle);
+
+ return chan;
+}
+
+static void
+_gabble_roster_emit_one (gpointer key,
+ gpointer value,
+ gpointer data)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (data);
+ GabbleRosterChannel *chan = GABBLE_ROSTER_CHANNEL (value);
+#ifdef ENABLE_DEBUG
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+ GabbleHandle handle = GPOINTER_TO_INT (key);
+ const gchar *name = gabble_handle_inspect (priv->conn->handles, TP_HANDLE_TYPE_LIST, handle);
+
+ gabble_debug (DEBUG_FLAG, "roster now received, emitting signal signal for %s list channel",
+ name);
+#endif
+
+ g_signal_emit_by_name (roster, "new-channel", chan);
+}
+
+static void
+_gabble_roster_received (GabbleRoster *roster)
+{
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (priv->channels != NULL);
+
+ if (!priv->roster_received)
+ {
+ priv->roster_received = TRUE;
+
+ g_hash_table_foreach (priv->channels, _gabble_roster_emit_one, roster);
+ }
+}
+
+/**
+ * gabble_roster_iq_cb
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler
+ * is concerned only with roster queries, and allows other handlers
+ * if queries other than rosters are received.
+ */
+static LmHandlerResult
+gabble_roster_iq_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ const gchar *from;
+ gboolean google_roster = FALSE;
+ LmMessageNode *iq_node, *query_node;
+ LmMessageSubType sub_type;
+
+ GabbleRoster *roster = GABBLE_ROSTER (user_data);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (lmconn == priv->conn->lmconn);
+
+ if (priv->channels == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ iq_node = lm_message_get_node (message);
+ query_node = lm_message_node_get_child_with_namespace (iq_node, "query",
+ NS_ROSTER);
+
+ if (query_node == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ from = lm_message_node_get_attribute (message->node, "from");
+
+ if (from != NULL)
+ {
+ GabbleHandle sender;
+
+ sender = gabble_handle_for_contact (priv->conn->handles,
+ from, FALSE);
+
+ if (sender != priv->conn->self_handle)
+ {
+ NODE_DEBUG (iq_node, "discarding roster IQ which is not from "
+ "ourselves or the server");
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ }
+
+ if (priv->conn->features & GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER)
+ {
+ const char *gr_ext;
+
+ gr_ext = lm_message_node_get_attribute (query_node, "gr:ext");
+
+ if (!g_strdiff (gr_ext, GOOGLE_ROSTER_VERSION))
+ google_roster = TRUE;
+ }
+
+ sub_type = lm_message_get_sub_type (message);
+
+ /* if this is a result, it's from our initial query. if it's a set,
+ * it's a roster push. either way, parse the items. */
+ switch (sub_type)
+ {
+ LmMessageNode *item_node;
+ GIntSet *pub_add, *pub_rem,
+ *sub_add, *sub_rem, *sub_rp,
+ *known_add, *known_rem,
+ *deny_add, *deny_rem;
+ GArray *removed;
+ GabbleHandle handle;
+ GabbleRosterChannel *chan;
+ guint i;
+
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ case LM_MESSAGE_SUB_TYPE_SET:
+ /* asymmetry is because we don't get locally pending subscription
+ * requests via <roster>, we get it via <presence> */
+ pub_add = g_intset_new ();
+ pub_rem = g_intset_new ();
+ sub_add = g_intset_new ();
+ sub_rem = g_intset_new ();
+ sub_rp = g_intset_new ();
+ known_add = g_intset_new ();
+ known_rem = g_intset_new ();
+ removed = g_array_new (FALSE, FALSE, sizeof (GabbleHandle));
+
+ if (google_roster)
+ {
+ deny_add = g_intset_new ();
+ deny_rem = g_intset_new ();
+ }
+ else
+ {
+ deny_add = NULL;
+ deny_rem = NULL;
+ }
+
+ /* get the publish channel first because we need it when processing */
+ handle = GABBLE_LIST_HANDLE_PUBLISH;
+ chan = _gabble_roster_get_channel (roster, handle);
+
+ /* iterate every sub-node, which we expect to be <item>s */
+ for (item_node = query_node->children;
+ item_node;
+ item_node = item_node->next)
+ {
+ const char *jid;
+ GabbleRosterItem *item;
+
+ if (strcmp (item_node->name, "item"))
+ {
+ NODE_DEBUG (item_node, "query sub-node is not item, skipping");
+ continue;
+ }
+
+ jid = lm_message_node_get_attribute (item_node, "jid");
+ if (!jid)
+ {
+ NODE_DEBUG (item_node, "item node has no jid, skipping");
+ continue;
+ }
+
+ handle = gabble_handle_for_contact (priv->conn->handles, jid, FALSE);
+ if (handle == 0)
+ {
+ NODE_DEBUG (item_node, "item jid is malformed, skipping");
+ continue;
+ }
+
+ item = _gabble_roster_item_update (roster, handle, item_node,
+ google_roster);
+
+#ifdef ENABLE_DEBUG
+ if (DEBUGGING)
+ {
+ gchar *dump = _gabble_roster_item_dump (item);
+ gabble_debug (DEBUG_FLAG, "jid: %s, %s", jid, dump);
+ g_free (dump);
+ }
+#endif
+
+ /* handle publish list changes */
+ switch (item->subscription)
+ {
+ case GABBLE_ROSTER_SUBSCRIPTION_FROM:
+ case GABBLE_ROSTER_SUBSCRIPTION_BOTH:
+ g_intset_add (pub_add, handle);
+ break;
+ case GABBLE_ROSTER_SUBSCRIPTION_NONE:
+ case GABBLE_ROSTER_SUBSCRIPTION_TO:
+ case GABBLE_ROSTER_SUBSCRIPTION_REMOVE:
+ /* publish channel is a bit odd, the roster item doesn't tell us
+ * if someone is awaiting our approval - we get this via presence
+ * type=subscribe, so we have to not remove them if they're
+ * already local_pending in our publish channel */
+ if (!handle_set_is_member (chan->group.local_pending, handle))
+ {
+ g_intset_add (pub_rem, handle);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ /* handle subscribe list changes */
+ switch (item->subscription)
+ {
+ case GABBLE_ROSTER_SUBSCRIPTION_TO:
+ case GABBLE_ROSTER_SUBSCRIPTION_BOTH:
+ g_intset_add (sub_add, handle);
+ break;
+ case GABBLE_ROSTER_SUBSCRIPTION_NONE:
+ case GABBLE_ROSTER_SUBSCRIPTION_FROM:
+ if (item->ask_subscribe)
+ g_intset_add (sub_rp, handle);
+ else
+ g_intset_add (sub_rem, handle);
+ break;
+ case GABBLE_ROSTER_SUBSCRIPTION_REMOVE:
+ g_intset_add (sub_rem, handle);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ /* handle known list changes */
+ switch (item->subscription)
+ {
+ case GABBLE_ROSTER_SUBSCRIPTION_NONE:
+ case GABBLE_ROSTER_SUBSCRIPTION_TO:
+ case GABBLE_ROSTER_SUBSCRIPTION_FROM:
+ case GABBLE_ROSTER_SUBSCRIPTION_BOTH:
+ if (item->google_type == GOOGLE_ITEM_TYPE_HIDDEN)
+ g_intset_add (known_rem, handle);
+ else
+ g_intset_add (known_add, handle);
+ break;
+ case GABBLE_ROSTER_SUBSCRIPTION_REMOVE:
+ g_intset_add (known_rem, handle);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ /* handle deny list changes */
+ if (google_roster)
+ {
+ switch (item->subscription)
+ {
+ case GABBLE_ROSTER_SUBSCRIPTION_NONE:
+ case GABBLE_ROSTER_SUBSCRIPTION_TO:
+ case GABBLE_ROSTER_SUBSCRIPTION_FROM:
+ case GABBLE_ROSTER_SUBSCRIPTION_BOTH:
+ if (item->google_type == GOOGLE_ITEM_TYPE_BLOCKED)
+ g_intset_add (deny_add, handle);
+ else
+ g_intset_add (deny_rem, handle);
+ break;
+ case GABBLE_ROSTER_SUBSCRIPTION_REMOVE:
+ g_intset_add (deny_rem, handle);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ /* delay removing items from roster until signals have been emitted;
+ * otherwise handles go out of scope! */
+ if (GABBLE_ROSTER_SUBSCRIPTION_REMOVE == item->subscription)
+ g_array_append_val (removed, handle);
+ }
+
+ /* chan was initialised to the publish channel before the for loop */
+
+ gabble_debug (DEBUG_FLAG, "calling change members on publish channel");
+ gabble_group_mixin_change_members (G_OBJECT (chan),
+ "", pub_add, pub_rem, NULL, NULL, 0, 0);
+
+ handle = GABBLE_LIST_HANDLE_SUBSCRIBE;
+ chan = _gabble_roster_get_channel (roster, handle);
+
+ gabble_debug (DEBUG_FLAG, "calling change members on subscribe channel");
+ gabble_group_mixin_change_members (G_OBJECT (chan),
+ "", sub_add, sub_rem, NULL, sub_rp, 0, 0);
+
+ handle = GABBLE_LIST_HANDLE_KNOWN;
+ chan = _gabble_roster_get_channel (roster, handle);
+
+ gabble_debug (DEBUG_FLAG, "calling change members on known channel");
+ gabble_group_mixin_change_members (G_OBJECT (chan),
+ "", known_add, known_rem, NULL, NULL, 0, 0);
+
+ if (google_roster)
+ {
+ handle = GABBLE_LIST_HANDLE_DENY;
+ chan = _gabble_roster_get_channel (roster, handle);
+
+ gabble_debug (DEBUG_FLAG, "calling change members on deny channel");
+ gabble_group_mixin_change_members (G_OBJECT (chan),
+ "", deny_add, deny_rem, NULL, NULL, 0, 0);
+
+ g_intset_destroy (deny_add);
+ g_intset_destroy (deny_rem);
+ }
+
+ for (i = 0; i < removed->len; i++)
+ _gabble_roster_item_remove (roster,
+ g_array_index (removed, GabbleHandle, i));
+
+ g_intset_destroy (pub_add);
+ g_intset_destroy (pub_rem);
+ g_intset_destroy (sub_add);
+ g_intset_destroy (sub_rem);
+ g_intset_destroy (sub_rp);
+ g_intset_destroy (known_add);
+ g_intset_destroy (known_rem);
+ g_array_free (removed, TRUE);
+ break;
+ default:
+ NODE_DEBUG (iq_node, "unhandled roster IQ");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ switch (sub_type)
+ {
+ case LM_MESSAGE_SUB_TYPE_RESULT:
+ /* result means it's a roster push, so the roster is now complete and we
+ * can emit signals */
+ _gabble_roster_received (roster);
+ break;
+ case LM_MESSAGE_SUB_TYPE_SET:
+ /* acknowledge roster */
+ _gabble_connection_acknowledge_set_iq (priv->conn, message);
+ break;
+ default:
+ break;
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+
+static void
+_gabble_roster_send_presence_ack (GabbleRoster *roster,
+ const gchar *from,
+ LmMessageSubType sub_type,
+ gboolean changed)
+{
+ LmMessage *reply;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ if (!changed)
+ {
+ gabble_debug (DEBUG_FLAG, "not sending ack to avoid loop with buggy server");
+ return;
+ }
+
+ switch (sub_type)
+ {
+ case LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE:
+ sub_type = LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED;
+ break;
+ case LM_MESSAGE_SUB_TYPE_SUBSCRIBED:
+ sub_type = LM_MESSAGE_SUB_TYPE_SUBSCRIBE;
+ break;
+ case LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED:
+ sub_type = LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE;
+ break;
+ default:
+ g_assert_not_reached();
+ return;
+ }
+
+ reply = lm_message_new_with_sub_type (from,
+ LM_MESSAGE_TYPE_PRESENCE,
+ sub_type);
+
+ _gabble_connection_send (priv->conn, reply, NULL);
+
+ lm_message_unref (reply);
+}
+
+
+/**
+ * connection_presence_roster_cb:
+ * @handler: #LmMessageHandler for this message
+ * @connection: #LmConnection that originated the message
+ * @message: the presence message
+ * @user_data: callback data
+ *
+ * Called by loudmouth when we get an incoming <presence>.
+ */
+static LmHandlerResult
+gabble_roster_presence_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ LmMessageNode *pres_node, *child_node;
+ const char *from;
+ LmMessageSubType sub_type;
+ GIntSet *tmp;
+ GabbleHandle handle;
+ const gchar *status_message = NULL;
+ GabbleRosterChannel *chan = NULL;
+ gboolean changed;
+ GabbleRoster *roster = GABBLE_ROSTER (user_data);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_assert (lmconn == priv->conn->lmconn);
+
+ if (priv->channels == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ pres_node = lm_message_get_node (message);
+
+ from = lm_message_node_get_attribute (pres_node, "from");
+
+ if (from == NULL)
+ {
+ NODE_DEBUG (pres_node, "presence stanza without from attribute, ignoring");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ sub_type = lm_message_get_sub_type (message);
+
+ handle = gabble_handle_for_contact (priv->conn->handles, from, FALSE);
+
+ if (handle == 0)
+ {
+ NODE_DEBUG (pres_node, "ignoring presence from malformed jid");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (handle == priv->conn->self_handle)
+ {
+ NODE_DEBUG (pres_node, "ignoring presence from ourselves on another resource");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ g_assert (handle != 0);
+
+ child_node = lm_message_node_get_child (pres_node, "status");
+ if (child_node)
+ status_message = lm_message_node_get_value (child_node);
+
+ switch (sub_type)
+ {
+ case LM_MESSAGE_SUB_TYPE_SUBSCRIBE:
+ gabble_debug (DEBUG_FLAG, "making %s (handle %u) local pending on the publish channel",
+ from, handle);
+
+ tmp = g_intset_new ();
+ g_intset_add (tmp, handle);
+
+ handle = GABBLE_LIST_HANDLE_PUBLISH;
+ chan = _gabble_roster_get_channel (roster, handle);
+ gabble_group_mixin_change_members (G_OBJECT (chan), status_message,
+ NULL, NULL, tmp, NULL, 0, 0);
+
+ g_intset_destroy (tmp);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ case LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE:
+ gabble_debug (DEBUG_FLAG, "removing %s (handle %u) from the publish channel",
+ from, handle);
+
+ tmp = g_intset_new ();
+ g_intset_add (tmp, handle);
+
+ handle = GABBLE_LIST_HANDLE_PUBLISH;
+ chan = _gabble_roster_get_channel (roster, handle);
+ changed = gabble_group_mixin_change_members (G_OBJECT (chan),
+ status_message, NULL, tmp, NULL, NULL, 0, 0);
+
+ _gabble_roster_send_presence_ack (roster, from, sub_type, changed);
+
+ g_intset_destroy (tmp);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ case LM_MESSAGE_SUB_TYPE_SUBSCRIBED:
+ gabble_debug (DEBUG_FLAG, "adding %s (handle %u) to the subscribe channel",
+ from, handle);
+
+ tmp = g_intset_new ();
+ g_intset_add (tmp, handle);
+
+ handle = GABBLE_LIST_HANDLE_SUBSCRIBE;
+ chan = _gabble_roster_get_channel (roster, handle);
+ changed = gabble_group_mixin_change_members (G_OBJECT (chan),
+ status_message, tmp, NULL, NULL, NULL, 0, 0);
+
+ _gabble_roster_send_presence_ack (roster, from, sub_type, changed);
+
+ g_intset_destroy (tmp);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ case LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED:
+ gabble_debug (DEBUG_FLAG, "removing %s (handle %u) from the subscribe channel",
+ from, handle);
+
+ tmp = g_intset_new ();
+ g_intset_add (tmp, handle);
+
+ handle = GABBLE_LIST_HANDLE_SUBSCRIBE;
+ chan = _gabble_roster_get_channel (roster, handle);
+ changed = gabble_group_mixin_change_members (G_OBJECT (chan),
+ status_message, NULL, tmp, NULL, NULL, 0, 0);
+
+ _gabble_roster_send_presence_ack (roster, from, sub_type, changed);
+
+ g_intset_destroy (tmp);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ default:
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+}
+
+static void
+gabble_roster_factory_iface_close_all (TpChannelFactoryIface *iface)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (iface);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ gabble_debug (DEBUG_FLAG, "closing channels");
+
+ if (priv->channels)
+ {
+ g_hash_table_destroy (priv->channels);
+ priv->channels = NULL;
+ }
+}
+
+static void
+gabble_roster_factory_iface_connecting (TpChannelFactoryIface *iface)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (iface);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ gabble_debug (DEBUG_FLAG, "adding callbacks");
+
+ g_assert (priv->iq_cb == NULL);
+ g_assert (priv->presence_cb == NULL);
+
+ priv->iq_cb = lm_message_handler_new (gabble_roster_iq_cb,
+ roster, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn,
+ priv->iq_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL);
+
+ priv->presence_cb = lm_message_handler_new (gabble_roster_presence_cb,
+ roster, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn,
+ priv->presence_cb,
+ LM_MESSAGE_TYPE_PRESENCE,
+ LM_HANDLER_PRIORITY_LAST);
+}
+
+static void
+gabble_roster_factory_iface_connected (TpChannelFactoryIface *iface)
+{
+ LmMessage *message;
+
+ GabbleRoster *roster = GABBLE_ROSTER (iface);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ gabble_debug (DEBUG_FLAG, "requesting roster");
+
+ message = _gabble_roster_message_new (roster, LM_MESSAGE_SUB_TYPE_GET, NULL);
+
+ _gabble_connection_send (priv->conn, message, NULL);
+
+ lm_message_unref (message);
+}
+
+static void
+gabble_roster_factory_iface_disconnected (TpChannelFactoryIface *iface)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (iface);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ gabble_debug (DEBUG_FLAG, "removing callbacks");
+
+ g_assert (priv->iq_cb != NULL);
+ g_assert (priv->presence_cb != NULL);
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn,
+ priv->iq_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (priv->iq_cb);
+ priv->iq_cb = NULL;
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn,
+ priv->presence_cb,
+ LM_MESSAGE_TYPE_PRESENCE);
+ lm_message_handler_unref (priv->presence_cb);
+ priv->presence_cb = NULL;
+}
+
+struct foreach_data {
+ TpChannelFunc func;
+ gpointer data;
+};
+
+static void
+_gabble_roster_factory_iface_foreach_one (gpointer key,
+ gpointer value,
+ gpointer data)
+{
+ TpChannelIface *chan = TP_CHANNEL_IFACE (value);
+ struct foreach_data *foreach = (struct foreach_data *) data;
+
+ foreach->func (chan, foreach->data);
+}
+
+static void
+gabble_roster_factory_iface_foreach (TpChannelFactoryIface *iface,
+ TpChannelFunc func,
+ gpointer data)
+{
+ struct foreach_data foreach;
+
+ GabbleRoster *roster = GABBLE_ROSTER (iface);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ foreach.func = func;
+ foreach.data = data;
+
+ g_hash_table_foreach (priv->channels,
+ _gabble_roster_factory_iface_foreach_one, &foreach);
+}
+
+static TpChannelFactoryRequestStatus
+gabble_roster_factory_iface_request (TpChannelFactoryIface *iface,
+ const gchar *chan_type,
+ TpHandleType handle_type,
+ guint handle,
+ TpChannelIface **ret,
+ GError **error)
+{
+ GabbleRoster *roster = GABBLE_ROSTER (iface);
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ if (strcmp (chan_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
+
+ if (handle_type != TP_HANDLE_TYPE_LIST)
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+
+ if (!gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_LIST,
+ handle,
+ NULL))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE;
+
+ /* disallow "deny" channels if we don't have google:roster support */
+ if (handle == GABBLE_LIST_HANDLE_DENY &&
+ !(priv->conn->features & GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+
+ if (priv->roster_received)
+ {
+ GabbleRosterChannel *chan;
+ chan = _gabble_roster_get_channel (roster, handle);
+ *ret = TP_CHANNEL_IFACE (chan);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE;
+ }
+ else
+ {
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_QUEUED;
+ }
+}
+
+static void
+gabble_roster_factory_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
+
+ klass->close_all = gabble_roster_factory_iface_close_all;
+ klass->connecting = gabble_roster_factory_iface_connecting;
+ klass->connected = gabble_roster_factory_iface_connected;
+ klass->disconnected = gabble_roster_factory_iface_disconnected;
+ klass->foreach = gabble_roster_factory_iface_foreach;
+ klass->request = gabble_roster_factory_iface_request;
+}
+
+GabbleRoster *
+gabble_roster_new (GabbleConnection *conn)
+{
+ g_return_val_if_fail (conn != NULL, NULL);
+
+ return g_object_new (GABBLE_TYPE_ROSTER,
+ "connection", conn,
+ NULL);
+}
+
+GabbleRosterSubscription
+gabble_roster_handle_get_subscription (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ GabbleRosterItem *item;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, GABBLE_ROSTER_SUBSCRIPTION_NONE);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster),
+ GABBLE_ROSTER_SUBSCRIPTION_NONE);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL),
+ GABBLE_ROSTER_SUBSCRIPTION_NONE);
+
+ item = g_hash_table_lookup (priv->items, GINT_TO_POINTER (handle));
+
+ if (NULL == item)
+ return GABBLE_ROSTER_SUBSCRIPTION_NONE;
+
+ return item->subscription;
+}
+
+gboolean
+gabble_roster_handle_set_blocked (GabbleRoster *roster,
+ GabbleHandle handle,
+ gboolean blocked,
+ GError **error)
+{
+ GabbleRosterItem *item;
+ GoogleItemType orig_type;
+ LmMessage *message;
+ gboolean ret;
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, FALSE);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster), FALSE);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), FALSE);
+ g_return_val_if_fail (priv->conn->features &
+ GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER, FALSE);
+
+ item = _gabble_roster_item_get (roster, handle);
+ orig_type = item->google_type;
+
+ if (blocked == (orig_type == GOOGLE_ITEM_TYPE_BLOCKED))
+ return TRUE;
+
+ /* temporarily set the desired block state and generate a message */
+ if (blocked)
+ item->google_type = GOOGLE_ITEM_TYPE_BLOCKED;
+ else
+ item->google_type = GOOGLE_ITEM_TYPE_NORMAL;
+ message = _gabble_roster_item_to_message (roster, handle, NULL);
+ item->google_type = orig_type;
+
+ ret = _gabble_connection_send (priv->conn, message, error);
+
+ lm_message_unref (message);
+
+ return ret;
+}
+
+gboolean
+gabble_roster_handle_has_entry (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ GabbleRosterItem *item;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, FALSE);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster), FALSE);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), FALSE);
+
+ item = g_hash_table_lookup (priv->items, GINT_TO_POINTER (handle));
+
+ return (NULL != item);
+}
+
+const gchar *
+gabble_roster_handle_get_name (GabbleRoster *roster,
+ GabbleHandle handle)
+{
+ GabbleRosterItem *item;
+
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, NULL);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster), NULL);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), NULL);
+
+ item = g_hash_table_lookup (priv->items, GINT_TO_POINTER (handle));
+
+ if (NULL == item)
+ return NULL;
+
+ return item->name;
+}
+
+gboolean
+gabble_roster_handle_set_name (GabbleRoster *roster,
+ GabbleHandle handle,
+ const gchar *name,
+ GError **error)
+{
+ LmMessage *message;
+ LmMessageNode *item_node;
+ gboolean ret;
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, FALSE);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster), FALSE);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), FALSE);
+ g_return_val_if_fail (name != NULL, FALSE);
+
+ message = _gabble_roster_item_to_message (roster, handle, &item_node);
+
+ lm_message_node_set_attribute (item_node, "name", name);
+
+ ret = _gabble_connection_send (priv->conn, message, error);
+
+ lm_message_unref (message);
+
+ return ret;
+}
+
+gboolean
+gabble_roster_handle_remove (GabbleRoster *roster,
+ GabbleHandle handle,
+ GError **error)
+{
+ GabbleRosterItem *item;
+ GabbleRosterSubscription subscription;
+ LmMessage *message;
+ gboolean ret;
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, FALSE);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster), FALSE);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), FALSE);
+
+ item = _gabble_roster_item_get (roster, handle);
+ subscription = item->subscription;
+ item->subscription = GABBLE_ROSTER_SUBSCRIPTION_REMOVE;
+
+ message = _gabble_roster_item_to_message (roster, handle, NULL);
+ ret = _gabble_connection_send (priv->conn, message, error);
+ lm_message_unref (message);
+
+ item->subscription = subscription;
+
+ return ret;
+}
+
+gboolean
+gabble_roster_handle_add (GabbleRoster *roster,
+ GabbleHandle handle,
+ GError **error)
+{
+ GabbleRosterItem *item;
+ LmMessage *message;
+ gboolean do_add = FALSE;
+ gboolean ret;
+ GabbleRosterPrivate *priv = GABBLE_ROSTER_GET_PRIVATE (roster);
+
+ g_return_val_if_fail (roster != NULL, FALSE);
+ g_return_val_if_fail (GABBLE_IS_ROSTER (roster), FALSE);
+ g_return_val_if_fail (gabble_handle_is_valid (priv->conn->handles,
+ TP_HANDLE_TYPE_CONTACT, handle, NULL), FALSE);
+
+ if (!gabble_roster_handle_has_entry (roster, handle))
+ do_add = TRUE;
+
+ item = _gabble_roster_item_get (roster, handle);
+
+ if (item->google_type == GOOGLE_ITEM_TYPE_HIDDEN)
+ {
+ item->google_type = GOOGLE_ITEM_TYPE_NORMAL;
+ do_add = TRUE;
+ }
+
+ if (!do_add)
+ return TRUE;
+
+ message = _gabble_roster_item_to_message (roster, handle, NULL);
+ ret = _gabble_connection_send (priv->conn, message, error);
+ lm_message_unref (message);
+
+ return ret;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/search-factory.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,412 @@
+/*
+ * search-factory.c - Source for GabbleSearchFactory
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "loudmouth/loudmouth.h"
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "telepathy-interfaces.h"
+#include "tp-channel-factory-iface.h"
+
+#include "search-mixin.h"
+#include "gabble-search-channel.h"
+
+#include "search-factory.h"
+
+static void gabble_search_factory_iface_init (gpointer g_iface, gpointer iface_data);
+
+#ifndef EMULATOR
+G_DEFINE_TYPE_WITH_CODE (GabbleSearchFactory, gabble_search_factory, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE, gabble_search_factory_iface_init));
+#endif
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(gabble_search_factory_parent_class,search_factory,gpointer)
+ #define gabble_search_factory_parent_class (*GET_WSD_VAR_NAME(gabble_search_factory_parent_class,search_factory,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,search_factory,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,search_factory,s)())
+
+static void gabble_search_factory_init (GabbleSearchFactory *self);
+static void gabble_search_factory_class_init (GabbleSearchFactoryClass *klass);
+static void gabble_search_factory_class_intern_init (gpointer klass)
+{
+ gabble_search_factory_parent_class = g_type_class_peek_parent (klass);
+ gabble_search_factory_class_init ((GabbleSearchFactoryClass*) klass);
+ }
+ EXPORT_C GType gabble_search_factory_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleSearchFactoryClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_search_factory_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleSearchFactory), 0, (GInstanceInitFunc) gabble_search_factory_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleSearchFactory"), &g_define_type_info, (GTypeFlags) 0); { { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) gabble_search_factory_iface_init }; g_type_add_interface_static (g_define_type_id, tp_channel_factory_iface_get_type(), &g_implement_interface_info); } ; } } return g_define_type_id; } ;
+
+#endif
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_IM
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/* properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+typedef struct _GabbleSearchFactoryPrivate GabbleSearchFactoryPrivate;
+struct _GabbleSearchFactoryPrivate
+{
+ GabbleConnection *conn;
+ GArray *channels;
+ gboolean dispose_has_run;
+};
+
+#define GABBLE_SEARCH_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GABBLE_TYPE_SEARCH_FACTORY, GabbleSearchFactoryPrivate))
+
+static GObject *gabble_search_factory_constructor (GType type, guint n_props, GObjectConstructParam *props);
+
+static void
+gabble_search_factory_init (GabbleSearchFactory *fac)
+{
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ priv->channels = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
+ priv->conn = NULL;
+ priv->dispose_has_run = FALSE;
+}
+
+static GObject *
+gabble_search_factory_constructor (GType type, guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ /* GabbleSearchFactoryPrivate *priv; */
+
+ obj = G_OBJECT_CLASS (gabble_search_factory_parent_class)->
+ constructor (type, n_props, props);
+ /* priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (obj); */
+
+ return obj;
+}
+
+
+static void
+gabble_search_factory_dispose (GObject *object)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (object);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->dispose_has_run)
+ return;
+
+ gabble_debug (DEBUG_FLAG, "dispose called");
+ priv->dispose_has_run = TRUE;
+
+ tp_channel_factory_iface_close_all (TP_CHANNEL_FACTORY_IFACE (object));
+ g_assert (priv->channels == NULL);
+
+ if (G_OBJECT_CLASS (gabble_search_factory_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_search_factory_parent_class)->dispose (object);
+}
+
+static void
+gabble_search_factory_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (object);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->conn);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_search_factory_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (object);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->conn = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_search_factory_class_init (GabbleSearchFactoryClass *gabble_search_factory_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_search_factory_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_search_factory_class, sizeof (GabbleSearchFactoryPrivate));
+
+ object_class->constructor = gabble_search_factory_constructor;
+ object_class->dispose = gabble_search_factory_dispose;
+
+ object_class->get_property = gabble_search_factory_get_property;
+ object_class->set_property = gabble_search_factory_set_property;
+
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "Search channel factory object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+}
+
+static GabbleSearchChannel *new_search_channel (GabbleSearchFactory *fac, GabbleHandle handle);
+
+static void search_channel_closed_cb (GabbleSearchChannel *chan, gpointer user_data);
+
+
+
+/**
+ * search_channel_closed_cb:
+ *
+ * Signal callback for when search channel is closed. Removes the references
+ * that #GabbleConnection holds to them.
+ */
+static void
+search_channel_closed_cb (GabbleSearchChannel *chan, gpointer user_data)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (user_data);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+ g_message("in search_channel_closed_cb");
+ if (priv->channels)
+ {
+ g_array_remove_index( priv->channels, chan->channel_index );
+ }
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn, chan->iq_cb,
+ LM_MESSAGE_TYPE_IQ);
+ lm_message_handler_unref (chan->iq_cb);
+ chan->iq_cb = NULL;
+ g_object_unref (chan);
+ chan = NULL;
+}
+
+/**
+ * new_search_channel
+ */
+static GabbleSearchChannel *
+new_search_channel (GabbleSearchFactory *fac, GabbleHandle handle)
+{
+ GabbleSearchFactoryPrivate *priv;
+ GabbleSearchChannel *chan;
+ char *object_path;
+
+ g_assert (GABBLE_IS_SEARCH_FACTORY (fac));
+
+ priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ g_message("in new_search_channel:handle %u\n",handle);
+
+ object_path = g_strdup_printf ("%s/SearchChannel%u", priv->conn->object_path, handle);
+
+ gabble_debug (DEBUG_FLAG, "object path %s", object_path);
+
+
+
+ // handle type should be none and handle value should be zero
+ // so handle passed in g_object_new
+ chan = g_object_new (GABBLE_TYPE_SEARCH_CHANNEL,
+ "connection", priv->conn,
+ "object-path", object_path,
+ "handle", handle,
+ NULL);
+
+ g_message("in new_search_channel: chan is %u\n", chan);
+
+ g_array_append_val(priv->channels, chan);
+
+ g_signal_connect (chan, "closed", (GCallback) search_channel_closed_cb,fac);
+
+
+ g_signal_emit_by_name (fac, "new-channel", chan);
+
+ g_free (object_path);
+ chan->channel_index = priv->channels->len - 1;
+
+ //added for search as chan need to be passed as userdata in search_channel_iq_cb
+ chan->iq_cb = lm_message_handler_new (search_channel_iq_cb, chan , NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn, chan->iq_cb,
+ LM_MESSAGE_TYPE_IQ,
+ LM_HANDLER_PRIORITY_NORMAL);
+
+ return chan;
+}
+
+static void
+gabble_search_factory_iface_close_all (TpChannelFactoryIface *iface)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (iface);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ gabble_debug (DEBUG_FLAG, "closing channels");
+
+ if (priv->channels)
+ {
+ g_array_free ( priv->channels, TRUE);
+ priv->channels = NULL;
+ }
+}
+
+static void
+gabble_search_factory_iface_connecting (TpChannelFactoryIface *iface)
+{
+ /* nothing to do */
+}
+
+
+
+static void
+gabble_search_factory_iface_connected (TpChannelFactoryIface *iface)
+{
+ /* nothing to do */
+}
+
+static void
+gabble_search_factory_iface_disconnected (TpChannelFactoryIface *iface)
+{
+ // free any object here
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (iface);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+
+ if (priv->channels)
+ {
+ g_array_free ( priv->channels, TRUE);
+ priv->channels = NULL;
+ }
+}
+
+struct _ForeachData
+{
+ TpChannelFunc foreach;
+ gpointer user_data;
+};
+
+static void
+_foreach_slave ( gpointer value, gpointer user_data )
+{
+ struct _ForeachData *data = (struct _ForeachData *) user_data;
+ TpChannelIface *chan = TP_CHANNEL_IFACE (value);
+
+ data->foreach (chan, data->user_data);
+}
+
+
+static void
+gabble_search_factory_iface_foreach (TpChannelFactoryIface *iface, TpChannelFunc foreach, gpointer user_data)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (iface);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+ struct _ForeachData data;
+ guint i = 0;
+ GabbleSearchChannel *chan = NULL;
+
+ data.user_data = user_data;
+ data.foreach = foreach;
+
+ for( i = 0; i< priv->channels->len ; i++ )
+ {
+ chan = GABBLE_SEARCH_CHANNEL ( g_array_index(priv->channels,guint,i) );
+ _foreach_slave(chan, &data);
+ }
+
+}
+
+static TpChannelFactoryRequestStatus
+gabble_search_factory_iface_request (TpChannelFactoryIface *iface,
+ const gchar *chan_type,
+ TpHandleType handle_type,
+ guint handle,
+ TpChannelIface **ret,
+ GError **error)
+{
+ GabbleSearchFactory *fac = GABBLE_SEARCH_FACTORY (iface);
+ GabbleSearchFactoryPrivate *priv = GABBLE_SEARCH_FACTORY_GET_PRIVATE (fac);
+ GabbleSearchChannel *chan;
+
+ if (strcmp (chan_type, TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH))
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
+
+ // should always pass handle type as none and handle as zero
+
+ if ((handle_type != TP_HANDLE_TYPE_NONE) || handle )
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+
+
+ g_message("in gabble_search_factory_iface_request:handle %u\n",handle);
+
+ chan = new_search_channel (fac, handle);
+ g_assert (chan);
+ *ret = TP_CHANNEL_IFACE (chan);
+ return TP_CHANNEL_FACTORY_REQUEST_STATUS_DONE;
+}
+
+static void
+gabble_search_factory_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
+
+ klass->close_all = gabble_search_factory_iface_close_all;
+ klass->connecting = gabble_search_factory_iface_connecting;
+ klass->connected = gabble_search_factory_iface_connected;
+ klass->disconnected = gabble_search_factory_iface_disconnected;
+ klass->foreach = gabble_search_factory_iface_foreach;
+ klass->request = gabble_search_factory_iface_request;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/search-keys-info.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,298 @@
+/*
+ * search-keys-info.c - Source for Jingle info discovery
+ * Copyright (C) 2008 Collabora Ltd.
+ * and/or its subsidiaries. All rights reserved.
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+
+#include "debug.h"
+#include "search-keys-info.h"
+#include "gabble-error.h"
+#include "namespaces.h"
+#include "util.h"
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+/**
+ * get_search_keys_info:
+ *
+ * get search keys
+ *
+ */
+void
+get_search_keys_info (GabbleConnection *conn, const gchar *jid )
+{
+ LmMessage *msg;
+ LmMessageNode *query_node;
+ gboolean result;
+ gchar *service = NULL;
+ GError *error = NULL;
+
+ conn->search_service_jid = g_strdup( jid );
+
+ msg= lm_message_new_with_sub_type ( jid,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_GET);
+ query_node = lm_message_node_add_child (msg->node, "query", NULL);
+
+ lm_message_node_set_attribute (query_node, "xmlns", NS_SEARCH);
+
+ if (!_gabble_connection_send (conn, msg, &error))
+ {
+ g_warning ("%s: send failed: %s\n", G_STRFUNC, error->message);
+ goto OUT;
+ }
+
+OUT:
+ if (msg)
+ lm_message_unref (msg);
+
+ if (error)
+ g_error_free (error);
+
+}
+
+
+/**
+ * _gabble_submit_search_form:
+ *
+ * Submit search form
+ *
+ */
+gboolean
+_gabble_submit_search_form (GabbleConnection *conn)
+{
+ LmMessage *msg;
+ LmMessageNode *query_node;
+ LmMessageNode *x_node;
+ LmMessageNode *field_node, *value_node;
+ gboolean result;
+ const gchar *jid;
+ gchar *service = NULL;
+ GError **error = NULL;
+
+ g_message("_gabble_submit_search_form\n");
+ jid = gabble_handle_inspect (conn->handles, TP_HANDLE_TYPE_CONTACT, conn->self_handle);
+ g_message("jid is %s\n",jid);
+ gabble_decode_jid(jid, NULL /*username*/,&service,NULL/*resource*/);
+ g_message("service is %s\n",service);
+
+ msg= lm_message_new_with_sub_type ( service,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+ query_node = lm_message_node_add_child (msg->node, "query", NULL);
+
+ lm_message_node_set_attribute (query_node, "xmlns", NS_SEARCH);
+
+ x_node = lm_message_node_add_child ( query_node, "x", NULL );
+
+ lm_message_node_set_attributes (x_node,
+ "xmlns", NS_X_DATA,
+ "type", "submit",
+ NULL);
+
+ field_node = lm_message_node_add_child ( x_node, "x", NULL );
+
+ lm_message_node_set_attributes (x_node,
+ "type", "hidden",
+ "var", "FORM_TYPE",
+ NULL);
+
+ value_node = lm_message_node_get_child(field_node, "value");
+ lm_message_node_set_value(value_node,"NS_SEARCH");
+
+ g_message("_gabble_submit_search_form b4 _gabble_connection_send\n");
+
+ result = _gabble_connection_send (conn, msg, error);
+ lm_message_unref (msg);
+
+ if (!result)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+/**
+ * search_keys_iq_cb
+ *
+ * Called by loudmouth when we get an incoming <iq>. This handler
+ * is concerned only with Requesting Search Keys info queries.
+ */
+LmHandlerResult
+search_keys_iq_cb (LmMessageHandler *handler,
+ LmConnection *lmconn,
+ LmMessage *message,
+ gpointer user_data)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (user_data);
+
+ LmMessageSubType sub_type;
+ LmMessageNode *query_node, *x_node, *result_node,*x_item_node;
+ const gchar *str;
+ const gchar *type, *field_label,*field_var, *field_type;
+ guint i = 0;
+
+ if ( NULL == conn )
+ {
+ g_debug ("%s: accesing after dereferenced connection", G_STRFUNC);
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ query_node = lm_message_node_get_child_with_namespace (message->node,
+ "query", NS_SEARCH);
+
+ if (query_node == NULL)
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ sub_type = lm_message_get_sub_type (message);
+
+ if (sub_type != LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (sub_type == LM_MESSAGE_SUB_TYPE_RESULT)
+ {
+ x_node = lm_message_node_get_child_with_namespace (query_node, "x", NS_X_DATA);
+
+ if( x_node )
+ {
+ //if service supports data forms
+ result_node = x_node;
+ type = lm_message_node_get_attribute (x_node, "type" );
+
+ if (0 == strcmp (type, "form"))
+ {
+ gint filed_count = 0;
+
+ for (x_item_node = result_node->children; x_item_node; x_item_node = x_item_node->next)
+ {
+ if( 0 == strcmp (x_item_node->name, "field") )
+ {
+ filed_count++;
+ }
+ }
+
+ if(conn->search_key_names == NULL)
+ {
+ conn->search_key_names = (gchar**)g_new0( gchar*, filed_count);
+ }
+
+ if(conn->search_key_ht == NULL)
+ {
+ conn->search_key_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ }
+
+ conn->search_form = TRUE;
+ for (x_item_node = result_node->children; x_item_node; x_item_node = x_item_node->next)
+ {
+
+ // "reported" should also be used to get the types of search result fields
+ //'g' type currently not supported by dbus-glib-binding
+ if (0 != strcmp (x_item_node->name, "field")
+ && 0 != strcmp (x_item_node->name, "instructions"))
+ continue;
+
+
+ if( 0 == strcmp (x_item_node->name, "instructions") )
+ {
+ //get the instructions
+ g_message("get the instuction\n");
+ conn->search_instr = g_strdup( lm_message_node_get_value(x_item_node) );
+ g_message("after gettting the instuction\n");
+ continue;
+ }
+
+ if( 0 == strcmp (x_item_node->name, "field") )
+ {
+ //node is a field node
+ //get the name of each field
+ //type also ..later
+ field_type = lm_message_node_get_attribute(x_item_node, "type");
+ if( 0 == strcmp (field_type, "hidden") )
+ {
+ //see later if this must be sent while sending request to the server
+ continue;
+ }
+ //get the "type" of the attr as well along with "var"
+ //to send it to the client later
+ //dbus-glib-binding tool support 'g' type
+ field_label = lm_message_node_get_attribute(x_item_node, "label");
+
+ g_message("b4 gettting the search_key_names\n");
+ conn->search_key_names[i] = g_strdup(field_label);
+ g_message("after gettting the search_key_names\n");
+ g_message("%s\n",conn->search_key_names[i]);
+ field_var = lm_message_node_get_attribute(x_item_node, "var");
+ g_hash_table_insert(conn->search_key_ht,g_strdup(field_label),g_strdup(field_var));
+ i++;
+
+ }
+ }
+
+ conn->search_key_names[i] = NULL;
+ // this should be done when we need to give the
+ // search result attributes in advance to the client
+ // and if we are able to give the type also
+
+
+ }
+
+ }
+ else
+ {
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+
+ }
+
+ else if (sub_type == LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ GabbleXmppError xmpp_error = INVALID_XMPP_ERROR;
+
+ result_node = lm_message_node_get_child (message->node, "error");
+ if (result_node)
+ {
+ xmpp_error = gabble_xmpp_error_from_node (result_node);
+ }
+
+ str = gabble_xmpp_error_string (xmpp_error);
+
+ g_warning ("%s: jingle info error: %s", G_STRFUNC,
+ (str) ? str : "unknown error");
+ }
+ else
+ {
+ NODE_DEBUG (message->node, "unknown message sub type");
+ }
+
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/search-mixin-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,112 @@
+/*
+ * search-mixin-signals-marshal.c - Source for GabbleSearchMixinSignalsMarshal
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ * @author Senko Rasic <senko@senko.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+
+/* VOID:UINT,BOXED (search-mixin-signals-marshal.list:11) */
+
+void
+search_mixin_marshal_VOID__UINT_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_BOXED) (gpointer data1,
+ guint arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_BOXED callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_boxed (param_values + 2),
+ data2);
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/search-mixin.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,497 @@
+/*
+ * search-mixin.c - Source for GabbleSearchMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ * @author Senko Rasic <senko@senko.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "loudmouth/loudmouth.h"
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "namespaces.h"
+#include "roster.h"
+#include "util.h"
+
+
+#include "search-mixin.h"
+#include "search-mixin-signals-marshal.h"
+
+
+#include "gabble_enums.h"
+
+#define _GNU_SOURCE /* Needed for strptime (_XOPEN_SOURCE can also be used). */
+
+#define DEBUG_FLAG GABBLE_DEBUG_SEARCH
+
+
+/* allocator */
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark1,gabble_search_mixin,GQuark)
+ #define offset_quark1 (*GET_WSD_VAR_NAME(offset_quark1,gabble_search_mixin, s)())
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark,gabble_search_mixin,GQuark)
+ #define offset_quark (*GET_WSD_VAR_NAME(offset_quark,gabble_search_mixin, s)())
+
+ GET_STATIC_VAR_FROM_TLS(alloc1,gabble_search_mixin,GabbleAllocator)
+ #define alloc1 (*GET_WSD_VAR_NAME(alloc1,gabble_search_mixin, s)())
+
+#endif
+
+/*
+Moved to gabble_enums.h
+typedef struct _GabbleAllocator GabbleAllocator;
+struct _GabbleAllocator
+{
+ gulong size;
+ guint limit;
+ guint count;
+};*/
+
+
+typedef struct _IsKeyValidUserData IsKeyValidUserData;
+
+struct _IsKeyValidUserData
+{
+ GError **error;
+ gchar **search_key_names;
+ gboolean is_key_found;
+};
+
+
+typedef struct _SearchKeyVarUserData SearchKeyVarUserData;
+
+struct _SearchKeyVarUserData
+{
+ LmMessageNode *x_node;
+ GabbleConnection *conn;
+
+};
+
+
+#define ga_new0(alloc, type) \
+ ((type *) gabble_allocator_alloc0 (alloc))
+
+static void
+gabble_allocator_init (GabbleAllocator *alloc, gulong size, guint limit)
+{
+ g_assert (alloc != NULL);
+ g_assert (size > 0);
+ g_assert (limit > 0);
+
+ alloc->size = size;
+ alloc->limit = limit;
+}
+
+static gpointer gabble_allocator_alloc0 (GabbleAllocator *alloc)
+{
+ gpointer ret;
+
+ g_assert (alloc != NULL);
+ g_assert (alloc->count <= alloc->limit);
+
+ if (alloc->count == alloc->limit)
+ {
+ ret = NULL;
+ }
+ else
+ {
+ ret = g_malloc0 (alloc->size);
+ alloc->count++;
+ }
+
+ return ret;
+}
+
+static void gabble_allocator_free (GabbleAllocator *alloc, gpointer thing)
+{
+ g_assert (alloc != NULL);
+ g_assert (thing != NULL);
+
+ g_free (thing);
+ alloc->count--;
+}
+
+
+/**
+ * gabble_search_mixin_class_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObjectClass
+ */
+GQuark
+gabble_search_mixin_class_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark1 = 0;
+#endif
+
+ if (!offset_quark1)
+ offset_quark1 = g_quark_from_static_string("SearchMixinClassOffsetQuark");
+ return offset_quark1;
+}
+
+/**
+ * gabble_search_mixin_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObject
+ */
+GQuark
+gabble_search_mixin_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark = 0;
+#endif
+
+ if (!offset_quark)
+ offset_quark = g_quark_from_static_string("SearchMixinOffsetQuark");
+ return offset_quark;
+}
+
+
+/* GabbleSearchMixin */
+void
+gabble_search_mixin_class_init (GObjectClass *obj_cls, glong offset)
+{
+ GabbleSearchMixinClass *mixin_cls;
+
+ g_assert (G_IS_OBJECT_CLASS (obj_cls));
+
+ g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls),
+ GABBLE_SEARCH_MIXIN_CLASS_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin_cls = GABBLE_SEARCH_MIXIN_CLASS (obj_cls);
+
+
+ mixin_cls->search_result_received_signal_id = g_signal_new ("search-result-received",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ search_mixin_marshal_VOID__UINT_BOXED,
+ G_TYPE_NONE,
+ 2, G_TYPE_UINT, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE ));
+
+ mixin_cls->search_state_changed_signal_id = g_signal_new ("search-state-changed",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT );
+
+}
+
+void
+gabble_search_mixin_init (GObject *obj,
+ glong offset )
+{
+ GabbleSearchMixin *mixin;
+
+ g_assert (G_IS_OBJECT (obj));
+
+ g_type_set_qdata (G_OBJECT_TYPE (obj),
+ GABBLE_SEARCH_MIXIN_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin = GABBLE_SEARCH_MIXIN (obj);
+
+ mixin->search_state = TP_CHANNEL_CONTACT_SEARCH_STATE_BEFORE;
+
+ }
+
+void
+gabble_search_mixin_finalize (GObject *obj)
+{
+ GabbleSearchMixin *mixin = GABBLE_SEARCH_MIXIN (obj);
+ /* free any data held directly by the object here */
+}
+
+static void
+setfield_foreach (gpointer key, gpointer value, gpointer user_data)
+{
+ const gchar *search_data_string = NULL;
+ SearchKeyVarUserData *key_var_struct = (SearchKeyVarUserData*)user_data;
+ LmMessageNode *field_node;
+ const gchar *search_key_var = NULL;
+ GType g_type = G_VALUE_TYPE (value);
+
+ switch (g_type)
+ {
+ case G_TYPE_STRING:
+ search_data_string = g_value_get_string(value);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ search_key_var = (gchar *) g_hash_table_lookup (key_var_struct->conn->search_key_ht,
+ key /*Label*/);
+ field_node = lm_message_node_add_child ( key_var_struct->x_node, "field", NULL );
+ lm_message_node_set_attribute ( field_node, "var", search_key_var );
+ lm_message_node_add_child ( field_node, "value", search_data_string );
+}
+static void
+gabble_search_keynames_are_valid ( gpointer key, gpointer value,
+ gpointer userdata )
+{
+ guint i;
+ const gchar *search_data_string = g_value_get_string(value);
+ IsKeyValidUserData *key_valid_struct = (IsKeyValidUserData*)userdata;
+ gchar **search_key_names = key_valid_struct->search_key_names;
+
+ if( !key_valid_struct->is_key_found )
+ return;
+
+ if( key == NULL )
+ {
+ key_valid_struct->is_key_found = FALSE;
+ return;
+ }
+
+
+ for (i = 0; search_key_names[i]; i++)
+ {
+ if (0 == strcmp (search_key_names[i], key))
+ {
+ g_message("searchkey %s is valid\n",key);
+ if( search_data_string )
+ g_message("value is %s\n",search_data_string);
+ return;
+ }
+ }
+ key_valid_struct->is_key_found = FALSE;
+ g_message("searchkey %s is invalid\n",key);
+ g_set_error ( key_valid_struct->error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid search key found : %s\n", key);
+}
+
+
+/**
+ * gabble_search_mixin_search
+ *
+ * Implements D-Bus method Search
+ * on interface org.freedesktop.Telepathy.Channel.Type.ContactSearch
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean gabble_search_mixin_search (GObject *obj,GHashTable *params,
+ GabbleConnection *conn,
+ GError **error)
+{
+ LmMessage *msg;
+ LmMessageNode *query_node;
+ LmMessageNode *x_node;
+ gboolean result;
+ const gchar *service = NULL;
+ GabbleSearchMixin *mixin = GABBLE_SEARCH_MIXIN (obj);
+ IsKeyValidUserData *user_data = NULL;
+ SearchKeyVarUserData *get_keyvar_userdata = NULL;
+
+
+ if (params == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid argument \n");
+ return FALSE;
+ }
+
+ if ( !g_hash_table_size(params) )
+ {
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid argument, no key-value pair to do search\n");
+ return FALSE;
+ }
+
+ service = conn->search_service_jid;
+
+ if (service == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "Search Service is not available\n");
+ return FALSE;
+ }
+
+ g_message("service is %s\n",service);
+
+ if (conn->search_key_names == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "search key names not available");
+ return FALSE;
+ }
+
+ user_data = g_new0 (IsKeyValidUserData, 1);
+ user_data->is_key_found = TRUE;
+ user_data->error = error;
+ user_data->search_key_names = conn->search_key_names;
+
+ g_hash_table_foreach (params, gabble_search_keynames_are_valid, user_data );
+
+ if(!user_data->is_key_found)
+ {
+ g_free(user_data);
+ g_message("invalid searchkey found\n");
+ return FALSE;
+ }
+
+ g_free(user_data);
+
+ msg= lm_message_new_with_sub_type ( service,
+ LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+ query_node = lm_message_node_add_child (msg->node, "query", NULL);
+
+ lm_message_node_set_attribute (query_node, "xmlns", NS_SEARCH);
+
+ x_node = lm_message_node_add_child ( query_node, "x", NULL );
+
+ lm_message_node_set_attributes (x_node,
+ "xmlns", NS_X_DATA,
+ "type", "submit",
+ NULL);
+
+ get_keyvar_userdata = g_new0 (SearchKeyVarUserData, 1);
+ get_keyvar_userdata->x_node = x_node;
+ get_keyvar_userdata->conn = conn;
+
+ g_hash_table_foreach (params, setfield_foreach, get_keyvar_userdata );
+
+ g_free(get_keyvar_userdata);
+
+ result = _gabble_connection_send (conn, msg, error);
+ lm_message_unref (msg);
+
+ if (!result)
+ return FALSE;
+
+ //this means for each search attempt, a new channel should be created
+ mixin->search_state = TP_CHANNEL_CONTACT_SEARCH_STATE_DURING;
+
+ //send search state changed signal if required
+ _gabble_search_mixin_emit_search_state_changed(obj,mixin->search_state);
+
+ return TRUE;
+}
+
+gboolean gabble_search_mixin_get_search_state ( GObject *obj,
+ guint *ret,
+ GError **error )
+{
+ GabbleSearchMixin *mixin = GABBLE_SEARCH_MIXIN (obj);
+ *ret = mixin->search_state;
+ return TRUE;
+}
+
+
+/**
+ * gabble_search_mixin_get_search_keys
+ *
+ * Implements D-Bus method GetSearchKeys
+ * on interface org.freedesktop.Telepathy.Channel.Type.ContactSearch
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean
+gabble_search_mixin_get_search_keys ( GObject *obj,
+ gchar **ret_instruction,
+ gchar ***ret_searchkeys,
+ GabbleConnection *conn,
+ GError **error
+ )
+{
+ //later this method should be modified to give
+ //types of search keys fields also
+
+ if (conn->search_key_names == NULL)
+ {
+ g_set_error (error, TELEPATHY_ERRORS, NotAvailable,
+ "search keys not available");
+ return FALSE;
+ }
+
+ *ret_searchkeys = g_strdupv ((gchar **) conn->search_key_names);
+ *ret_instruction = g_strdup ( (gchar*)conn->search_instr);
+
+ g_message("conn->search_instr :%s\n",(gchar*)conn->search_instr);
+ g_message("ret_instruction :%s\n",(gchar*)*ret_instruction );
+
+ return TRUE;
+}
+
+
+void
+_gabble_search_mixin_emit_search_result_received (GObject *obj,
+ guint contact_handle,
+ GHashTable *values )
+{
+ GabbleSearchMixinClass *mixin_cls = GABBLE_SEARCH_MIXIN_CLASS (G_OBJECT_GET_CLASS
+ (obj));
+
+ g_signal_emit (obj, mixin_cls->search_result_received_signal_id, 0,
+ contact_handle,
+ values );
+}
+
+void
+_gabble_search_mixin_emit_search_state_changed (GObject *obj,
+ guint search_state )
+{
+ GabbleSearchMixinClass *mixin_cls = GABBLE_SEARCH_MIXIN_CLASS (G_OBJECT_GET_CLASS
+ (obj));
+ g_signal_emit (obj, mixin_cls->search_state_changed_signal_id, 0,
+ search_state );
+}
+
+void
+_gabble_search_mixin_set_search_state (GObject *obj, guint state )
+{
+ GabbleSearchMixin *mixin = GABBLE_SEARCH_MIXIN (obj);
+ mixin->search_state = state;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/sha1.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,649 @@
+/*-
+ * Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: sha1.c 680 2003-07-25 21:57:38Z asaddi $
+ */
+
+/*
+ * Define WORDS_BIGENDIAN if compiling on a big-endian architecture.
+ *
+ * Define SHA1_TEST to test the implementation using the NIST's
+ * sample messages. The output should be:
+ *
+ * a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d
+ * 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1
+ * 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+
+#include <string.h>
+
+
+#include "sha1.h"
+
+#ifndef lint
+static const char rcsid[] =
+ "$Id: sha1.c 680 2003-07-25 21:57:38Z asaddi $";
+#endif /* !lint */
+
+#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
+
+#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+#define F_20_39(x, y, z) ((x) ^ (y) ^ (z))
+#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
+#define F_60_79(x, y, z) ((x) ^ (y) ^ (z))
+
+#define DO_ROUND(F, K) { \
+ temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \
+ e = d; \
+ d = c; \
+ c = ROTL(b, 30); \
+ b = a; \
+ a = temp; \
+}
+
+#define K_0_19 0x5a827999L
+#define K_20_39 0x6ed9eba1L
+#define K_40_59 0x8f1bbcdcL
+#define K_60_79 0xca62c1d6L
+
+#ifndef RUNTIME_ENDIAN
+
+#ifdef WORDS_BIGENDIAN
+
+#define BYTESWAP(x) (x)
+#define BYTESWAP64(x) (x)
+
+#else /* WORDS_BIGENDIAN */
+
+#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
+ (ROTL((x), 8) & 0x00ff00ffL))
+#define BYTESWAP64(x) _byteswap64(x)
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+uint64_t _byteswap64(uint64_t x)
+{
+ uint32_t a = x >> 32;
+ uint32_t b = (uint32_t) x;
+ return ((uint64_t) BYTESWAP(b) << 32) | (uint64_t) BYTESWAP(a);
+}
+
+#endif /* WORDS_BIGENDIAN */
+
+#else /* !RUNTIME_ENDIAN */
+
+#define BYTESWAP(x) _byteswap(sc->littleEndian, x)
+#define BYTESWAP64(x) _byteswap64(sc->littleEndian, x)
+
+#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
+ (ROTL((x), 8) & 0x00ff00ffL))
+#define _BYTESWAP64(x) __byteswap64(x)
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+uint64_t __byteswap64(uint64_t x)
+{
+ uint32_t a = x >> 32;
+ uint32_t b = (uint32_t) x;
+ return ((uint64_t) _BYTESWAP(b) << 32) | (uint64_t) _BYTESWAP(a);
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+uint32_t _byteswap(int littleEndian, uint32_t x)
+{
+ if (!littleEndian)
+ return x;
+ else
+ return _BYTESWAP(x);
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+uint64_t _byteswap64(int littleEndian, uint64_t x)
+{
+ if (!littleEndian)
+ return x;
+ else
+ return _BYTESWAP64(x);
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+void setEndian(int *littleEndianp)
+{
+ union {
+ uint32_t w;
+ uint8_t b[4];
+ } endian;
+
+ endian.w = 1L;
+ *littleEndianp = endian.b[0] != 0;
+}
+
+#endif /* !RUNTIME_ENDIAN */
+
+static const uint8_t padding[64] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+void
+SHA1Init (SHA1Context *sc)
+{
+#ifdef RUNTIME_ENDIAN
+ setEndian (&sc->littleEndian);
+#endif /* RUNTIME_ENDIAN */
+
+ sc->totalLength = 0LL;
+ sc->hash[0] = 0x67452301L;
+ sc->hash[1] = 0xefcdab89L;
+ sc->hash[2] = 0x98badcfeL;
+ sc->hash[3] = 0x10325476L;
+ sc->hash[4] = 0xc3d2e1f0L;
+ sc->bufferLength = 0L;
+}
+
+static void
+burnStack (int size)
+{
+ char buf[128];
+
+ memset (buf, 0, sizeof (buf));
+ size -= sizeof (buf);
+ if (size > 0)
+ burnStack (size);
+}
+
+static void
+SHA1Guts (SHA1Context *sc, const uint32_t *cbuf)
+{
+ uint32_t buf[80];
+ uint32_t *W, *W3, *W8, *W14, *W16;
+ uint32_t a, b, c, d, e, temp;
+ int i;
+
+ W = buf;
+
+ for (i = 15; i >= 0; i--) {
+ *(W++) = BYTESWAP(*cbuf);
+ cbuf++;
+ }
+
+ W16 = &buf[0];
+ W14 = &buf[2];
+ W8 = &buf[8];
+ W3 = &buf[13];
+
+ for (i = 63; i >= 0; i--) {
+ *W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++);
+ *W = ROTL(*W, 1);
+ W++;
+ }
+
+ a = sc->hash[0];
+ b = sc->hash[1];
+ c = sc->hash[2];
+ d = sc->hash[3];
+ e = sc->hash[4];
+
+ W = buf;
+
+#ifndef SHA1_UNROLL
+#define SHA1_UNROLL 20
+#endif /* !SHA1_UNROLL */
+
+#if SHA1_UNROLL == 1
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_0_19, K_0_19);
+
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_20_39, K_20_39);
+
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_40_59, K_40_59);
+
+ for (i = 19; i >= 0; i--)
+ DO_ROUND(F_60_79, K_60_79);
+#elif SHA1_UNROLL == 2
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 9; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 4
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 5
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 3; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 10
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ }
+
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ }
+
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ }
+
+ for (i = 1; i >= 0; i--) {
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ }
+#elif SHA1_UNROLL == 20
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+ DO_ROUND(F_0_19, K_0_19);
+
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+ DO_ROUND(F_20_39, K_20_39);
+
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+ DO_ROUND(F_40_59, K_40_59);
+
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+ DO_ROUND(F_60_79, K_60_79);
+#else /* SHA1_UNROLL */
+#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20!
+#endif
+
+ sc->hash[0] += a;
+ sc->hash[1] += b;
+ sc->hash[2] += c;
+ sc->hash[3] += d;
+ sc->hash[4] += e;
+}
+
+void
+SHA1Update (SHA1Context *sc, const void *vdata, uint32_t len)
+{
+ const uint8_t *data = vdata;
+ uint32_t bufferBytesLeft;
+ uint32_t bytesToCopy;
+ int needBurn = 0;
+
+#ifdef SHA1_FAST_COPY
+ if (sc->bufferLength) {
+ bufferBytesLeft = 64L - sc->bufferLength;
+
+ bytesToCopy = bufferBytesLeft;
+ if (bytesToCopy > len)
+ bytesToCopy = len;
+
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy);
+
+ sc->totalLength += bytesToCopy * 8L;
+
+ sc->bufferLength += bytesToCopy;
+ data += bytesToCopy;
+ len -= bytesToCopy;
+
+ if (sc->bufferLength == 64L) {
+ SHA1Guts (sc, sc->buffer.words);
+ needBurn = 1;
+ sc->bufferLength = 0L;
+ }
+ }
+
+ while (len > 63) {
+ sc->totalLength += 512L;
+
+ SHA1Guts (sc, data);
+ needBurn = 1;
+
+ data += 64L;
+ len -= 64L;
+ }
+
+ if (len) {
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, len);
+
+ sc->totalLength += len * 8L;
+
+ sc->bufferLength += len;
+ }
+#else /* SHA1_FAST_COPY */
+ while (len) {
+ bufferBytesLeft = 64L - sc->bufferLength;
+
+ bytesToCopy = bufferBytesLeft;
+ if (bytesToCopy > len)
+ bytesToCopy = len;
+
+ memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy);
+
+ sc->totalLength += bytesToCopy * 8L;
+
+ sc->bufferLength += bytesToCopy;
+ data += bytesToCopy;
+ len -= bytesToCopy;
+
+ if (sc->bufferLength == 64L) {
+ SHA1Guts (sc, sc->buffer.words);
+ needBurn = 1;
+ sc->bufferLength = 0L;
+ }
+ }
+#endif /* SHA1_FAST_COPY */
+
+ if (needBurn)
+ burnStack (sizeof (uint32_t[86]) + sizeof (uint32_t *[5]) + sizeof (int));
+}
+
+void
+SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE])
+{
+ uint32_t bytesToPad;
+ uint64_t lengthPad;
+ int i;
+
+ bytesToPad = 120L - sc->bufferLength;
+ if (bytesToPad > 64L)
+ bytesToPad -= 64L;
+
+ lengthPad = BYTESWAP64(sc->totalLength);
+
+ SHA1Update (sc, padding, bytesToPad);
+ SHA1Update (sc, &lengthPad, 8L);
+
+ if (hash) {
+ for (i = 0; i < SHA1_HASH_WORDS; i++) {
+#ifdef SHA1_FAST_COPY
+ *((uint32_t *) hash) = BYTESWAP(sc->hash[i]);
+#else /* SHA1_FAST_COPY */
+ hash[0] = (uint8_t) (sc->hash[i] >> 24);
+ hash[1] = (uint8_t) (sc->hash[i] >> 16);
+ hash[2] = (uint8_t) (sc->hash[i] >> 8);
+ hash[3] = (uint8_t) sc->hash[i];
+#endif /* SHA1_FAST_COPY */
+ hash += 4;
+ }
+ }
+}
+
+#ifdef SHA1_TEST
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+ SHA1Context foo;
+ uint8_t hash[SHA1_HASH_SIZE];
+ char buf[1000];
+ int i;
+
+ SHA1Init (&foo);
+ SHA1Update (&foo, "abc", 3);
+ SHA1Final (&foo, hash);
+
+ for (i = 0; i < SHA1_HASH_SIZE;) {
+ printf ("%02x", hash[i++]);
+ if (!(i % 4))
+ printf (" ");
+ }
+ printf ("\n");
+
+ SHA1Init (&foo);
+ SHA1Update (&foo,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ 56);
+ SHA1Final (&foo, hash);
+
+ for (i = 0; i < SHA1_HASH_SIZE;) {
+ printf ("%02x", hash[i++]);
+ if (!(i % 4))
+ printf (" ");
+ }
+ printf ("\n");
+
+ SHA1Init (&foo);
+ memset (buf, 'a', sizeof (buf));
+ for (i = 0; i < 1000; i++)
+ SHA1Update (&foo, buf, sizeof (buf));
+ SHA1Final (&foo, hash);
+
+ for (i = 0; i < SHA1_HASH_SIZE;) {
+ printf ("%02x", hash[i++]);
+ if (!(i % 4))
+ printf (" ");
+ }
+ printf ("\n");
+
+ exit (0);
+}
+
+#endif /* SHA1_TEST */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/telepathy-errors-enumtypes.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,67 @@
+/*
+ * telepathy-errors-enumtypes.c - Source for Gabble service discovery
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * -- LET'S DISCO!!! \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
+ */
+/* Generated data (by glib-mkenums) */
+//vinod: changed system path to local
+#include "telepathy-errors.h"
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(etype,gabble_enum_types,GType)
+ #define etype (*GET_WSD_VAR_NAME(etype,gabble_enum_types,s)())
+
+#endif
+
+/* enumerations from "telepathy-errors.h" */
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GType
+telepathy_errors_get_type (void)
+{
+
+#ifndef EMULATOR
+ static GType etype = 0;
+#endif
+
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { ChannelBanned, "ChannelBanned", "ChannelBanned" },
+ { ChannelFull, "ChannelFull", "ChannelFull" },
+ { ChannelInviteOnly, "ChannelInviteOnly", "ChannelInviteOnly" },
+ { Disconnected, "Disconnected", "Disconnected" },
+ { InvalidArgument, "InvalidArgument", "InvalidArgument" },
+ { InvalidHandle, "InvalidHandle", "InvalidHandle" },
+ { NetworkError, "NetworkError", "NetworkError" },
+ { NotAvailable, "NotAvailable", "NotAvailable" },
+ { NotImplemented, "NotImplemented", "NotImplemented" },
+ { PermissionDenied, "PermissionDenied", "PermissionDenied" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("TelepathyErrors", values);
+ }
+ return etype;
+}
+
+/* Generated data ends here */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/telepathy-errors.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,45 @@
+/*
+ * telepathy-errors.c - Source for D-Bus error types used in telepathy
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib.h>
+#include "telepathy-errors.h"
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(quark,gabble_errors,GQuark)
+ #define quark (*GET_WSD_VAR_NAME(quark,gabble_errors, s)())
+
+#endif
+
+#ifdef SYMBIAN
+EXPORT_C
+#endif
+GQuark
+telepathy_errors_quark (void)
+{
+#ifndef EMULATOR
+ static GQuark quark = 0;
+#endif
+
+ if (!quark)
+ quark = g_quark_from_static_string ("telepathy_errors");
+ return quark;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/telepathy-helpers.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,118 @@
+/*
+ * telepathy-helpers.c - Source for some Telepathy D-Bus helper functions
+ * Copyright (C) 2005 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <dbus/dbus-glib.h>
+#include "telepathy-helpers.h"
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(busCon,gabble_helpers,DBusGConnection*)
+ #define busCon (*GET_WSD_VAR_NAME(busCon,gabble_helpers, s)())
+
+ GET_STATIC_VAR_FROM_TLS(bus_proxy,gabble_helpers,DBusGProxy*)
+ #define bus_proxy (*GET_WSD_VAR_NAME(bus_proxy,gabble_helpers, s)())
+
+#endif
+
+
+DBusGConnection *
+tp_get_bus ()
+{
+#ifndef EMULATOR
+ static DBusGConnection *busCon = NULL;
+#endif
+
+ if (busCon == NULL)
+ {
+ GError *error = NULL;
+
+ busCon = dbus_g_bus_get (DBUS_BUS_SESSION/*DBUS_BUS_STARTER*/, &error);
+
+ if (busCon == NULL)
+ {
+ g_warning ("Failed to connect to starter bus: %s", error->message);
+ exit (1);
+ }
+ }
+
+ return busCon;
+}
+
+DBusGProxy *
+tp_get_bus_proxy ()
+{
+#ifndef EMULATOR
+ static DBusGProxy *bus_proxy = NULL;
+#endif
+
+ if (bus_proxy == NULL)
+ {
+ DBusGConnection *bus = tp_get_bus ();
+
+ bus_proxy = dbus_g_proxy_new_for_name (bus,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ if (bus_proxy == NULL)
+ g_error ("Failed to get proxy object for bus.");
+ }
+
+ return bus_proxy;
+}
+
+static void _list_builder (gpointer key, gpointer value, gpointer data);
+
+GSList *
+tp_hash_to_key_value_list (GHashTable *hash)
+{
+ GSList *ret = NULL;
+
+ g_hash_table_foreach (hash, _list_builder, &ret);
+
+ return ret;
+}
+
+void
+tp_key_value_list_free (GSList *list)
+{
+ GSList *iter;
+
+ for (iter = list; iter; iter = g_slist_next(iter))
+ {
+ g_free (iter->data);
+ }
+
+ g_slist_free (list);
+}
+
+static void _list_builder (gpointer key, gpointer value, gpointer data)
+{
+ GSList **list = (GSList **) data;
+ TpKeyValue *kv = g_new0 (TpKeyValue, 1);
+
+ kv->key = key;
+ kv->value = value;
+
+ *list = g_slist_prepend (*list, kv);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/text-mixin-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,191 @@
+/*
+ * text-mixin-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:UINT,UINT,UINT,UINT,UINT,STRING (text-mixin-signals-marshal.list:1) */
+void
+text_mixin_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT_UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ guint arg_4,
+ guint arg_5,
+ gpointer arg_6,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT_UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 7);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT_UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_uint (param_values + 4),
+ g_marshal_value_peek_uint (param_values + 5),
+ g_marshal_value_peek_string (param_values + 6),
+ data2);
+}
+
+/* VOID:UINT,UINT,UINT,STRING (text-mixin-signals-marshal.list:2) */
+void
+text_mixin_marshal_VOID__UINT_UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ guint arg_3,
+ gpointer arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_uint (param_values + 3),
+ g_marshal_value_peek_string (param_values + 4),
+ data2);
+}
+
+/* VOID:UINT,UINT,STRING (text-mixin-signals-marshal.list:3) */
+void
+text_mixin_marshal_VOID__UINT_UINT_STRING (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT_STRING) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT_STRING callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 4);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__UINT_UINT_STRING) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ g_marshal_value_peek_string (param_values + 3),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/text-mixin.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,819 @@
+/*
+ * text-mixin.c - Source for GabbleTextMixin
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Ole Andre Vadla Ravnaas <ole.andre.ravnaas@collabora.co.uk>
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ * @author Senko Rasic <senko@senko.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "loudmouth/loudmouth.h"
+#include <dbus/dbus-glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "telepathy-constants.h"
+#include "telepathy-errors.h"
+
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "namespaces.h"
+#include "roster.h"
+#include "util.h"
+
+#include "text-mixin.h"
+#include "text-mixin-signals-marshal.h"
+
+#include "gabble_enums.h"
+
+#define _GNU_SOURCE /* Needed for strptime (_XOPEN_SOURCE can also be used). */
+#define DEBUG_FLAG GABBLE_DEBUG_IM
+#define TP_TYPE_PENDING_MESSAGE_STRUCT (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_INVALID))
+
+/* allocator */
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark1,gabble_txt_mixin,GQuark)
+ #define offset_quark1 (*GET_WSD_VAR_NAME(offset_quark1,gabble_txt_mixin, s)())
+
+ GET_STATIC_VAR_FROM_TLS(offset_quark,gabble_txt_mixin,GQuark)
+ #define offset_quark (*GET_WSD_VAR_NAME(offset_quark,gabble_txt_mixin, s)())
+
+ GET_STATIC_VAR_FROM_TLS(alloc1,gabble_txt_mixin,GabbleAllocator)
+ #define alloc1 (*GET_WSD_VAR_NAME(alloc1,gabble_txt_mixin, s)())
+
+#endif
+
+/*
+Moved to gabble_enums.h
+typedef struct _GabbleAllocator GabbleAllocator;
+struct _GabbleAllocator
+{
+ gulong size;
+ guint limit;
+ guint count;
+};*/
+
+
+
+#define ga_new0(alloc, type) \
+ ((type *) gabble_allocator_alloc0 (alloc))
+
+static void
+gabble_allocator_init (GabbleAllocator *alloc, gulong size, guint limit)
+{
+ g_assert (alloc != NULL);
+ g_assert (size > 0);
+ g_assert (limit > 0);
+
+ alloc->size = size;
+ alloc->limit = limit;
+}
+
+static gpointer gabble_allocator_alloc0 (GabbleAllocator *alloc)
+{
+ gpointer ret;
+
+ g_assert (alloc != NULL);
+ g_assert (alloc->count <= alloc->limit);
+
+ if (alloc->count == alloc->limit)
+ {
+ ret = NULL;
+ }
+ else
+ {
+ ret = g_malloc0 (alloc->size);
+ alloc->count++;
+ }
+
+ return ret;
+}
+
+static void gabble_allocator_free (GabbleAllocator *alloc, gpointer thing)
+{
+ g_assert (alloc != NULL);
+ g_assert (thing != NULL);
+
+ g_free (thing);
+ alloc->count--;
+}
+
+/* pending message */
+#define MAX_PENDING_MESSAGES 256
+#define MAX_MESSAGE_SIZE 1024 - 1
+
+typedef struct _GabblePendingMessage GabblePendingMessage;
+struct _GabblePendingMessage
+{
+ guint id;
+ time_t timestamp;
+ GabbleHandle sender;
+ TpChannelTextMessageType type;
+ char *text;
+ guint flags;
+};
+
+/**
+ * gabble_text_mixin_class_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObjectClass
+ */
+GQuark
+gabble_text_mixin_class_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark1 = 0;
+#endif
+
+ if (!offset_quark1)
+ offset_quark1 = g_quark_from_static_string("TextMixinClassOffsetQuark");
+ return offset_quark1;
+}
+
+/**
+ * gabble_text_mixin_get_offset_quark:
+ *
+ * Returns: the quark used for storing mixin offset on a GObject
+ */
+GQuark
+gabble_text_mixin_get_offset_quark ()
+{
+#ifndef EMULATOR
+ static GQuark offset_quark = 0;
+#endif
+
+ if (!offset_quark)
+ offset_quark = g_quark_from_static_string("TextMixinOffsetQuark");
+ return offset_quark;
+}
+
+
+/* GabbleTextMixin */
+void
+gabble_text_mixin_class_init (GObjectClass *obj_cls, glong offset)
+{
+ GabbleTextMixinClass *mixin_cls;
+
+ g_assert (G_IS_OBJECT_CLASS (obj_cls));
+
+ g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls),
+ GABBLE_TEXT_MIXIN_CLASS_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin_cls = GABBLE_TEXT_MIXIN_CLASS (obj_cls);
+
+ mixin_cls->lost_message_signal_id = g_signal_new ("lost-message",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ mixin_cls->received_signal_id = g_signal_new ("received",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ text_mixin_marshal_VOID__UINT_UINT_UINT_UINT_UINT_STRING,
+ G_TYPE_NONE, 6, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
+
+ mixin_cls->send_error_signal_id = g_signal_new ("send-error",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ text_mixin_marshal_VOID__UINT_UINT_UINT_STRING,
+ G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
+
+ mixin_cls->sent_signal_id = g_signal_new ("sent",
+ G_OBJECT_CLASS_TYPE (obj_cls),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ text_mixin_marshal_VOID__UINT_UINT_STRING,
+ G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
+}
+
+void
+gabble_text_mixin_init (GObject *obj,
+ glong offset,
+ GabbleHandleRepo *handle_repo,
+ gboolean send_nick)
+{
+ GabbleTextMixin *mixin;
+
+ g_assert (G_IS_OBJECT (obj));
+
+ g_type_set_qdata (G_OBJECT_TYPE (obj),
+ GABBLE_TEXT_MIXIN_OFFSET_QUARK,
+ GINT_TO_POINTER (offset));
+
+ mixin = GABBLE_TEXT_MIXIN (obj);
+
+ mixin->pending = g_queue_new ();
+ mixin->handle_repo = handle_repo;
+ mixin->recv_id = 0;
+ mixin->msg_types = g_array_sized_new (FALSE, FALSE, sizeof (guint), 4);
+
+ mixin->message_lost = FALSE;
+}
+
+void
+gabble_text_mixin_set_message_types (GObject *obj,
+ ...)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ va_list args;
+ guint type;
+
+ va_start (args, obj);
+
+ while ((type = va_arg (args, guint)) != G_MAXUINT)
+ g_array_append_val (mixin->msg_types, type);
+
+ va_end (args);
+}
+
+static void _gabble_pending_free (GabblePendingMessage *msg);
+static GabbleAllocator * _gabble_pending_get_alloc ();
+
+void
+gabble_text_mixin_finalize (GObject *obj)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ GabblePendingMessage *msg;
+
+ /* free any data held directly by the object here */
+
+ msg = g_queue_pop_head(mixin->pending);
+ while (msg)
+ {
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender);
+ _gabble_pending_free (msg);
+ msg = g_queue_pop_head(mixin->pending);
+ }
+
+ g_queue_free (mixin->pending);
+
+ g_array_free (mixin->msg_types, TRUE);
+}
+
+/**
+ * _gabble_pending_get_alloc
+ *
+ * Returns a GabbleAllocator for creating up to 256 pending messages, but no
+ * more.
+ */
+static GabbleAllocator *
+_gabble_pending_get_alloc ()
+{
+
+#ifndef EMULATOR
+ static GabbleAllocator alloc1 = { 0, };
+#endif
+
+ if (0 == alloc1.size)
+ gabble_allocator_init (&alloc1, sizeof(GabblePendingMessage), MAX_PENDING_MESSAGES);
+
+ return &alloc1;
+}
+
+#define _gabble_pending_new0() \
+ (ga_new0 (_gabble_pending_get_alloc (), GabblePendingMessage))
+
+/**
+ * _gabble_pending_free
+ *
+ * Free up a GabblePendingMessage struct.
+ */
+static void _gabble_pending_free (GabblePendingMessage *msg)
+{
+ g_free (msg->text);
+ gabble_allocator_free (_gabble_pending_get_alloc (), msg);
+}
+
+/**
+ * _gabble_text_mixin_receive
+ *
+ */
+gboolean gabble_text_mixin_receive (GObject *obj,
+ TpChannelTextMessageType type,
+ GabbleHandle sender,
+ time_t timestamp,
+ const char *text)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ GabbleTextMixinClass *mixin_cls = GABBLE_TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+
+ gchar *end;
+ GabblePendingMessage *msg;
+ gsize len;
+
+ msg = _gabble_pending_new0 ();
+
+ if (msg == NULL)
+ {
+ gabble_debug (DEBUG_FLAG, "no more pending messages available, giving up");
+
+ if (!mixin->message_lost)
+ {
+ g_signal_emit (obj, mixin_cls->lost_message_signal_id, 0);
+ mixin->message_lost = TRUE;
+ }
+
+ return FALSE;
+ }
+
+ len = strlen (text);
+
+ if (len > MAX_MESSAGE_SIZE)
+ {
+ gabble_debug (DEBUG_FLAG, "message exceeds maximum size, truncating");
+
+ msg->flags |= TP_CHANNEL_TEXT_MESSAGE_FLAG_TRUNCATED;
+
+ end = g_utf8_find_prev_char (text, text+MAX_MESSAGE_SIZE);
+ if (end)
+ len = end-text;
+ else
+ len = 0;
+ }
+
+ msg->text = g_try_malloc (len + 1);
+
+ if (msg->text == NULL)
+ {
+ gabble_debug (DEBUG_FLAG, "unable to allocate message, giving up");
+
+ if (!mixin->message_lost)
+ {
+ g_signal_emit (obj, mixin_cls->lost_message_signal_id, 0);
+ mixin->message_lost = TRUE;
+ }
+
+ _gabble_pending_free (msg);
+
+ return FALSE;
+ }
+
+ g_strlcpy (msg->text, text, len + 1);
+
+ msg->id = mixin->recv_id++;
+ msg->timestamp = timestamp;
+ msg->sender = sender;
+ msg->type = type;
+
+ gabble_handle_ref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender);
+ g_queue_push_tail (mixin->pending, msg);
+
+ g_signal_emit (obj, mixin_cls->received_signal_id, 0,
+ msg->id,
+ msg->timestamp,
+ msg->sender,
+ msg->type,
+ msg->flags,
+ msg->text);
+
+ gabble_debug (DEBUG_FLAG, "queued message %u", msg->id);
+
+ mixin->message_lost = FALSE;
+
+ return TRUE;
+}
+
+static gint
+compare_pending_message (gconstpointer haystack,
+ gconstpointer needle)
+{
+ GabblePendingMessage *msg = (GabblePendingMessage *) haystack;
+ guint id = GPOINTER_TO_INT (needle);
+
+ return (msg->id != id);
+}
+
+/**
+ * gabble_text_mixin_acknowledge_pending_messages
+ *
+ * Implements D-Bus method AcknowledgePendingMessages
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean gabble_text_mixin_acknowledge_pending_messages (GObject *obj, const GArray * ids, GError **error)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ GList **nodes;
+ GabblePendingMessage *msg;
+ guint i;
+
+ nodes = g_new(GList *, ids->len);
+
+ for (i = 0; i < ids->len; i++)
+ {
+ guint id = g_array_index(ids, guint, i);
+
+ nodes[i] = g_queue_find_custom (mixin->pending,
+ GINT_TO_POINTER (id),
+ compare_pending_message);
+
+ if (nodes[i] == NULL)
+ {
+ gabble_debug (DEBUG_FLAG, "invalid message id %u", id);
+
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid message id %u", id);
+
+ g_free(nodes);
+ return FALSE;
+ }
+ }
+
+ for (i = 0; i < ids->len; i++)
+ {
+ msg = (GabblePendingMessage *) nodes[i]->data;
+
+ gabble_debug (DEBUG_FLAG, "acknowleding message id %u", msg->id);
+
+ g_queue_remove (mixin->pending, msg);
+
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender);
+ _gabble_pending_free (msg);
+ }
+
+ g_free(nodes);
+ return TRUE;
+}
+
+/**
+ * gabble_text_mixin_list_pending_messages
+ *
+ * Implements D-Bus method ListPendingMessages
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean gabble_text_mixin_list_pending_messages (GObject *obj, gboolean clear, GPtrArray ** ret, GError **error)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ guint count;
+ GPtrArray *messages;
+ GList *cur;
+
+ count = g_queue_get_length (mixin->pending);
+ messages = g_ptr_array_sized_new (count);
+
+ for (cur = (clear ? g_queue_pop_head_link(mixin->pending)
+ : g_queue_peek_head_link(mixin->pending));
+ cur != NULL;
+ cur = (clear ? g_queue_pop_head_link(mixin->pending)
+ : cur->next))
+ {
+ GabblePendingMessage *msg = (GabblePendingMessage *) cur->data;
+ GValue val = { 0, };
+
+ g_value_init (&val, TP_TYPE_PENDING_MESSAGE_STRUCT);
+ g_value_take_boxed (&val,
+ dbus_g_type_specialized_construct (TP_TYPE_PENDING_MESSAGE_STRUCT));
+ dbus_g_type_struct_set (&val,
+ 0, msg->id,
+ 1, msg->timestamp,
+ 2, msg->sender,
+ 3, msg->type,
+ 4, msg->flags,
+ 5, msg->text,
+ G_MAXUINT);
+
+ g_ptr_array_add (messages, g_value_get_boxed (&val));
+ }
+
+ *ret = messages;
+
+ return TRUE;
+}
+
+/**
+ * gabble_text_mixin_send
+ *
+ * Implements D-Bus method Send
+ * on interface org.freedesktop.Telepathy.Channel.Type.Text
+ *
+ * @error: Used to return a pointer to a GError detailing any error
+ * that occurred, D-Bus will throw the error only if this
+ * function returns false.
+ *
+ * Returns: TRUE if successful, FALSE if an error was thrown.
+ */
+gboolean gabble_text_mixin_send (GObject *obj, guint type, guint subtype,
+ const char *recipient, const gchar *text,
+ GabbleConnection *conn, gboolean emit_signal,
+ GError **error)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ LmMessage *msg;
+ gboolean result;
+ time_t timestamp;
+
+ if (type > TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE)
+ {
+ gabble_debug (DEBUG_FLAG, "invalid message type %u", type);
+
+ g_set_error (error, TELEPATHY_ERRORS, InvalidArgument,
+ "invalid message type: %u", type);
+
+ return FALSE;
+ }
+
+ if (!subtype)
+ {
+ switch (type)
+ {
+ case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
+ case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION:
+ subtype = LM_MESSAGE_SUB_TYPE_CHAT;
+ break;
+ case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE:
+ subtype = LM_MESSAGE_SUB_TYPE_NORMAL;
+ break;
+ }
+ }
+
+ msg = lm_message_new_with_sub_type (recipient, LM_MESSAGE_TYPE_MESSAGE, subtype);
+
+ if (mixin->send_nick)
+ {
+ lm_message_node_add_own_nick (msg->node, conn);
+ mixin->send_nick = FALSE;
+ }
+
+ if (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION)
+ {
+ gchar *tmp;
+ tmp = g_strconcat ("/me ", text, NULL);
+ lm_message_node_add_child (msg->node, "body", tmp);
+ g_free (tmp);
+ }
+ else
+ {
+ lm_message_node_add_child (msg->node, "body", text);
+ }
+
+ result = _gabble_connection_send (conn, msg, error);
+ lm_message_unref (msg);
+
+ if (!result)
+ return FALSE;
+
+ if (emit_signal)
+ {
+ timestamp = time (NULL);
+
+ gabble_text_mixin_emit_sent (obj, timestamp, type, text);
+ }
+
+ return TRUE;
+}
+
+void
+gabble_text_mixin_emit_sent (GObject *obj,
+ time_t timestamp,
+ guint type,
+ const char *text)
+{
+ GabbleTextMixinClass *mixin_cls = GABBLE_TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS
+ (obj));
+
+ g_signal_emit (obj, mixin_cls->sent_signal_id, 0,
+ timestamp,
+ type,
+ text);
+}
+
+gboolean
+gabble_text_mixin_get_message_types (GObject *obj, GArray **ret, GError **error)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ guint i;
+
+ *ret = g_array_sized_new (FALSE, FALSE, sizeof (guint),
+ mixin->msg_types->len);
+
+ for (i = 0; i < mixin->msg_types->len; i++)
+ {
+ g_array_append_val (*ret, g_array_index (mixin->msg_types, guint, i));
+ }
+
+ return TRUE;
+}
+
+
+void
+gabble_text_mixin_clear (GObject *obj)
+{
+ GabbleTextMixin *mixin = GABBLE_TEXT_MIXIN (obj);
+ GabblePendingMessage *msg;
+
+ msg = g_queue_pop_head(mixin->pending);
+ while (msg)
+ {
+ gabble_handle_unref (mixin->handle_repo, TP_HANDLE_TYPE_CONTACT, msg->sender);
+ _gabble_pending_free (msg);
+ msg = g_queue_pop_head(mixin->pending);
+ }
+}
+
+gboolean
+gabble_text_mixin_parse_incoming_message (LmMessage *message,
+ const gchar **from,
+ time_t *stamp,
+ TpChannelTextMessageType *msgtype,
+ const gchar **body,
+ const gchar **body_offset,
+ GabbleTextMixinSendError *send_error)
+{
+ const gchar *type;
+ LmMessageNode *node;
+
+ *send_error = CHANNEL_TEXT_SEND_NO_ERROR;
+
+ if (lm_message_get_sub_type (message) == LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ LmMessageNode *error_node;
+
+ error_node = lm_message_node_get_child (message->node, "error");
+ if (error_node)
+ {
+ GabbleXmppError err = gabble_xmpp_error_from_node (error_node);
+ gabble_debug (DEBUG_FLAG, "got xmpp error: %s: %s", gabble_xmpp_error_string (err),
+ gabble_xmpp_error_description (err));
+
+ /* these are based on descriptions of errors, and some testing */
+ switch (err)
+ {
+ case XMPP_ERROR_SERVICE_UNAVAILABLE:
+ case XMPP_ERROR_RECIPIENT_UNAVAILABLE:
+ *send_error = CHANNEL_TEXT_SEND_ERROR_OFFLINE;
+ break;
+
+ case XMPP_ERROR_ITEM_NOT_FOUND:
+ case XMPP_ERROR_JID_MALFORMED:
+ case XMPP_ERROR_REMOTE_SERVER_TIMEOUT:
+ *send_error = CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT;
+ break;
+
+ case XMPP_ERROR_FORBIDDEN:
+ *send_error = CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED;
+ break;
+
+ case XMPP_ERROR_RESOURCE_CONSTRAINT:
+ *send_error = CHANNEL_TEXT_SEND_ERROR_TOO_LONG;
+ break;
+
+ case XMPP_ERROR_FEATURE_NOT_IMPLEMENTED:
+ *send_error = CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED;
+ break;
+
+ default:
+ *send_error = CHANNEL_TEXT_SEND_ERROR_UNKNOWN;
+ }
+ }
+ else
+ {
+ *send_error = CHANNEL_TEXT_SEND_ERROR_UNKNOWN;
+ }
+ }
+
+ *from = lm_message_node_get_attribute (message->node, "from");
+ if (*from == NULL)
+ {
+ NODE_DEBUG (message->node, "got a message without a from field");
+ return FALSE;
+ }
+
+ type = lm_message_node_get_attribute (message->node, "type");
+
+ /*
+ * Parse timestamp of delayed messages. For non-delayed, it's
+ * 0 and the channel code should set the current timestamp.
+ */
+ *stamp = 0;
+
+ node = lm_message_node_get_child_with_namespace (message->node, "x",
+ NS_X_DELAY);
+ if (node != NULL)
+ {
+ const gchar *stamp_str, *p;
+ struct tm stamp_tm = { 0, };
+
+ stamp_str = lm_message_node_get_attribute (node, "stamp");
+ if (stamp_str != NULL)
+ {
+ p = strptime (stamp_str, "%Y%m%dT%T", &stamp_tm);
+ if (p == NULL || *p != '\0')
+ {
+ g_warning ("%s: malformed date string '%s' for jabber:x:delay",
+ G_STRFUNC, stamp_str);
+ }
+ else
+ {
+ *stamp = 0; // bsr timegm (&stamp_tm);
+ }
+ }
+ }
+
+ /*
+ * Parse body if it exists.
+ */
+ node = lm_message_node_get_child (message->node, "body");
+
+ if (node)
+ {
+ *body = lm_message_node_get_value (node);
+ }
+ else
+ {
+ *body = NULL;
+ }
+
+ /* Messages starting with /me are ACTION messages, and the /me should be
+ * removed. type="chat" messages are NORMAL. everything else is
+ * something that doesn't necessarily expect a reply or ongoing
+ * conversation ("normal") or has been auto-sent, so we make it NOTICE in
+ * all other cases. */
+
+ *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE;
+ *body_offset = *body;
+
+ if (*body)
+ {
+ if (0 == strncmp (*body, "/me ", 4))
+ {
+ *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION;
+ *body_offset = *body + 4;
+ }
+ else if (type != NULL && (0 == strcmp (type, "chat") ||
+ 0 == strcmp (type, "groupchat")))
+ {
+ *msgtype = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
+ *body_offset = *body;
+ }
+ }
+
+ return TRUE;
+}
+
+void
+_gabble_text_mixin_send_error_signal (GObject *obj,
+ GabbleTextMixinSendError error,
+ time_t timestamp,
+ TpChannelTextMessageType type,
+ const gchar *text)
+{
+ GabbleTextMixinClass *mixin_cls = GABBLE_TEXT_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
+
+ g_signal_emit (obj, mixin_cls->send_error_signal_id, 0, error, timestamp, type, text, 0);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/tp-channel-factory-iface-signals-marshal.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,103 @@
+/*
+ * tp-channel-factory-iface-signals-marshal.c
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:OBJECT,POINTER (tp-channel-factory-iface-signals-marshal.list:1) */
+void
+tp_channel_factory_iface_marshal_VOID__OBJECT_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__OBJECT_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__OBJECT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_object (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/tp-channel-factory-iface.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,138 @@
+/*
+ * tp-channel-factory-iface.c - Stubs for Telepathy Channel Factory interface
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib-object.h>
+
+#include "tp-channel-factory-iface.h"
+#include "tp-channel-factory-iface-signals-marshal.h"
+#include "tp-channel-iface.h"
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(initialized,gabble_fac_iface,gboolean)
+ #define initialized (*GET_WSD_VAR_NAME(initialized,gabble_fac_iface, s)())
+
+ GET_STATIC_VAR_FROM_TLS(type,gabble_fac_iface,GType)
+ #define type (*GET_WSD_VAR_NAME(type,gabble_fac_iface, s)())
+
+#endif
+
+
+static void
+tp_channel_factory_iface_base_init (gpointer klass)
+{
+#ifndef EMULATOR
+ static gboolean initialized = FALSE;
+#endif
+
+ if (!initialized) {
+ initialized = TRUE;
+
+ g_signal_new ("new-channel",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+ g_signal_new ("channel-error",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ tp_channel_factory_iface_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_POINTER);
+ }
+}
+
+GType
+tp_channel_factory_iface_get_type (void)
+{
+
+#ifndef EMULATOR
+ static GType type = 0;
+#endif
+
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (TpChannelFactoryIfaceClass),
+ tp_channel_factory_iface_base_init, /* base_init */
+ NULL, /* base_finalize */
+ NULL, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL /* instance_init */
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE, "TpChannelFactoryIface", &info, 0);
+ }
+
+ return type;
+}
+
+void
+tp_channel_factory_iface_close_all (TpChannelFactoryIface *self)
+{
+ TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->close_all (self);
+}
+
+void
+tp_channel_factory_iface_connecting (TpChannelFactoryIface *self)
+{
+ TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->connecting (self);
+}
+
+void
+tp_channel_factory_iface_connected (TpChannelFactoryIface *self)
+{
+ TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->connected (self);
+}
+
+void
+tp_channel_factory_iface_disconnected (TpChannelFactoryIface *self)
+{
+ TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->disconnected (self);
+}
+
+void
+tp_channel_factory_iface_foreach (TpChannelFactoryIface *self,
+ TpChannelFunc func,
+ gpointer data)
+{
+ TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->foreach (self, func, data);
+}
+
+TpChannelFactoryRequestStatus
+tp_channel_factory_iface_request (TpChannelFactoryIface *self,
+ const gchar *chan_type,
+ TpHandleType handle_type,
+ guint handle,
+ TpChannelIface **ret,
+ GError **error)
+{
+ return (TP_CHANNEL_FACTORY_IFACE_GET_CLASS (self)->request (self, chan_type,
+ handle_type, handle, ret, error));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/tp-channel-iface.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,115 @@
+/*
+ * tp-channel-iface.c - Stubs for Telepathy Channel interface
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "tp-channel-iface.h"
+
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_VAR_FROM_TLS(type,gabble_chnl_iface,GType)
+ #define type (*GET_WSD_VAR_NAME(type,gabble_chnl_iface, s)())
+
+ GET_STATIC_VAR_FROM_TLS(initialized,gabble_chnl_iface,gboolean)
+ #define initialized (*GET_WSD_VAR_NAME(initialized,gabble_chnl_iface, s)())
+
+#endif
+
+static void
+tp_channel_iface_base_init (gpointer klass)
+{
+#ifndef EMULATOR
+ static gboolean initialized = FALSE;
+#endif
+
+ if (!initialized) {
+ GParamSpec *param_spec;
+
+ initialized = TRUE;
+
+ param_spec = g_param_spec_string ("object-path", "D-Bus object path",
+ "The D-Bus object path used for this "
+ "object on the bus.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_interface_install_property (klass, param_spec);
+
+ param_spec = g_param_spec_string ("channel-type", "Telepathy channel type",
+ "The D-Bus interface representing the "
+ "type of this channel.",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_interface_install_property (klass, param_spec);
+
+ param_spec = g_param_spec_uint ("handle-type", "Contact handle type",
+ "The TpHandleType representing a "
+ "contact handle.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_interface_install_property (klass, param_spec);
+
+ param_spec = g_param_spec_uint ("handle", "Contact handle",
+ "The GabbleHandle representing the contact "
+ "with whom this channel communicates.",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_interface_install_property (klass, param_spec);
+ }
+}
+
+
+GType
+tp_channel_iface_get_type (void)
+{
+
+#ifndef EMULATOR
+ static GType type = 0;
+#endif
+
+
+ if (type == 0) {
+ static const GTypeInfo info = {
+ sizeof (TpChannelIfaceClass),
+ tp_channel_iface_base_init, /* base_init */
+ NULL, /* base_finalize */
+ NULL, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL /* instance_init */
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE, "TpChannelIface", &info, 0);
+ }
+
+ return type;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/util.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,267 @@
+/*
+ * util.c - Source for Gabble utility functions
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * @author Robert McQueen <robert.mcqueen@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#include "namespaces.h"
+#include "gabble-connection.h"
+
+#include "util.h"
+#include "sha1.h"
+
+gchar *
+sha1_hex (const gchar *bytes, guint len)
+{
+ SHA1Context sc;
+ uint8_t hash[SHA1_HASH_SIZE];
+ gchar *hex_hash = g_malloc (SHA1_HASH_SIZE*2 + 1);
+ int i;
+
+ SHA1Init (&sc);
+ SHA1Update (&sc, bytes, len);
+ SHA1Final (&sc, hash);
+
+ for (i = 0; i < SHA1_HASH_SIZE; i++)
+ {
+ sprintf (hex_hash + 2 * i, "%02x", (unsigned int) hash[i]);
+ }
+
+ return hex_hash;
+}
+
+gboolean
+g_strdiff (const gchar *left, const gchar *right)
+{
+ if ((NULL == left) != (NULL == right))
+ return TRUE;
+
+ else if (left == right)
+ return FALSE;
+
+ else
+ return (0 != strcmp (left, right));
+}
+
+static void
+lm_message_node_add_nick (LmMessageNode *node, const gchar *nick)
+{
+ LmMessageNode *nick_node;
+
+ nick_node = lm_message_node_add_child (node, "nick", nick);
+ lm_message_node_set_attribute (nick_node, "xmlns", NS_NICK);
+}
+
+void
+lm_message_node_add_own_nick (LmMessageNode *node,
+ GabbleConnection *connection)
+{
+ gchar *nick;
+ GabbleConnectionAliasSource source;
+
+ source = _gabble_connection_get_cached_alias (connection,
+ connection->self_handle, &nick);
+
+ if (source > GABBLE_CONNECTION_ALIAS_FROM_JID)
+ lm_message_node_add_nick (node, nick);
+
+ g_free (nick);
+}
+
+void
+lm_message_node_steal_children (LmMessageNode *snatcher,
+ LmMessageNode *mum)
+{
+ LmMessageNode *baby;
+
+ g_return_if_fail (snatcher->children == NULL);
+
+ if (mum->children == NULL)
+ return;
+
+ snatcher->children = mum->children;
+ mum->children = NULL;
+
+ for (baby = snatcher->children;
+ baby != NULL;
+ baby = baby->next)
+ baby->parent = snatcher;
+}
+
+gboolean
+lm_message_node_has_namespace (LmMessageNode *node,
+ const gchar *ns,
+ const gchar *tag)
+{
+ gchar *attribute = NULL;
+ const gchar *node_ns;
+ gboolean ret;
+
+ if (tag != NULL)
+ attribute = g_strconcat ("xmlns:", tag, NULL);
+
+ node_ns = lm_message_node_get_attribute (node,
+ tag != NULL ? attribute : "xmlns");
+
+ ret = !g_strdiff (node_ns, ns);
+
+ g_free (attribute);
+
+ return ret;
+}
+
+LmMessageNode *
+lm_message_node_get_child_with_namespace (LmMessageNode *node,
+ const gchar *name,
+ const gchar *ns)
+{
+ LmMessageNode *tmp;
+
+ for (tmp = node->children;
+ tmp != NULL;
+ tmp = tmp->next)
+ {
+ gchar *tag = NULL;
+ gboolean found;
+
+ if (g_strdiff (tmp->name, name))
+ {
+ const gchar *suffix;
+
+ suffix = strchr (tmp->name, ':');
+
+ if (suffix == NULL)
+ continue;
+ else
+ suffix++;
+
+ if (g_strdiff (suffix, name))
+ continue;
+
+ tag = g_strndup (tmp->name, suffix - tmp->name - 1);
+ }
+
+ found = lm_message_node_has_namespace (tmp, ns, tag);
+
+ g_free (tag);
+
+ if (found)
+ return tmp;
+ }
+
+ return NULL;
+}
+
+/**
+ * gabble_decode_jid
+ *
+ * Parses a JID which may be one of the following forms:
+ * server
+ * server/resource
+ * username@server
+ * username@server/resource
+ * room@service/nick
+ * and sets the caller's username_room, server_service and resource_nick
+ * pointers to the username/room, server/service and resource/nick parts
+ * respectively, if available in the provided JID. The caller may set any of
+ * the pointers to NULL if they are not interested in a certain component.
+ *
+ * The returned values may be NULL or zero-length if a component was either
+ * not present or zero-length respectively in the given JID. The username/room
+ * and server/service are lower-cased because the Jabber protocol treats them
+ * case-insensitively.
+ */
+void
+gabble_decode_jid (const gchar *jid,
+ gchar **username_room,
+ gchar **server_service,
+ gchar **resource_nick)
+{
+ char *tmp_jid, *tmp_username, *tmp_server, *tmp_resource;
+
+ g_assert (jid != NULL);
+ g_assert (*jid != '\0');
+
+ if (username_room != NULL)
+ *username_room = NULL;
+
+ if (server_service != NULL)
+ *server_service = NULL;
+
+ if (resource_nick != NULL)
+ *resource_nick = NULL;
+
+ /* take a local copy so we don't modify the caller's string */
+ tmp_jid = g_strdup (jid);
+
+ /* find an @ in username, truncate username to that length, and point
+ * 'server' to the byte afterwards */
+ tmp_server = strchr (tmp_jid, '@');
+ if (tmp_server)
+ {
+ tmp_username = tmp_jid;
+
+ *tmp_server = '\0';
+ tmp_server++;
+
+ /* store the username if the user provided a pointer */
+ if (username_room != NULL)
+ *username_room = g_utf8_strdown (tmp_username, -1);
+ }
+ else
+ {
+ tmp_username = NULL;
+ tmp_server = tmp_jid;
+ }
+
+ /* if we have a server, find a / in it, truncate it to that length, and point
+ * 'resource' to the byte afterwards. otherwise, do the same to username to
+ * find any resource there. */
+ tmp_resource = strchr (tmp_server, '/');
+ if (tmp_resource)
+ {
+ *tmp_resource = '\0';
+ tmp_resource++;
+
+ /* store the resource if the user provided a pointer */
+ if (resource_nick != NULL)
+ *resource_nick = g_strdup (tmp_resource);
+ }
+
+ /* the server must be stored after the resource, in case we truncated a
+ * resource from it */
+ if (server_service != NULL)
+ *server_service = g_utf8_strdown (tmp_server, -1);
+
+ /* free our working copy */
+ g_free (tmp_jid);
+}
+
+/* extend a pointer by an offset, provided the offset is not 0 */
+gpointer
+gabble_mixin_offset_cast (gpointer instance,
+ guint offset)
+{
+ g_return_val_if_fail (offset != 0, NULL);
+
+ return ((guchar *) instance + offset);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/vcard-manager.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,956 @@
+/*
+ * vcard-manager.c - Source for Gabble vCard lookup helper
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "debug.h"
+#include "gabble-connection.h"
+#include "namespaces.h"
+#include "telepathy-helpers.h"
+#include "util.h"
+#include "vcard-manager.h"
+
+#include "gabble_enums.h"
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#define DEBUG_FLAG GABBLE_DEBUG_VCARD
+#define DEFAULT_REQUEST_TIMEOUT 20000
+
+#ifdef DEBUG_FLAG
+//#define DEBUG(format, ...)
+#define DEBUGGING 0
+#define NODE_DEBUG(n, s)
+#endif /* DEBUG_FLAG */
+
+
+#ifndef EMULATOR
+G_DEFINE_TYPE(GabbleVCardManager, gabble_vcard_manager, G_TYPE_OBJECT);
+#endif
+
+/* signal enum */
+enum
+{
+ NICKNAME_UPDATE,
+ LAST_SIGNAL
+#ifdef EMULATOR
+ = LAST_SIGNAL_VCARD_MGR
+#endif
+
+};
+
+#ifdef EMULATOR
+#include "libgabble_wsd_solution.h"
+
+ GET_STATIC_ARRAY_FROM_TLS(signals,gabble_vcard_mgr,guint)
+ #define signals (GET_WSD_VAR_NAME(signals,gabble_vcard_mgr, s)())
+
+ GET_STATIC_VAR_FROM_TLS(quark1,gabble_vcard_mgr,GQuark)
+ #define quark1 (*GET_WSD_VAR_NAME(quark1,gabble_vcard_mgr, s)())
+
+ GET_STATIC_VAR_FROM_TLS(quark2,gabble_vcard_mgr,GQuark)
+ #define quark2 (*GET_WSD_VAR_NAME(quark2,gabble_vcard_mgr, s)())
+
+ GET_STATIC_VAR_FROM_TLS(gabble_vcard_manager_parent_class,gabble_vcard_mgr,gpointer)
+ #define gabble_vcard_manager_parent_class (*GET_WSD_VAR_NAME(gabble_vcard_manager_parent_class,gabble_vcard_mgr,s)())
+
+ GET_STATIC_VAR_FROM_TLS(g_define_type_id,gabble_vcard_mgr,GType)
+ #define g_define_type_id (*GET_WSD_VAR_NAME(g_define_type_id,gabble_vcard_mgr,s)())
+
+ GET_STATIC_ARRAY_FROM_TLS(NO_ALIAS,gabble_vcard_mgr,gchar)
+ #define NO_ALIAS (GET_WSD_VAR_NAME(NO_ALIAS,gabble_vcard_mgr,s)())
+
+static void gabble_vcard_manager_init (GabbleVCardManager *self);
+static void gabble_vcard_manager_class_init (GabbleVCardManagerClass *klass);
+static void gabble_vcard_manager_class_intern_init (gpointer klass)
+ {
+ gabble_vcard_manager_parent_class = g_type_class_peek_parent (klass);
+ gabble_vcard_manager_class_init ((GabbleVCardManagerClass*) klass);
+ }
+ EXPORT_C GType gabble_vcard_manager_get_type (void)
+ {
+ if ((g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GabbleVCardManagerClass), (GBaseInitFunc) ((void *)0), (GBaseFinalizeFunc) ((void *)0), (GClassInitFunc) gabble_vcard_manager_class_intern_init, (GClassFinalizeFunc) ((void *)0), ((void *)0), sizeof (GabbleVCardManager), 0, (GInstanceInitFunc) gabble_vcard_manager_init, ((void *)0) }; g_define_type_id = g_type_register_static ( ((GType) ((20) << (2))), g_intern_static_string ("GabbleVCardManager"), &g_define_type_info, (GTypeFlags) 0); { {} ; } } return g_define_type_id; } ;
+
+#else
+
+ static guint signals[LAST_SIGNAL] = {0};
+
+ static const gchar *NO_ALIAS = "none";
+
+#endif
+
+
+/* Properties */
+enum
+{
+ PROP_CONNECTION = 1,
+ LAST_PROPERTY
+};
+
+
+
+typedef struct _GabbleVCardManagerPrivate GabbleVCardManagerPrivate;
+struct _GabbleVCardManagerPrivate
+{
+ GabbleConnection *connection;
+ GList *requests;
+ gboolean dispose_has_run;
+};
+
+struct _GabbleVCardManagerRequest
+{
+ GabbleVCardManager *manager;
+ guint timer_id;
+ guint timeout;
+
+ GabbleHandle handle;
+ gchar **edit_args;
+
+ GabbleVCardManagerCb callback;
+ gpointer user_data;
+ GObject *bound_object;
+};
+
+GQuark
+gabble_vcard_manager_error_quark (void)
+{
+
+#ifndef EMULATOR
+ static GQuark quark1 = 0;
+#endif
+
+ if (!quark1)
+ quark1 = g_quark_from_static_string ("gabble-vcard-manager-error");
+ return quark1;
+}
+
+GQuark
+gabble_vcard_manager_cache_quark (void)
+{
+
+#ifndef EMULATOR
+ static GQuark quark2 = 0;
+#endif
+
+ if (!quark2)
+ quark2 = g_quark_from_static_string ("gabble-vcard-manager-cache");
+ return quark2;
+}
+
+#define GABBLE_VCARD_MANAGER_GET_PRIVATE(o) ((GabbleVCardManagerPrivate*)((o)->priv));
+
+static void
+gabble_vcard_manager_init (GabbleVCardManager *obj)
+{
+ GabbleVCardManagerPrivate *priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (obj, GABBLE_TYPE_VCARD_MANAGER, GabbleVCardManagerPrivate);
+ obj->priv = priv;
+
+}
+
+static void gabble_vcard_manager_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec);
+static void gabble_vcard_manager_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec);
+static void gabble_vcard_manager_dispose (GObject *object);
+static void gabble_vcard_manager_finalize (GObject *object);
+
+static void
+gabble_vcard_manager_class_init (GabbleVCardManagerClass *gabble_vcard_manager_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_vcard_manager_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_vcard_manager_class, sizeof (GabbleVCardManagerPrivate));
+
+ object_class->get_property = gabble_vcard_manager_get_property;
+ object_class->set_property = gabble_vcard_manager_set_property;
+
+ object_class->dispose = gabble_vcard_manager_dispose;
+ object_class->finalize = gabble_vcard_manager_finalize;
+
+ param_spec = g_param_spec_object ("connection", "GabbleConnection object",
+ "Gabble connection object that owns this "
+ "vCard lookup helper object.",
+ GABBLE_TYPE_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+
+ /* signal definitions */
+
+ signals[NICKNAME_UPDATE] =
+ g_signal_new ("nickname-update",
+ G_TYPE_FROM_CLASS (gabble_vcard_manager_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+
+}
+
+static void
+gabble_vcard_manager_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleVCardManager *chan = GABBLE_VCARD_MANAGER (object);
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->connection);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_vcard_manager_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleVCardManager *chan = GABBLE_VCARD_MANAGER (object);
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (chan);
+
+ switch (property_id) {
+ case PROP_CONNECTION:
+ priv->connection = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void cancel_request (GabbleVCardManagerRequest *request);
+
+void
+gabble_vcard_manager_dispose (GObject *object)
+{
+ DBusGProxy *bus_proxy;
+ GabbleVCardManager *self = GABBLE_VCARD_MANAGER (object);
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (self);
+ bus_proxy = tp_get_bus_proxy ();
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ /* cancel request removes the element from the list after cancelling */
+ while (priv->requests)
+ cancel_request (priv->requests->data);
+
+ if (G_OBJECT_CLASS (gabble_vcard_manager_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_vcard_manager_parent_class)->dispose (object);
+}
+
+void
+gabble_vcard_manager_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gabble_vcard_manager_parent_class)->finalize (object);
+}
+
+static void
+status_changed_cb (GObject *object,
+ guint status,
+ guint reason,
+ gpointer user_data)
+{
+ GabbleVCardManager *self = GABBLE_VCARD_MANAGER (user_data);
+ GabbleConnection *conn = GABBLE_CONNECTION (object);
+
+ if (status == TP_CONN_STATUS_CONNECTED)
+ {
+ gchar *alias;
+ GabbleConnectionAliasSource alias_src;
+
+ /* if we have a better alias, patch it into our vCard on the server */
+ alias_src = _gabble_connection_get_cached_alias (conn,
+ conn->self_handle,
+ &alias);
+ if (alias_src > GABBLE_CONNECTION_ALIAS_FROM_VCARD)
+ {
+ /* ignore errors, just kick off the request in the background */
+ gabble_vcard_manager_edit (self, 0, NULL, NULL, G_OBJECT (conn),
+ NULL, "NICKNAME", alias, NULL);
+ }
+ else
+ {
+ /* find out our own alias, so it's in the cache; again,
+ * there's nothing useful we can do with errors really
+ */
+ gabble_vcard_manager_request (self, conn->self_handle,
+ 0, NULL, NULL, NULL, NULL);
+ }
+
+ g_free(alias);
+ }
+}
+
+/**
+ * gabble_vcard_manager_new:
+ * @conn: The #GabbleConnection to use for vCard lookup
+ *
+ * Creates an object to use for Jabber vCard lookup (JEP 0054).
+ * There should be one of these per connection
+ */
+GabbleVCardManager *
+gabble_vcard_manager_new (GabbleConnection *conn)
+{
+ GabbleVCardManager *self;
+
+ g_return_val_if_fail (GABBLE_IS_CONNECTION (conn), NULL);
+
+ self = GABBLE_VCARD_MANAGER (g_object_new (GABBLE_TYPE_VCARD_MANAGER, "connection", conn, NULL));
+ g_signal_connect (conn, "status-changed",
+ G_CALLBACK (status_changed_cb), self);
+ return self;
+}
+
+static void notify_delete_request (gpointer data, GObject *obj);
+
+static void
+delete_request (GabbleVCardManagerRequest *request)
+{
+ GabbleVCardManager *manager = request->manager;
+ GabbleVCardManagerPrivate *priv;
+
+ gabble_debug (DEBUG_FLAG, "Discarding request %p", request);
+
+ g_assert (NULL != request);
+ g_assert (GABBLE_IS_VCARD_MANAGER (manager));
+
+ priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (manager);
+
+ g_assert (NULL != g_list_find (priv->requests, request));
+
+ priv->requests = g_list_remove (priv->requests, request);
+
+ if (NULL != request->bound_object)
+ {
+ g_object_weak_unref (request->bound_object, notify_delete_request, request);
+ }
+
+ if (0 != request->timer_id)
+ {
+ g_source_remove (request->timer_id);
+ }
+
+ gabble_handle_unref (priv->connection->handles, TP_HANDLE_TYPE_CONTACT,
+ request->handle);
+ g_strfreev (request->edit_args);
+
+ g_free (request);
+}
+
+static gboolean
+timeout_request (gpointer data)
+{
+ GabbleVCardManagerRequest *request = (GabbleVCardManagerRequest*) data;
+ GError *err;
+ g_return_val_if_fail (data != NULL, FALSE);
+
+ err = g_error_new (GABBLE_VCARD_MANAGER_ERROR, GABBLE_VCARD_MANAGER_ERROR_TIMEOUT,
+ "Request timed out");
+ gabble_debug (DEBUG_FLAG, "Request %p timed out, notifying callback %p",
+ request, request->callback);
+ if (request->callback)
+ {
+ (request->callback)(request->manager, request, request->handle,
+ NULL, err, request->user_data);
+ }
+ g_error_free (err);
+
+ request->timer_id = 0;
+ delete_request (request);
+ return FALSE;
+}
+
+static void
+cancel_request (GabbleVCardManagerRequest *request)
+{
+ GError *err;
+
+ g_assert (request != NULL);
+
+ err = g_error_new (GABBLE_VCARD_MANAGER_ERROR, GABBLE_VCARD_MANAGER_ERROR_CANCELLED,
+ "Request cancelled");
+ gabble_debug (DEBUG_FLAG, "Request %p cancelled, notifying callback %p",
+ request, request->callback);
+ if (request->callback)
+ {
+ (request->callback)(request->manager, request, request->handle,
+ NULL, err, request->user_data);
+ }
+ g_error_free (err);
+
+ delete_request (request);
+}
+
+static void
+observe_vcard (GabbleConnection *conn, GabbleVCardManager *manager,
+ GabbleHandle handle, LmMessageNode *vcard_node)
+{
+ LmMessageNode *nick_node = lm_message_node_get_child (vcard_node,
+ "NICKNAME");
+
+ gabble_debug (DEBUG_FLAG, "Observing vCard for %u", handle);
+ NODE_DEBUG(vcard_node, "their vCard is");
+
+ if (nick_node)
+ {
+ const gchar *nick = lm_message_node_get_value (nick_node);
+
+ gabble_debug (DEBUG_FLAG, "%u has <NICKNAME> \"%s\"", handle, nick ? nick : "(null)");
+
+ if (nick && *nick)
+ {
+ /* nicknames are comma-separated, let's use the first one */
+ gchar **bits = g_strsplit (nick, ",", 2);
+
+ if (bits[0])
+ {
+ gchar *alias = g_strdup (bits[0]);
+
+ gabble_debug (DEBUG_FLAG, "... using \"%s\" as their alias", alias);
+
+ g_signal_emit (G_OBJECT (manager), signals[NICKNAME_UPDATE],
+ 0, handle);
+ if (!gabble_handle_set_qdata (conn->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ handle,
+ gabble_vcard_manager_cache_quark(),
+ alias, g_free))
+ {
+ gabble_debug (DEBUG_FLAG, "failed to cache their alias");
+ g_free (alias);
+ }
+
+ }
+
+ g_strfreev (bits);
+ }
+ }
+ else
+ {
+ const gchar *fn = NULL;
+ /* let's see if they have a FN (formatted name) instead */
+ nick_node = lm_message_node_get_child (vcard_node, "FN");
+ if (nick_node)
+ fn = lm_message_node_get_value (nick_node);
+ gabble_debug (DEBUG_FLAG, "%u has no <NICKNAME>, but has <FN> \"%s\"", handle,
+ fn ? fn : "(null)");
+ if (fn && *fn)
+ {
+ gchar *alias = g_strdup (fn);
+
+ gabble_debug (DEBUG_FLAG, "... using \"%s\" as their alias", alias);
+
+ g_signal_emit (G_OBJECT (manager), signals[NICKNAME_UPDATE],
+ 0, handle);
+ if (!gabble_handle_set_qdata (conn->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ handle,
+ gabble_vcard_manager_cache_quark(),
+ alias, g_free))
+ {
+ gabble_debug (DEBUG_FLAG, "failed to cache their alias");
+ g_free (alias);
+ }
+ }
+ else
+ {
+ /* remember that they don't have an alias */
+ if (!gabble_handle_set_qdata (conn->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ handle,
+ gabble_vcard_manager_cache_quark (),
+ (gchar *) NO_ALIAS, NULL))
+ gabble_debug (DEBUG_FLAG, "failed to cache their lack of vcard alias");
+ }
+
+ }
+}
+
+static GabbleVCardManagerRequest *request_send (GabbleVCardManagerRequest *,
+ LmMessageNode *replacement,
+ const gchar *jid,
+ GError **);
+
+static LmHandlerResult
+replace_reply_cb (GabbleConnection *conn, LmMessage *sent_msg,
+ LmMessage *reply_msg, GObject *object, gpointer user_data)
+{
+ LmMessageNode *vcard_node = NULL;
+ GError *err = NULL;
+ GabbleVCardManagerRequest *request = (GabbleVCardManagerRequest*) user_data;
+ GabbleVCardManager *manager = GABBLE_VCARD_MANAGER (object);
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (manager);
+
+ g_assert (request);
+
+ gabble_debug (DEBUG_FLAG, "Replace request got a reply: conn@%p, sent_msg@%p, reply_msg@%p, "
+ "bound object@%p, request@%p", conn, sent_msg, reply_msg, object,
+ user_data);
+
+ if (!g_list_find (priv->requests, request))
+ {
+ gabble_debug (DEBUG_FLAG, "I don't care about that request any more");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+ if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ LmMessageNode *error_node;
+
+ error_node = lm_message_node_get_child (reply_msg->node, "error");
+ if (error_node)
+ {
+ err = gabble_xmpp_error_to_g_error (
+ gabble_xmpp_error_from_node (error_node));
+ }
+
+ if (err == NULL)
+ {
+ err = g_error_new (GABBLE_VCARD_MANAGER_ERROR,
+ GABBLE_VCARD_MANAGER_ERROR_UNKNOWN,
+ "an unknown error occurred");
+ }
+ }
+ else
+ {
+ vcard_node = lm_message_node_get_child (sent_msg->node, "vCard");
+ }
+
+ gabble_debug (DEBUG_FLAG, "Request %p %s, notifying callback %p", request,
+ err ? "failed" : "succeeded", request->callback);
+ if (request->callback)
+ {
+ request->callback (request->manager, request, request->handle,
+ vcard_node, err, request->user_data);
+ }
+ delete_request (request);
+
+ if (err)
+ g_error_free (err);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+static LmHandlerResult
+request_reply_cb (GabbleConnection *conn,
+ LmMessage *sent_msg,
+ LmMessage *reply_msg,
+ GObject *object,
+ gpointer user_data)
+{
+ LmMessageNode *vcard_node = NULL;
+ GError *err = NULL;
+ GabbleVCardManagerRequest *request = (GabbleVCardManagerRequest*) user_data;
+ GabbleVCardManager *manager = GABBLE_VCARD_MANAGER (object);
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (manager);
+
+ g_assert (request);
+
+ gabble_debug (DEBUG_FLAG, "Fetch request got a reply: conn@%p, sent_msg@%p, reply_msg@%p, "
+ "bound object@%p, request@%p", conn, sent_msg, reply_msg, object,
+ user_data);
+
+ if (!g_list_find (priv->requests, request))
+ {
+ gabble_debug (DEBUG_FLAG, "I don't care about that request any more");
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+ }
+
+
+ if (lm_message_get_sub_type (reply_msg) == LM_MESSAGE_SUB_TYPE_ERROR)
+ {
+ LmMessageNode *error_node;
+
+ error_node = lm_message_node_get_child (reply_msg->node, "error");
+ if (error_node)
+ {
+ err = gabble_xmpp_error_to_g_error (
+ gabble_xmpp_error_from_node (error_node));
+ }
+
+ if (err == NULL)
+ {
+ err = g_error_new (GABBLE_VCARD_MANAGER_ERROR,
+ GABBLE_VCARD_MANAGER_ERROR_UNKNOWN,
+ "an unknown error occurred");
+ }
+ }
+ else
+ {
+ vcard_node = lm_message_node_get_child (reply_msg->node, "vCard");
+
+ if (NULL == vcard_node)
+ {
+ gabble_debug (DEBUG_FLAG, "successful lookup response contained no <vCard> node, "
+ "creating an empty one");
+
+ vcard_node = lm_message_node_add_child (reply_msg->node, "vCard",
+ NULL);
+ lm_message_node_set_attribute (vcard_node, "xmlns", NS_VCARD_TEMP);
+ }
+
+ observe_vcard (conn, manager, request->handle, vcard_node);
+ }
+
+ if (vcard_node && request->edit_args)
+ {
+ gchar **ptr;
+ for (ptr = request->edit_args; *ptr; ptr++)
+ {
+ gchar *key = *ptr;
+ gchar *value = *(++ptr);
+ LmMessageNode *node;
+
+ if (!value)
+ {
+ /* oops, someone passed in an odd number of args. */
+ g_assert_not_reached ();
+ break;
+ }
+
+ node = lm_message_node_get_child (vcard_node, key);
+ if (node)
+ {
+ lm_message_node_set_value (node, value);
+ }
+ else
+ {
+ node = lm_message_node_add_child (vcard_node, key, value);
+ }
+ }
+
+ request_send (request, vcard_node, NULL, &err);
+
+ if (err)
+ {
+ gabble_debug (DEBUG_FLAG, "Request %p failed, notifying callback %p",
+ request, request->callback);
+ if (request->callback)
+ {
+ request->callback (request->manager, request, request->handle,
+ NULL, err, request->user_data);
+ }
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "Request %p fetch succeeded", request);
+ /* early return to avoid deleting the request */
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+ }
+ }
+ else
+ {
+ gabble_debug (DEBUG_FLAG, "Request %p %s, notifying callback %p",
+ request, err ? "failed" : "succeeded", request->callback);
+ if (request->callback)
+ {
+ request->callback (request->manager, request, request->handle,
+ vcard_node, err, request->user_data);
+ }
+ }
+
+ delete_request (request);
+
+ if (err)
+ g_error_free (err);
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
+/* If @replacement is NULL sends a request, calling request_reply_cb when
+ * it returns.
+ *
+ * Otherwise steals its children and sends an update, calling
+ * replace_reply_cb when it returns.
+ *
+ * Frees the @request on error, returns it on success. */
+static GabbleVCardManagerRequest *
+request_send (GabbleVCardManagerRequest *request,
+ LmMessageNode *replacement,
+ const gchar *jid,
+ GError **error)
+{
+ LmMessage *msg;
+ LmMessageNode *lm_node;
+ GabbleVCardManager *self = request->manager;
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (self);
+
+ gabble_debug (DEBUG_FLAG, "Sending off request %p to %s for %s", request,
+ replacement ? "replace vCard" : "retrieve vCard",
+ jid ? jid : "myself");
+ msg = lm_message_new_with_sub_type (jid, LM_MESSAGE_TYPE_IQ,
+ (replacement
+ ? LM_MESSAGE_SUB_TYPE_SET
+ : LM_MESSAGE_SUB_TYPE_GET));
+ lm_node = lm_message_node_add_child (msg->node, "vCard", NULL);
+ lm_message_node_set_attribute (lm_node, "xmlns", NS_VCARD_TEMP);
+
+ if (replacement)
+ lm_message_node_steal_children (lm_node, replacement);
+
+ if (! _gabble_connection_send_with_reply (priv->connection, msg,
+ (replacement ? replace_reply_cb : request_reply_cb),
+ G_OBJECT(self), request, error))
+ {
+ delete_request (request);
+ lm_message_unref (msg);
+ return NULL;
+ }
+ else
+ {
+ if (0 == request->timer_id)
+ {
+ request->timer_id =
+ g_timeout_add (request->timeout, timeout_request, request);
+ }
+ lm_message_unref (msg);
+ return request;
+ }
+}
+
+static void
+notify_delete_request (gpointer data, GObject *obj)
+{
+ GabbleVCardManagerRequest *request = (GabbleVCardManagerRequest *) data;
+ request->bound_object = NULL;
+ delete_request (request);
+}
+
+/* Request the vCard for the given handle. When it arrives, call the given
+ * callback.
+ *
+ * The callback may be NULL if you just want the side-effect of this
+ * operation, which is to update the cached alias.
+ */
+GabbleVCardManagerRequest *
+gabble_vcard_manager_request (GabbleVCardManager *self,
+ GabbleHandle handle,
+ guint timeout,
+ GabbleVCardManagerCb callback,
+ gpointer user_data,
+ GObject *object,
+ GError **error)
+{
+ GabbleVCardManagerRequest *request;
+ const gchar *jid;
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (self);
+
+ if (timeout == 0)
+ timeout = DEFAULT_REQUEST_TIMEOUT;
+
+ request = g_new0 (GabbleVCardManagerRequest, 1);
+ gabble_debug (DEBUG_FLAG, "Created request %p to retrieve <%u>'s vCard",
+ request, handle);
+ request->timeout = timeout;
+ request->manager = self;
+ gabble_handle_ref (priv->connection->handles, TP_HANDLE_TYPE_CONTACT,
+ handle);
+ request->handle = handle;
+ request->callback = callback;
+ request->user_data = user_data;
+ request->bound_object = object;
+
+ if (NULL != object)
+ g_object_weak_ref (object, notify_delete_request, request);
+
+ priv->requests = g_list_prepend (priv->requests, request);
+ if (handle == priv->connection->self_handle)
+ {
+ jid = NULL;
+ }
+ else
+ {
+ jid = gabble_handle_inspect (priv->connection->handles,
+ TP_HANDLE_TYPE_CONTACT, handle);
+ }
+
+ return request_send (request, NULL, jid, error);
+}
+
+GabbleVCardManagerRequest *
+gabble_vcard_manager_replace (GabbleVCardManager *self,
+ LmMessageNode *replacement,
+ guint timeout,
+ GabbleVCardManagerCb callback,
+ gpointer user_data,
+ GObject *object,
+ GError **error)
+{
+ GabbleVCardManagerRequest *request;
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (self);
+
+ if (timeout == 0)
+ timeout = DEFAULT_REQUEST_TIMEOUT;
+
+ request = g_new0 (GabbleVCardManagerRequest, 1);
+ gabble_debug (DEBUG_FLAG, "Created request %p to replace my vCard",
+ request);
+ request->timeout = timeout;
+ request->manager = self;
+ gabble_handle_ref (priv->connection->handles, TP_HANDLE_TYPE_CONTACT,
+ priv->connection->self_handle);
+ request->handle = priv->connection->self_handle;
+ request->callback = callback;
+ request->user_data = user_data;
+ request->bound_object = object;
+
+ if (NULL != object)
+ g_object_weak_ref (object, notify_delete_request, request);
+
+ priv->requests = g_list_prepend (priv->requests, request);
+
+ return request_send (request, replacement, NULL, error);
+}
+
+GabbleVCardManagerRequest *
+gabble_vcard_manager_edit (GabbleVCardManager *self,
+ guint timeout,
+ GabbleVCardManagerCb callback,
+ gpointer user_data,
+ GObject *object,
+ GError **error,
+ ...)
+{
+ va_list ap;
+ size_t i, argc;
+ GabbleVCardManagerRequest *request;
+ GabbleVCardManagerPrivate *priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (self);
+
+ if (timeout == 0)
+ timeout = DEFAULT_REQUEST_TIMEOUT;
+
+ request = g_new0 (GabbleVCardManagerRequest, 1);
+ gabble_debug (DEBUG_FLAG, "Created request %p to edit my vCard", request);
+ request->timeout = timeout;
+ request->manager = self;
+ gabble_handle_ref (priv->connection->handles, TP_HANDLE_TYPE_CONTACT,
+ priv->connection->self_handle);
+ request->handle = priv->connection->self_handle;
+ request->callback = callback;
+ request->user_data = user_data;
+ request->bound_object = object;
+
+ if (NULL != object)
+ g_object_weak_ref (object, notify_delete_request, request);
+
+ priv->requests = g_list_prepend (priv->requests, request);
+
+ argc = 0;
+ va_start (ap, error);
+ while (va_arg (ap, const gchar *) != NULL)
+ {
+ argc++;
+ }
+ va_end (ap);
+ g_return_val_if_fail (argc % 2 == 0, NULL);
+
+ request->edit_args = g_new (gchar *, argc + 1);
+
+ va_start (ap, error);
+ for (i = 0; i < argc; i++)
+ {
+ request->edit_args[i] = g_strdup (va_arg (ap, const gchar *));
+ }
+ request->edit_args[argc] = NULL;
+ va_end (ap);
+
+ return request_send (request, NULL, NULL, error);
+}
+
+void
+gabble_vcard_manager_cancel_request (GabbleVCardManager *manager,
+ GabbleVCardManagerRequest *request)
+{
+ GabbleVCardManagerPrivate *priv;
+
+ g_return_if_fail (GABBLE_IS_VCARD_MANAGER (manager));
+ g_return_if_fail (NULL != request);
+
+ priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (manager);
+
+ g_return_if_fail (NULL != g_list_find (priv->requests, request));
+
+ cancel_request (request);
+}
+
+/**
+ * Return the cached alias derived from the vCard for the given handle,
+ * if any. If there is no cached alias, return NULL.
+ */
+const gchar *
+gabble_vcard_manager_get_cached_alias (GabbleVCardManager *manager,
+ GabbleHandle handle)
+{
+ GabbleVCardManagerPrivate *priv;
+ const gchar *s;
+
+ g_return_val_if_fail (GABBLE_IS_VCARD_MANAGER (manager), NULL);
+
+ priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (manager);
+
+ s = gabble_handle_get_qdata (priv->connection->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ handle,
+ gabble_vcard_manager_cache_quark());
+
+ if (s == NO_ALIAS)
+ s = NULL;
+
+ gabble_debug (DEBUG_FLAG, "Cached alias for %u is \"%s\"", handle, s ? s : "(null)");
+ return s;
+}
+
+/**
+ * Return TRUE if we've tried looking up an alias for this handle before.
+ */
+gboolean
+gabble_vcard_manager_has_cached_alias (GabbleVCardManager *manager,
+ GabbleHandle handle)
+{
+ GabbleVCardManagerPrivate *priv;
+ gpointer p;
+
+ g_return_val_if_fail (GABBLE_IS_VCARD_MANAGER (manager), FALSE);
+
+ priv = GABBLE_VCARD_MANAGER_GET_PRIVATE (manager);
+ p = gabble_handle_get_qdata (priv->connection->handles,
+ TP_HANDLE_TYPE_CONTACT,
+ handle,
+ gabble_vcard_manager_cache_quark());
+ return p != NULL;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/telepathygabble/src/write-mgr-file.c Tue Feb 02 01:10:06 2010 +0200
@@ -0,0 +1,104 @@
+/*
+ * write_mgr_file.c - utility to produce gabble.manager. Part of Gabble.
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-protocol.h>
+
+#include "telepathy-constants.h"
+#include "gabble-connection-manager.h"
+
+static gchar *
+mgr_file_contents (const char *busname,
+ const char *objpath,
+ const GabbleProtocolSpec *protocols,
+ GError **error)
+{
+ GKeyFile *f = g_key_file_new();
+ const GabbleProtocolSpec *protocol;
+ const GabbleParamSpec *row;
+
+ g_key_file_set_string(f, "ConnectionManager", "BusName", busname);
+ g_key_file_set_string(f, "ConnectionManager", "ObjectPath", objpath);
+
+ for (protocol = protocols; protocol->name; protocol++)
+ {
+ gchar *section_name = g_strdup_printf("Protocol %s", protocol->name);
+
+ for (row = protocol->parameters; row->name; row++)
+ {
+ gchar *param_name = g_strdup_printf("param-%s", row->name);
+ gchar *param_value = g_strdup_printf("%s%s%s", row->dtype,
+ (row->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED ? " required" : ""),
+ (row->flags & TP_CONN_MGR_PARAM_FLAG_REGISTER ? " register" : ""));
+ g_key_file_set_string(f, section_name, param_name, param_value);
+ g_free(param_value);
+ g_free(param_name);
+ }
+
+ for (row = protocol->parameters; row->name; row++)
+ {
+ if (row->flags & TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT)
+ {
+ gchar *default_name = g_strdup_printf("default-%s", row->name);
+
+ switch (row->gtype)
+ {
+ case G_TYPE_STRING:
+ g_key_file_set_string(f, section_name, default_name,
+ row->def);
+ break;
+ case G_TYPE_INT:
+ case G_TYPE_UINT:
+ g_key_file_set_integer(f, section_name, default_name,
+ GPOINTER_TO_INT(row->def));
+ break;
+ case G_TYPE_BOOLEAN:
+ g_key_file_set_boolean(f, section_name, default_name,
+ GPOINTER_TO_INT(row->def) ? 1 : 0);
+ }
+ g_free(default_name);
+ }
+ }
+ g_free(section_name);
+ }
+ return g_key_file_to_data(f, NULL, error);
+}
+
+int
+main (void)
+{
+ GError *error = NULL;
+
+ gchar *s = mgr_file_contents(GABBLE_CONN_MGR_BUS_NAME,
+ GABBLE_CONN_MGR_OBJECT_PATH,
+ gabble_protocols, &error);
+ if (!s)
+ {
+ fprintf(stderr, error->message);
+ g_error_free(error);
+ return 1;
+ }
+ g_message("%s", s);
+ getchar(); //vinod
+ g_free(s);
+ return 0;
+}