sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "file-transfer-server.h" sl@0: #include "file_send-glue.h" sl@0: #include sl@0: #include sl@0: sl@0: sl@0: static GObjectClass *parent_class = ((void *)0); sl@0: static void some_object_init (SomeObject *self); sl@0: sl@0: char *FILENAME = "c:/bunbask1.jpg"; sl@0: int SIZE = (4*1024); sl@0: sl@0: gboolean some_object_method1_impl (SomeObject *self, gint a, GArray *y,gint *z,GError **error) sl@0: { sl@0: *z = a; sl@0: sl@0: return TRUE; sl@0: } sl@0: sl@0: void some_object_method2_impl (SomeObject *self, gchar* b) sl@0: { sl@0: self->m_b = b; sl@0: g_print ("Method2: %s\n", self->m_b); sl@0: } sl@0: sl@0: sl@0: /* Public methods. */ sl@0: gboolean some_object_method1 (SomeObject *self, gint a,GArray *y,gint *z,GError **error) sl@0: { sl@0: return SOME_OBJECT_GET_CLASS (self)->method1 (self, a,y,z,error); sl@0: } sl@0: sl@0: void some_object_method2 (SomeObject *self, gchar* b) sl@0: { sl@0: SOME_OBJECT_GET_CLASS (self)->method2 (self, b); sl@0: } sl@0: sl@0: void some_object_method3 (SomeObject *self, gfloat c) sl@0: { sl@0: self->m_c = c; sl@0: g_print ("Method3: %f\n", self->m_c); sl@0: } sl@0: sl@0: sl@0: void some_object_dispose (GObject *self) sl@0: { sl@0: static gboolean first_run = TRUE; sl@0: sl@0: if (first_run) sl@0: { sl@0: first_run = FALSE; sl@0: sl@0: /* Call g_object_unref on any GObjects that we hold, but don't break the object */ sl@0: sl@0: parent_class-> dispose (self); sl@0: } sl@0: } sl@0: sl@0: void some_object_finalize (GObject *self) sl@0: { sl@0: parent_class-> finalize (self); sl@0: } sl@0: sl@0: /* Here is where we override any functions. Since we have no properties or even fields, none of the below are needed. */ sl@0: void some_object_class_init (gpointer g_class, gpointer class_data) sl@0: { sl@0: GObjectClass *object_class = G_OBJECT_CLASS (g_class); sl@0: SomeObjectClass *this_class = SOME_OBJECT_CLASS (g_class); sl@0: sl@0: //assign value to parent class sl@0: parent_class = g_type_class_peek_parent (g_class); sl@0: sl@0: //assing pointer values to the base class members sl@0: object_class-> dispose = &some_object_dispose; sl@0: object_class-> finalize = &some_object_finalize; sl@0: sl@0: //assign value to derived class members sl@0: this_class->method1 = &some_object_method1_impl; sl@0: this_class->method2 = &some_object_method2_impl; sl@0: sl@0: dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(this_class),&dbus_glib__object_info); sl@0: } sl@0: sl@0: void some_object_init (SomeObject *self) sl@0: { sl@0: self->m_a = 1; sl@0: self->m_c = 1.03f; sl@0: self->m_b = "sumit"; sl@0: } sl@0: sl@0: GType some_object_get_type () sl@0: { sl@0: static GType g_define_type_id = 0; sl@0: if ((g_define_type_id == 0)) sl@0: { sl@0: static const GTypeInfo g_define_type_info = sl@0: { sl@0: sizeof (SomeObjectClass), sl@0: (GBaseInitFunc) ((void *)0), sl@0: (GBaseFinalizeFunc) ((void *)0), sl@0: (GClassInitFunc) some_object_class_init, sl@0: (GClassFinalizeFunc) ((void *)0), sl@0: ((void *)0), sl@0: sizeof (SomeObject), sl@0: 0, sl@0: (GInstanceInitFunc) some_object_init, sl@0: }; sl@0: sl@0: g_define_type_id = g_type_register_static sl@0: ( sl@0: G_TYPE_OBJECT, sl@0: "SomeObject", sl@0: &g_define_type_info, sl@0: (GTypeFlags) 0 sl@0: ); sl@0: sl@0: } sl@0: sl@0: return g_define_type_id; sl@0: } sl@0: sl@0: int main() sl@0: { sl@0: SomeObject *so = NULL; sl@0: DBusGConnection *bus; sl@0: GMainLoop *mainLoop = NULL; sl@0: unsigned int request_ret; sl@0: GError *error = NULL; sl@0: sl@0: DBusGProxy *proxy = NULL; sl@0: sl@0: g_type_init(); sl@0: sl@0: so = g_object_new(SOME_OBJECT_TYPE,NULL); sl@0: sl@0: bus = dbus_g_bus_get(DBUS_BUS_SESSION,NULL); sl@0: sl@0: proxy = dbus_g_proxy_new_for_name(bus,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS); sl@0: sl@0: dbus_g_connection_register_g_object(bus,"/com/example/SomeObject",G_OBJECT(so)); sl@0: sl@0: if(!org_freedesktop_DBus_request_name(proxy,"com.example.SomeObject",0,&request_ret,&error)) sl@0: { sl@0: g_print("Unable to register service\n"); sl@0: return 1; sl@0: } sl@0: sl@0: mainLoop = g_main_loop_new(NULL,FALSE); sl@0: g_main_loop_run(mainLoop); sl@0: sl@0: return 0; sl@0: } sl@0: