os/ossrv/ofdbus/dbus-glib/tsrc/testapps/file-transfer-server/src/file-transfer-server.c
First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "file-transfer-server.h"
24 #include "file_send-glue.h"
25 #include <dbus/dbus-glib-bindings.h>
29 static GObjectClass *parent_class = ((void *)0);
30 static void some_object_init (SomeObject *self);
32 char *FILENAME = "c:/bunbask1.jpg";
35 gboolean some_object_method1_impl (SomeObject *self, gint a, GArray *y,gint *z,GError **error)
42 void some_object_method2_impl (SomeObject *self, gchar* b)
45 g_print ("Method2: %s\n", self->m_b);
50 gboolean some_object_method1 (SomeObject *self, gint a,GArray *y,gint *z,GError **error)
52 return SOME_OBJECT_GET_CLASS (self)->method1 (self, a,y,z,error);
55 void some_object_method2 (SomeObject *self, gchar* b)
57 SOME_OBJECT_GET_CLASS (self)->method2 (self, b);
60 void some_object_method3 (SomeObject *self, gfloat c)
63 g_print ("Method3: %f\n", self->m_c);
67 void some_object_dispose (GObject *self)
69 static gboolean first_run = TRUE;
75 /* Call g_object_unref on any GObjects that we hold, but don't break the object */
77 parent_class-> dispose (self);
81 void some_object_finalize (GObject *self)
83 parent_class-> finalize (self);
86 /* Here is where we override any functions. Since we have no properties or even fields, none of the below are needed. */
87 void some_object_class_init (gpointer g_class, gpointer class_data)
89 GObjectClass *object_class = G_OBJECT_CLASS (g_class);
90 SomeObjectClass *this_class = SOME_OBJECT_CLASS (g_class);
92 //assign value to parent class
93 parent_class = g_type_class_peek_parent (g_class);
95 //assing pointer values to the base class members
96 object_class-> dispose = &some_object_dispose;
97 object_class-> finalize = &some_object_finalize;
99 //assign value to derived class members
100 this_class->method1 = &some_object_method1_impl;
101 this_class->method2 = &some_object_method2_impl;
103 dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(this_class),&dbus_glib__object_info);
106 void some_object_init (SomeObject *self)
113 GType some_object_get_type ()
115 static GType g_define_type_id = 0;
116 if ((g_define_type_id == 0))
118 static const GTypeInfo g_define_type_info =
120 sizeof (SomeObjectClass),
121 (GBaseInitFunc) ((void *)0),
122 (GBaseFinalizeFunc) ((void *)0),
123 (GClassInitFunc) some_object_class_init,
124 (GClassFinalizeFunc) ((void *)0),
128 (GInstanceInitFunc) some_object_init,
131 g_define_type_id = g_type_register_static
141 return g_define_type_id;
146 SomeObject *so = NULL;
147 DBusGConnection *bus;
148 GMainLoop *mainLoop = NULL;
149 unsigned int request_ret;
150 GError *error = NULL;
152 DBusGProxy *proxy = NULL;
156 so = g_object_new(SOME_OBJECT_TYPE,NULL);
158 bus = dbus_g_bus_get(DBUS_BUS_SESSION,NULL);
160 proxy = dbus_g_proxy_new_for_name(bus,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);
162 dbus_g_connection_register_g_object(bus,"/com/example/SomeObject",G_OBJECT(so));
164 if(!org_freedesktop_DBus_request_name(proxy,"com.example.SomeObject",0,&request_ret,&error))
166 g_print("Unable to register service\n");
170 mainLoop = g_main_loop_new(NULL,FALSE);
171 g_main_loop_run(mainLoop);