+PREFIX = /usr
CC = gcc
CFLAGS = -Wall -O2 -g -D_GNU_SOURCE
-INCLUDES = $(shell pkg-config dbus-1 --cflags)
+INCLUDES = $(shell pkg-config --cflags dbus-1 libhildondesktop-1)
LDFLAGS =
-LIBS = $(shell pkg-config dbus-1 --libs)
-PREFIX = /usr
+LIBS_DBUS = $(shell pkg-config --libs dbus-1)
+LIBS_HILDON = $(shell pkg-config --libs libhildondesktop-1)
+HILDON_DESKTOP = $(shell pkg-config --variable=hildonstatusmenudesktopentrydir libhildondesktop-1)
+HILDON_PLUGIN = $(shell pkg-config --variable=hildondesktoplibdir libhildondesktop-1)
+
+all: mtetherd mtetherd-plugin.so
mtetherd: mtetherd.o device.o
- $(CC) $(LDFLAGS) $(LIBS) -o $@ $^
+ $(CC) $(LDFLAGS) $(LIBS_DBUS) -o $@ $^
+
+mtetherd-plugin.so: status.o
+ $(CC) $(LDFLAGS) $(LIBS_HILDON) -shared -o $@ $^
%PHONY: clean install uninstall
clean:
- rm -f *.o mtetherd
+ rm -f *.o mtetherd mtetherd-plugin.so
-install: mtetherd
+install: mtetherd mtetherd-plugin.so
install -m 755 -D mtetherd $(DESTDIR)/$(PREFIX)/sbin/mtetherd
install -m 644 -D event.d-mtetherd $(DESTDIR)/etc/event.d/mtetherd
install -m 644 -D README $(DESTDIR)/$(PREFIX)/share/doc/mtetherd/README
+ install -m 644 -D mtetherd-plugin.desktop $(DESTDIR)/$(HILDON_DESKTOP)/mtetherd-plugin.desktop
+ install -m 755 -D mtetherd-plugin.so $(DESTDIR)/$(HILDON_PLUGIN)/mtetherd-plugin.so
uninstall:
rm -f $(DESTDIR)/$(PREFIX)/sbin/mtetherd
rm -f $(DESTDIR)/etc/event.d/mtetherd
rm -rf $(DESTDIR)/$(PREFIX)/share/doc/mtetherd
+ rm -f $(DESTDIR)/$(HILDON_DESKTOP)/mtetherd-plugin.desktop
+ rm -f $(DESTDIR)/$(HILDON_PLUGIN)/mtetherd-plugin.so
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $^
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-struct Device;
+#ifndef _MTETHERD_DEVICE_H
+#define _MTETHERD_DEVICE_H
-typedef struct Device {
+typedef struct _Device Device;
+
+struct _Device {
char *name;
char *address;
char *startaddress;
char *endaddress;
- struct Device *previous;
- struct Device *next;
-} Device;
+ Device *previous;
+ Device *next;
+};
// Allocates memory for a device structure and copies the name
Device *device_new(const char *name);
// Searches for a device name, starting from start and returns a pointer
// to the matching node, or NULL if no name matches
Device *device_search(Device *start, const char *name);
+
+#endif //_MTETHERD_DEVICE_H
+
--- /dev/null
+[Desktop Entry]
+Name=MTetherD USB Enabler
+Comment=Maemo Tethering Daemon USB networking enabler
+Category=permanent
+Type=default
+X-Path=mtetherd-plugin.so
--- /dev/null
+/*
+ mtetherd
+ (c) 2010 Gregor Riepl <onitake@gmail.com>
+
+ Tethering utility for Maemo
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+
+#include "status.h"
+
+#define MTETHERD_STATUS_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPluginPrivate))
+
+struct _MTetherDStatusPluginPrivate {
+ GtkWidget *button;
+ gboolean neton;
+};
+
+HD_DEFINE_PLUGIN_MODULE(MTetherDStatusPlugin, mtetherd_status_plugin, HD_TYPE_STATUS_MENU_ITEM);
+
+static void mtetherd_status_plugin_class_finalize(MTetherDStatusPluginClass *klass) { }
+
+static void mtetherd_status_plugin_class_init(MTetherDStatusPluginClass *klass) {
+ g_type_class_add_private(klass, sizeof(MTetherDStatusPluginPrivate));
+}
+
+static void set_button_text(GtkWidget *button, gboolean enabled) {
+ if (enabled) {
+ gtk_button_set_label(GTK_BUTTON(button), "Disable USB Networking");
+ } else {
+ gtk_button_set_label(GTK_BUTTON(button), "Enable USB Networking");
+ }
+}
+
+static void enable_usb_net_clicked(GtkWidget *button, gpointer user) {
+ MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(user);
+
+ if (button == plugin->priv->button) {
+ plugin->priv->neton = !plugin->priv->neton;
+ set_button_text(plugin->priv->button, plugin->priv->neton);
+ if (plugin->priv->neton) {
+ // enable
+ } else {
+ // disable
+ }
+ }
+}
+
+static void mtetherd_status_plugin_init(MTetherDStatusPlugin *plugin) {
+ plugin->priv = MTETHERD_STATUS_PLUGIN_GET_PRIVATE(plugin);
+
+ plugin->priv->neton = FALSE;
+ plugin->priv->button = gtk_button_new();
+ set_button_text(plugin->priv->button, plugin->priv->neton);
+ g_signal_connect(plugin->priv->button, "clicked", G_CALLBACK(enable_usb_net_clicked), plugin);
+ gtk_container_add(GTK_CONTAINER(plugin), plugin->priv->button);
+ gtk_widget_show_all(plugin->priv->button);
+ gtk_widget_show(GTK_WIDGET(plugin));
+}
+
--- /dev/null
+/*
+ mtetherd
+ (c) 2010 Gregor Riepl <onitake@gmail.com>
+
+ Tethering utility for Maemo
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _MTETHERD_STATUS_H
+#define _MTETHERD_STATUS_H
+
+#include <libhildondesktop/libhildondesktop.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_MTETHERD_STATUS_PLUGIN (mtetherd_status_plugin_get_type())
+#define MTETHERD_STATUS_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_CAST((object), TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPlugin))
+#define MTETHERD_STATUS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPluginClass))
+#define IS_MTETHERD_STATUS_PLUGIN(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), TYPE_MTETHERD_STATUS_PLUGIN))
+#define IS_MTETHERD_STATUS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_MTETHERD_STATUS_PLUGIN))
+#define MTETHERD_STATUS_PLUGIN_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPluginClass))
+
+typedef struct _MTetherDStatusPluginClass MTetherDStatusPluginClass;
+typedef struct _MTetherDStatusPlugin MTetherDStatusPlugin;
+typedef struct _MTetherDStatusPluginPrivate MTetherDStatusPluginPrivate;
+
+struct _MTetherDStatusPluginClass {
+ HDStatusMenuItemClass parent;
+};
+
+struct _MTetherDStatusPlugin {
+ HDStatusMenuItem parent;
+ MTetherDStatusPluginPrivate *priv;
+};
+
+GType mtetherd_status_plugin_get_type();
+
+G_END_DECLS
+
+#endif //_MTETHERD_STATUS_H
+