#include <gtk/gtk.h>
#include <hildon/hildon.h>
+#include <time.h>
+#include <stdlib.h>
#include "lib-timeout-home-widget.h"
#include "location-provider.h"
+#include "coordinate-system.h"
HD_DEFINE_PLUGIN_MODULE (TimeOutPlugin, time_out_plugin, HD_TYPE_HOME_PLUGIN_ITEM)
char debugStr[1024];
#define debug(...) sprintf(debugStr, __VA_ARGS__); printDebug(debugStr)
+
+#define IDLE 0
+#define SEARCHING_LOCATION 1
+#define LOCATION_RECEIVED 2
+
+static int widget_state = IDLE;
+
+void get_me_home(KKJ x, KKJ y)
+{
+ time_t t;
+ struct tm *tmp;
+
+ char hour[4];
+ char minute[4];
+
+ // Get the current time
+ t = time(NULL);
+ tmp = localtime(&t);
+ if (tmp == NULL) {
+ return;
+ }
+
+ // Format needed parts from the current time
+ strftime(hour, sizeof(hour), "%H", tmp);
+ strftime(minute, sizeof(minute), "%M", tmp);
+
+ debug("Hour %s minute %s", hour, minute);
+
+ // Format the URL
+
+
+ // Open the browser
+ char command[1024];
+ sprintf(command, "browser_dbuscmd.sh load_url http://www.reittiopas.fi");
+ system(command);
+
+ widget_state = IDLE;
+}
+
static void location_listener(double latitude, double longitude)
{
- debug("got location: %f, %f", latitude, longitude);
+ KKJ x, y;
+
+// debug("got location: %f, %f", latitude, longitude);
+
+ if (widget_state == SEARCHING_LOCATION) {
+ widget_state = LOCATION_RECEIVED;
+
+ WGS84lola_to_KKJxy(longitude, latitude, &x, &y);
+
+ get_me_home(x, y);
+ }
}
int locationTrackingOn = 0;
void search_button_clicked(GtkButton *button, gpointer user_data)
{
+ widget_state = SEARCHING_LOCATION;
+
if (!locationTrackingOn) {
// Setup location tracking
setup_location_provider();
// hildon_picker_button_set_active (action, 0);
GtkWidget* getmehomeButton = hildon_gtk_button_new(HILDON_SIZE_AUTO);
- gtk_button_set_label(GTK_BUTTON(getmehomeButton), "Search");
+ gtk_button_set_label(GTK_BUTTON(getmehomeButton), "Get Me Home");
g_signal_connect(getmehomeButton, "clicked", G_CALLBACK(search_button_clicked), NULL);
gtk_widget_show_all(GTK_WIDGET(contents));
return GTK_WIDGET(contents);
+
+ /*GtkWidget* getmehomeButton = hildon_gtk_button_new(HILDON_SIZE_AUTO);
+ gtk_button_set_label(GTK_BUTTON(getmehomeButton), "Get Me Home");
+ g_signal_connect(getmehomeButton, "clicked", G_CALLBACK(search_button_clicked), NULL);
+
+ gtk_widget_show_all(GTK_WIDGET(getmehomeButton));
+
+ return GTK_WIDGET(getmehomeButton);*/
}
static void