libtelepathy/tsrc/src/telepathygabbleutils.cpp
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /*
       
     2 * Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    File containing Utility functions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 //Include files
       
    23 #include <e32err.h>
       
    24 #include <e32const.h>
       
    25 #include <e32base.h>
       
    26 
       
    27 #include <glib.h>
       
    28 
       
    29 #include "telepathygabbletestdata.h"
       
    30 #include "telepathygabbleutils.h"
       
    31 
       
    32 
       
    33 
       
    34 
       
    35 //-----------------------------------------------------------------------------
       
    36 // function_name	: CTelepathyGabbleUtils
       
    37 // description     	: constructor
       
    38 //----------------------------------------------------------------------------- 
       
    39 guint CTelepathyGabbleUtils::get_handle_from_contact ( const gchar  *contact_id,
       
    40 														CTestData* aTestData)
       
    41 	 
       
    42 {
       
    43 
       
    44 	guint          handle;
       
    45 	gboolean       success;
       
    46 	GError        *error = NULL;
       
    47 	
       
    48 	
       
    49 	//check for the return value if 0 is ok or should some negative value to be passed
       
    50 	g_return_val_if_fail (contact_id != NULL, 0); 
       
    51 	
       
    52 	GArray      *handles = NULL;	
       
    53 	const gchar *contact_ids[2] ; //contact_ids initialization here gives error ..may be some compiler issue as otherwise okay to initialze here
       
    54 	
       
    55 	
       
    56 	contact_ids[0]= contact_id;
       
    57 	contact_ids[1]= NULL;
       
    58 	
       
    59 
       
    60 	success = tp_conn_request_handles (DBUS_G_PROXY (aTestData->GetTpConn()),
       
    61 					   TP_CONN_HANDLE_TYPE_CONTACT,
       
    62 					   contact_ids, &handles, &error);
       
    63 	if( !handles || error )	
       
    64 	{
       
    65 	 	//do some error handling here
       
    66 	 	
       
    67 	 	g_error_free(error);
       
    68 	 	return KErrNotFound; 
       
    69 	}				   
       
    70 						   
       
    71 
       
    72 	handle = g_array_index(handles, guint, 0);
       
    73 	g_array_free (handles, TRUE);
       
    74 	
       
    75 
       
    76 	if (!success) 
       
    77 	{
       
    78 		//test_log_handler ( error->message );
       
    79 		g_clear_error (&error);
       
    80 		
       
    81 		//check for the return value if 0 is ok or should some negative value to be passed
       
    82 		return 0;
       
    83 	}
       
    84 
       
    85 	return handle;
       
    86 }
       
    87 
       
    88 //  End of File