1 /* Copyright (C) 2006 Barış Metin <baris@pardus.org.tr>
2 * Copyright (C) 2007 Serkan Kaba <serkan_kaba@yahoo.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, Dom Lachowicz
20 * gives permission to link the code of this program with
21 * non-LGPL Spelling Provider libraries (eg: a MSFT Office
22 * spell checker backend) and distribute linked combinations including
23 * the two. You must obey the GNU Lesser General Public License in all
24 * respects for all of the code used other than said providers. If you modify
25 * this file, you may extend this exception to your version of the
26 * file, but you are not obligated to do so. If you do not wish to
27 * do so, delete this exception statement from your version.
32 bool zemberek_service_is_running ()
34 DBusGConnection *connection;
40 connection = dbus_g_bus_get (DBUS_BUS_SYSTEM,
42 if (connection == NULL) {
46 proxy = dbus_g_proxy_new_for_name_owner (connection,
47 "net.zemberekserver.server.dbus",
48 "/net/zemberekserver/server/dbus/ZemberekDbus",
49 "net.zemberekserver.server.dbus.ZemberekDbusInterface",
52 dbus_g_connection_unref (connection);
57 g_object_unref (proxy);
62 : connection(NULL), proxy(NULL)
67 connection = dbus_g_bus_get (DBUS_BUS_SYSTEM,
69 if (connection == NULL) {
71 throw "couldn't connect to the system bus";
73 proxy = dbus_g_proxy_new_for_name (connection,
74 "net.zemberekserver.server.dbus",
75 "/net/zemberekserver/server/dbus/ZemberekDbus",
76 "net.zemberekserver.server.dbus.ZemberekDbusInterface");
79 throw "couldn't connect to the Zemberek service";
87 g_object_unref (proxy);
89 dbus_g_connection_unref (connection);
93 int Zemberek::checkWord(const char* word) const
97 if (!dbus_g_proxy_call (proxy, "kelimeDenetle", &Error,
98 G_TYPE_STRING,word,G_TYPE_INVALID,
99 G_TYPE_BOOLEAN, &result, G_TYPE_INVALID)) {
100 g_error_free (Error);
112 char** Zemberek::suggestWord(const char* word, size_t *out_n_suggs)
115 GError *Error = NULL;
116 if (!dbus_g_proxy_call (proxy, "oner", &Error,
117 G_TYPE_STRING,word,G_TYPE_INVALID,
118 G_TYPE_STRV, &suggs,G_TYPE_INVALID)) {
119 g_error_free (Error);
122 *out_n_suggs = g_strv_length(suggs);