diff options
author | Robey Pointer <robey@src.gnome.org> | 2000-07-27 06:01:09 +0000 |
---|---|---|
committer | Robey Pointer <robey@src.gnome.org> | 2000-07-27 06:01:09 +0000 |
commit | fa3c6c012330e9f82841e14cf9a465bf486be815 (patch) | |
tree | bbb9eb5ccf34dcd1d547a3528f23bac7604d5b16 /components | |
parent | 05e9fc4bd192268afc3b173b96e741bc8e428622 (diff) | |
download | nautilus-fa3c6c012330e9f82841e14cf9a465bf486be815.tar.gz |
make the sample time nautilus-view use the new testmachine url instead of old broken eazel24. break time-service of its libnautilus habit and make the nautilus-view do the password dialog instead. fix the nautilus-view's misinterpretation of the time service return value
Diffstat (limited to 'components')
4 files changed, 84 insertions, 47 deletions
diff --git a/components/services/time/nautilus-view/trilobite-eazel-time-view.c b/components/services/time/nautilus-view/trilobite-eazel-time-view.c index caedf237d..a8b300bef 100644 --- a/components/services/time/nautilus-view/trilobite-eazel-time-view.c +++ b/components/services/time/nautilus-view/trilobite-eazel-time-view.c @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Michael Fleming <mfleming@eazel.com> + * Authors: Michael Fleming <mfleming@eazel.com> * Based on nautilus-sample-content-view by Maciej Stachowiak <mjs@eazel.com> * */ @@ -38,6 +38,7 @@ #include <libgnomeui/gnome-stock.h> #include <libnautilus/nautilus-bonobo-ui.h> #include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-password-dialog.h> #include <glade/glade.h> #include <libtrilobite/libtrilobite.h> @@ -47,7 +48,13 @@ * */ +/* FIXME: no way to save the url once you change it */ +/* FIXME: externally visible time server no longer exists */ +#if 0 #define DEFAULT_SERVER_URL "http://eazel24.eazel.com/time.pl" +#else +#define DEFAULT_SERVER_URL "http://testmachine.eazel.com:8888/examples/time/current" +#endif #define DEFAULT_TIME_DIFF "180" #define OAFIID_TIME_SERVICE "OAFIID:trilobite_eazel_time_service:13a2dbd9-84f9-4400-bd9e-bb4575b86894" @@ -66,6 +73,7 @@ struct TrilobiteEazelTimeViewDetails { GtkLabel * p_status; Trilobite_Eazel_Time service; guint timeout_slot; + TrilobiteRootClient *root_client; }; static void trilobite_eazel_time_view_initialize_class (TrilobiteEazelTimeViewClass *klass); @@ -192,8 +200,11 @@ update_time_display( TrilobiteEazelTimeView *view ) set_status_text (view, "Exception: could not get time"); } } else { - /* time service returns '0' if you're within the max time diff delta */ - gtk_entry_set_text (GTK_ENTRY(view->details->p_servertime), ctime( remote_time ? &remote_time : &local_time)); + /* time service returns 0 if you're within the max time diff delta, + * or the number of seconds you'd need to add to be correct. + */ + remote_time += local_time; + gtk_entry_set_text (GTK_ENTRY(view->details->p_servertime), ctime (&remote_time)); } } @@ -204,6 +215,22 @@ update_time_display( TrilobiteEazelTimeView *view ) return TRUE; } +static char * +trilobite_eazel_time_view_get_password (GtkObject *object, const char *prompt) +{ + GtkWidget *dialog; + gboolean rv; + char *tmp; + + dialog = nautilus_password_dialog_new ("Authenticate Me", prompt, "", TRUE); + + rv = nautilus_password_dialog_run_and_block (NAUTILUS_PASSWORD_DIALOG (dialog)); + tmp = nautilus_password_dialog_get_password (NAUTILUS_PASSWORD_DIALOG (dialog)); + gtk_widget_destroy (dialog); + gtk_main_iteration (); + return tmp; +} + static void trilobite_eazel_time_view_initialize_class (TrilobiteEazelTimeViewClass *klass) { @@ -261,10 +288,6 @@ trilobite_eazel_time_view_initialize (TrilobiteEazelTimeView *view) set_status_text (view, STATUS_ERROR_NO_SERVER); g_warning (STATUS_ERROR_NO_SERVER); } - if (p_service) { - bonobo_object_unref (BONOBO_OBJECT(p_service)); - p_service = NULL; - } /* Initialize service params */ @@ -332,6 +355,17 @@ trilobite_eazel_time_view_initialize (TrilobiteEazelTimeView *view) GTK_SIGNAL_FUNC (load_location_callback), view); + /* set up callbacks to ask for the root password */ + view->details->root_client = trilobite_root_client_new (); + trilobite_root_client_attach (view->details->root_client, p_service); + gtk_signal_connect (GTK_OBJECT (view->details->root_client), "need_password", + GTK_SIGNAL_FUNC (trilobite_eazel_time_view_get_password), NULL); + + if (p_service) { + bonobo_object_unref (BONOBO_OBJECT(p_service)); + p_service = NULL; + } + #if 0 /* * Get notified when our bonobo control is activated so we @@ -369,6 +403,7 @@ trilobite_eazel_time_view_destroy (GtkObject *object) g_free (view->details->max_time_diff); Trilobite_Eazel_Time_unref (view->details->service, NULL); + trilobite_root_client_unref (GTK_OBJECT (view->details->root_client)); gtk_timeout_remove (view->details->timeout_slot); @@ -380,6 +415,7 @@ trilobite_eazel_time_view_destroy (GtkObject *object) } + /** * trilobite_eazel_time_view_get_nautilus_view: * diff --git a/components/services/time/service/Makefile.am b/components/services/time/service/Makefile.am index 827c619b0..44accabaa 100644 --- a/components/services/time/service/Makefile.am +++ b/components/services/time/service/Makefile.am @@ -76,13 +76,9 @@ trilobite_eazel_time_service_SOURCES = \ trilobite-eazel-time-service-skels.c \ $(NULL) -## FIXME: bugzilla.eazel.com 1624 -## dep on libnautilus-extensions trilobite_eazel_time_service_LDADD = \ $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite-service.la \ - $(top_builddir)/libnautilus-extensions/nautilus-password-dialog.o \ - $(top_builddir)/libnautilus-extensions/nautilus-caption-table.o \ $(NULL) diff --git a/components/services/time/service/trilobite-eazel-time-service.c b/components/services/time/service/trilobite-eazel-time-service.c index 03df18178..7c600f3f5 100644 --- a/components/services/time/service/trilobite-eazel-time-service.c +++ b/components/services/time/service/trilobite-eazel-time-service.c @@ -36,8 +36,12 @@ #include <ghttp.h> #include <time.h> -/* This is the parent class pointer */ +/* might wanna make this configable */ +/* # of seconds to wait between bugging the time server again */ +#define TIME_SERVER_CACHE_TIMEOUT 60 + +/* This is the parent class pointer */ static GtkObjectClass *trilobite_eazel_time_service_parent_class; /* prototypes */ @@ -61,6 +65,7 @@ impl_Trilobite_Eazel_Time_Service_set_max_difference (impl_POA_Trilobite_Eazel_T CORBA_Environment *ev) { service->object->private->maxd = maxd; + service->object->private->time_obtained = 0; } static void @@ -72,6 +77,7 @@ impl_Trilobite_Eazel_Time_Service_set_time_url (impl_POA_Trilobite_Eazel_Time_Se g_free (service->object->private->time_url); } service->object->private->time_url = g_strdup (url); + service->object->private->time_obtained = 0; } static CORBA_unsigned_long @@ -86,10 +92,19 @@ impl_Trilobite_Eazel_Time_Service_check_time (impl_POA_Trilobite_Eazel_Time_Ser local_time = time (NULL); server_time = trilobite_eazel_time_service_get_server_time (service->object, ev); +#if 0 g_message ("Local time : %ld", local_time); g_message ("Server time : %ld", server_time); g_message ("Diff is : %d", abs (server_time - local_time)); g_message ("Allowed d : %d", service->object->private->maxd); +#endif + if (server_time == 0) { + g_warning ("Unable to get server time"); + } else if (abs (server_time - local_time) > service->object->private->maxd) { + g_warning ("Time off by %d, max allowed diff is %d", + abs (server_time - local_time), + service->object->private->maxd); + } /* If we did not get the time, raise an exception */ if (server_time != 0) { @@ -106,13 +121,11 @@ static void impl_Trilobite_Eazel_Time_Service_update_time (impl_POA_Trilobite_Eazel_Time_Service *service, CORBA_Environment *ev) { - gboolean get_time; + time_t server_time; TrilobiteRootHelper *root_helper; GList *args; char *tmp; - get_time = FALSE; - root_helper = gtk_object_get_data (GTK_OBJECT (service->object), "trilobite-root-helper"); if (trilobite_root_helper_start (root_helper) != TRILOBITE_ROOT_HELPER_SUCCESS) { Trilobite_Eazel_Time_NotPermitted *exn; @@ -121,31 +134,12 @@ impl_Trilobite_Eazel_Time_Service_update_time (impl_POA_Trilobite_Eazel_Time_Se return; } - /* if we have the server time, and it's less then 10 minutes old, use it */ - if (service->object->private->server_time != 0) { - if (abs (service->object->private->time_obtained - time (NULL)) > 60*10) { - get_time = TRUE; - } - } else { - get_time = TRUE; - } - - if (get_time == TRUE) { - time_t server_time; - - server_time = trilobite_eazel_time_service_get_server_time (service->object, ev); - if (server_time == 0) { - return; - } - - } else { - time_t diff; - - diff = time (NULL) - service->object->private->time_obtained; - service->object->private->server_time += diff; + server_time = trilobite_eazel_time_service_get_server_time (service->object, ev); + if (server_time == 0) { + return; } - tmp = g_strdup_printf ("%ld", service->object->private->server_time); + tmp = g_strdup_printf ("%ld", server_time); args = g_list_prepend (NULL, tmp); if (trilobite_root_helper_run (root_helper, TRILOBITE_ROOT_HELPER_RUN_SET_TIME, args, NULL) != TRILOBITE_ROOT_HELPER_SUCCESS) { @@ -237,11 +231,11 @@ trilobite_eazel_time_service_create_corba_object (BonoboObject *service) { g_assert (TRILOBITE_IS_EAZEL_TIME_SERVICE (service)); CORBA_exception_init (&ev); - - servant = (impl_POA_Trilobite_Eazel_Time_Service*)g_new0 (PortableServer_Servant,1); - ((POA_Trilobite_Eazel_Time*) servant)->vepv = TRILOBITE_EAZEL_TIME_SERVICE_CLASS ( GTK_OBJECT (service)->klass)->servant_vepv; + + servant = g_new0 (impl_POA_Trilobite_Eazel_Time_Service, 1); + ((POA_Trilobite_Eazel_Time *)servant)->vepv = TRILOBITE_EAZEL_TIME_SERVICE_CLASS ( GTK_OBJECT (service)->klass)->servant_vepv; POA_Trilobite_Eazel_Time__init (servant, &ev); - ORBIT_OBJECT_KEY (((POA_Trilobite_Eazel_Time*)servant)->_private)->object = NULL; + ORBIT_OBJECT_KEY (((POA_Trilobite_Eazel_Time *)servant)->_private)->object = NULL; if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("Cannot instantiate Trilobite_Eazel_Time corba object"); @@ -418,6 +412,14 @@ trilobite_eazel_time_service_get_server_time (TrilobiteEazelTimeService *service CORBA_Environment *ev) { time_t result; + time_t now; + + now = time (NULL); + if ((service->private->time_obtained > 0) && + (now - service->private->time_obtained < TIME_SERVER_CACHE_TIMEOUT)) { + /* don't bug the time server again -- just extrapolate the time */ + return service->private->server_time + (now - service->private->time_obtained); + } switch (service->private->method) { case REQUEST_BY_HTTP: @@ -429,7 +431,9 @@ trilobite_eazel_time_service_get_server_time (TrilobiteEazelTimeService *service }; service->private->server_time = result; - service->private->time_obtained = time (NULL); + if (result != 0) { + service->private->time_obtained = time (NULL); + } return result; } diff --git a/components/services/trilobite/libtrilobite/trilobite-service-passwordquery.c b/components/services/trilobite/libtrilobite/trilobite-service-passwordquery.c index e46fda256..575084e25 100644 --- a/components/services/trilobite/libtrilobite/trilobite-service-passwordquery.c +++ b/components/services/trilobite/libtrilobite/trilobite-service-passwordquery.c @@ -30,10 +30,7 @@ #include "trilobite-service.h" #include "trilobite-service-passwordquery-public.h" #include "trilobite-service-passwordquery-private.h" -/* FIXME: bugzilla.eazel.com 1624 - this makes libtrilobite dependent on libnautilus-extensions -*/ -#include <libnautilus-extensions/nautilus-password-dialog.h> + enum { ARG_0, @@ -315,6 +312,9 @@ trilobite_passwordquery_get_password (TrilobiteRootHelper *roothelper, TrilobitePasswordQuery *trilobite) { if (trilobite->private->client == CORBA_OBJECT_NIL) { + /* you lose. */ + return NULL; +#if 0 GtkWidget *dialog; gboolean rv; char *tmp; @@ -332,6 +332,7 @@ trilobite_passwordquery_get_password (TrilobiteRootHelper *roothelper, gtk_widget_destroy (dialog); gtk_main_iteration (); return tmp; +#endif } else { CORBA_Environment ev; CORBA_char *tmp; |