1 /* vim: set ts=4 sw=4 et: */
5 * Copyright (C) 2006 Nokia Corporation
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <glib/gi18n-lib.h>
30 #include <libgnomevfs/gnome-vfs.h>
33 #include "maemo-recorder.h"
34 #include "maemo-recorder-ui.h"
37 static gboolean createData(AppData **data);
38 static gboolean destroyData(AppData *data);
41 createData(AppData **data)
43 *data = (AppData *) g_malloc0((gulong)sizeof(AppData));
47 ((AppData *)*data)->state = APPSTATE_READY;
48 ((AppData *)*data)->saved = TRUE;
54 destroyData(AppData *data)
56 g_free(data->openFileName);
57 g_free(data->saveFileName);
64 cbDBus(const gchar *interface, const gchar *method,
65 GArray *arguments, gpointer data,
68 ULOG_INFO("dbus: %s, %s", interface, method);
70 if (!strcmp(method, "top_application"))
71 gtk_window_present(GTK_WINDOW(data));
73 retval->type = DBUS_TYPE_INVALID;
78 main(int argc, char *argv[])
82 guint minor = 0, major = 0, micro = 0, nano = 0;
84 /* Initialise the locale stuff */
85 setlocale(LC_ALL, "");
86 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
87 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
88 textdomain(GETTEXT_PACKAGE);
90 ULOG_OPEN("maemo_recorder " PACKAGE_VERSION);
91 ULOG_INFO("maemo-recorder %s", PACKAGE_VERSION);
93 createData (&appData);
95 appData->osso = osso_initialize(SERVICE_NAME,
96 PACKAGE_VERSION, FALSE, NULL);
97 if (appData->osso == NULL)
99 ULOG_CRIT("osso_initialize() failed");
103 if (osso_mime_set_cb(appData->osso,
104 (osso_mime_cb_f *) (&maemo_recorder_mime_open),
108 ULOG_CRIT("osso_mime_set_cb() failed");
112 gst_init(&argc, &argv);
113 gst_version (&major, &minor, µ, &nano);
116 ULOG_INFO("This program utilises GStreamer %d.%d.%d.%d", major, minor, micro, nano);
117 /* ULOG_DEBUG("GST_SECOND is %llu", GST_SECOND); */
120 gtk_init(&argc, &argv);
122 maemo_recorder_ui_new(appData);
124 ret = osso_rpc_set_default_cb_f(appData->osso,
130 ULOG_CRIT("osso_rpc_set_default_cb_f() failed: %d, exiting", ret);
137 osso_mime_unset_cb(appData->osso);
138 osso_deinitialize(appData->osso);
139 destroyData(appData);
141 ULOG_INFO("maemo-recorder exiting");
148 /* general utilities */
151 setAppState(AppData *app, AppState state)
157 getAppState(AppData *app)
164 audio_format_spec_new(void)
166 AudioFormatSpec *af = NULL;
168 af = (AudioFormatSpec *) g_malloc0(sizeof(AudioFormatSpec));
175 audio_format_spec_free(AudioFormatSpec *af)
180 if (af->mime_type != NULL)
182 g_free(af->mime_type);
183 af->mime_type = NULL;
190 get_mime_type(const AudioFormatSpec *af)
197 get_gst_mime_type(AudioFormat af)
199 /* MUST keep in sync with AudioFormat enum */
200 static char * gst_types[] =
210 return gst_types[af];