1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
*
* 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 2 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: J Shane Culpepper <pepper@eazel.com>
*/
#include <config.h>
#include "nautilus-summary-view.h"
#include "shared-service-widgets.h"
#include "shared-service-utilities.h"
#include <gnome-xml/tree.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-global-preferences.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-font-factory.h>
#include <stdio.h>
#include <unistd.h>
#include <orb/orbit.h>
#include <liboaf/liboaf.h>
#include <libtrilobite/eazelproxy.h>
#include <libtrilobite/libammonite.h>
#include <bonobo/bonobo-main.h>
#define DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF"
typedef enum {
Pending_None,
Pending_Login,
} SummaryPendingOperationType;
/* A NautilusContentView's private information. */
struct _NautilusSummaryViewDetails {
char *uri;
NautilusView *nautilus_view;
GtkWidget *form;
GtkWidget *form_title;
/* Login Frame Widgets */
GtkWidget *username_label;
GtkWidget *password_label;
GtkWidget *username_entry;
GtkWidget *password_entry;
GtkWidget *login_button;
GtkWidget *login_label;
GtkWidget *maintenance_button;
GtkWidget *maintenance_label;
GtkWidget *register_button;
GtkWidget *register_label;
GtkWidget *logout_button;
GtkWidget *logout_label;
GtkWidget *community_button;
GtkWidget *community_label;
GtkWidget *feedback_text;
/* EazelProxy -- for logging in/logging out */
EazelProxy_UserControl user_control;
SummaryPendingOperationType pending_operation;
EazelProxy_AuthnCallback authn_callback;
};
static void nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass);
static void nautilus_summary_view_initialize (NautilusSummaryView *view);
static void nautilus_summary_view_destroy (GtkObject *object);
static void summary_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusSummaryView *view);
static void generate_summary_form (NautilusSummaryView *view);
static void login_button_cb (GtkWidget *button,
NautilusSummaryView *view);
static void maintenance_button_cb (GtkWidget *button,
NautilusSummaryView *view);
static void logout_button_cb (GtkWidget *button,
NautilusSummaryView *view);
static void entry_changed_cb (GtkWidget *entry,
NautilusSummaryView *view);
static void goto_vault_cb (GtkWidget *button,
NautilusSummaryView *view);
static void update_netscape_cb (GtkWidget *button,
NautilusSummaryView *view);
static void register_button_cb (GtkWidget *button,
NautilusSummaryView *view);
static void community_button_cb (GtkWidget *button,
NautilusSummaryView *view);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSummaryView, nautilus_summary_view, GTK_TYPE_EVENT_BOX)
static void
generate_summary_form (NautilusSummaryView *view)
{
GtkWidget *frame;
GtkTable *parent;
GtkWidget *title;
GtkWidget *small_title;
GtkWidget *temp_box;
GtkWidget *temp_hbox;
GtkWidget *temp_icon;
GtkWidget *temp_label;
GtkWidget *temp_button;
GtkTable *login_table;
GtkTable *services_table;
GtkTable *service_news_table;
GtkTable *updates_table;
GtkWidget *button_box;
GdkFont *font;
/* allocate the parent box to hold everything */
view->details->form = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (view), view->details->form);
gtk_widget_show (view->details->form);
/* setup the title */
title = create_summary_service_title_top_widget ("You are not logged in.");
gtk_box_pack_start (GTK_BOX (view->details->form), title, FALSE, FALSE, 0);
gtk_widget_show (title);
/* Create the Parent Table to hold the 4 frames */
parent = GTK_TABLE (gtk_table_new (3, 2, FALSE));
/* Create the Services Listing Frame */
frame = gtk_frame_new ("");
gtk_widget_show (frame);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_table_attach (GTK_TABLE (parent), frame,
0, 1,
0, 1,
GTK_FILL | GTK_EXPAND,
GTK_FILL | GTK_EXPAND,
0, 0);
/* create the parent services list box */
temp_box = gtk_vbox_new (FALSE, 0);
/* setup the title */
title = create_summary_service_title_bottom_widget ("Services");
gtk_box_pack_start (GTK_BOX (temp_box), title, FALSE, FALSE, 0);
gtk_widget_show (title);
/* Create the parent table to hold 3 rows */
services_table = GTK_TABLE (gtk_table_new (5, 3, FALSE));
/* Generate first column with fake icon */
temp_hbox = gtk_hbox_new (TRUE, 4);
temp_icon = create_image_widget ("vault-service-icon.png", DEFAULT_BACKGROUND_COLOR);
g_assert (temp_icon != NULL);
gtk_box_pack_start (GTK_BOX (temp_hbox), temp_icon, 0, 0, 0);
gtk_widget_show (temp_icon);
gtk_table_attach (services_table, temp_hbox, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (temp_hbox);
/* Generate second Column with fake service title and summary */
temp_label = gtk_label_new ("Vault Service:\n Your remote file storage");
font = nautilus_font_factory_get_font_from_preferences (12);
nautilus_gtk_widget_set_font (temp_label, font);
gdk_font_unref (font);
gtk_table_attach (services_table, temp_label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (temp_label);
/* Add the redirect button to the third column */
temp_button = gtk_button_new ();
temp_label = gtk_label_new (" Go to Vault ");
gtk_widget_show (temp_label);
gtk_container_add (GTK_CONTAINER (temp_button), temp_label);
temp_hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (temp_hbox), temp_button, FALSE, FALSE, 13);
gtk_signal_connect (GTK_OBJECT (temp_button), "clicked", GTK_SIGNAL_FUNC (goto_vault_cb), view);
gtk_widget_show (temp_button);
gtk_table_attach (services_table, temp_hbox, 2, 3, 0, 1, 0, 0, 0, 0);
gtk_widget_show (temp_hbox);
/* draw parent vbox and connect it to the login frame */
gtk_box_pack_start (GTK_BOX (temp_box), GTK_WIDGET (services_table), 0, 0, 0);
gtk_widget_show (GTK_WIDGET (services_table));
gtk_widget_show (temp_box);
gtk_container_add (GTK_CONTAINER (frame), temp_box);
/* Create the Login Frame */
frame = gtk_frame_new ("");
gtk_widget_show (frame);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_table_attach (GTK_TABLE (parent), frame,
1, 2,
0, 1,
GTK_FILL | GTK_EXPAND,
GTK_FILL | GTK_EXPAND,
0, 0);
/* create the parent login box */
temp_box = gtk_vbox_new (FALSE, 0);
/* setup the title */
title = create_summary_service_large_grey_header_widget ("Options");
gtk_box_pack_start (GTK_BOX (temp_box), title, FALSE, FALSE, 0);
gtk_widget_show (title);
login_table = GTK_TABLE (gtk_table_new (4, 2, TRUE));
/* username label */
view->details->username_label = gtk_label_new ("User Name:");
font = nautilus_font_factory_get_font_from_preferences (16);
nautilus_gtk_widget_set_font (view->details->username_label, font);
gdk_font_unref (font);
gtk_table_attach (login_table, view->details->username_label, 0, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (view->details->username_label);
/*username text entry */
view->details->username_entry = gtk_entry_new_with_max_length (36);
gtk_table_attach (login_table, view->details->username_entry, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (view->details->username_entry);
/* password label */
view->details->password_label = gtk_label_new ("Password:");
font = nautilus_font_factory_get_font_from_preferences (16);
nautilus_gtk_widget_set_font (view->details->password_label, font);
gdk_font_unref (font);
gtk_table_attach (login_table, view->details->password_label, 0, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (view->details->password_label);
/* password text entry */
view->details->password_entry = gtk_entry_new_with_max_length (36);
gtk_table_attach (login_table, view->details->password_entry, 1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
gtk_entry_set_visibility (GTK_ENTRY (view->details->password_entry), FALSE);
gtk_widget_show (view->details->password_entry);
gtk_box_pack_start (GTK_BOX (temp_box), GTK_WIDGET (login_table), 0, 0, 0);
gtk_widget_show (GTK_WIDGET (login_table));
gtk_signal_connect (GTK_OBJECT (view->details->username_entry), "changed", GTK_SIGNAL_FUNC (entry_changed_cb), view);
gtk_signal_connect (GTK_OBJECT (view->details->password_entry), "changed", GTK_SIGNAL_FUNC (entry_changed_cb), view);
/* login button */
view->details->login_button = gtk_button_new ();
view->details->login_label = gtk_label_new (" I'm ready to login! ");
gtk_widget_show (view->details->login_label);
gtk_container_add (GTK_CONTAINER (view->details->login_button), view->details->login_label);
button_box = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (button_box), view->details->login_button, FALSE, FALSE, 21);
gtk_signal_connect (GTK_OBJECT (view->details->login_button), "clicked", GTK_SIGNAL_FUNC (login_button_cb), view);
gtk_widget_set_sensitive (view->details->login_button, FALSE);
gtk_widget_show (view->details->login_button);
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (temp_box), button_box, FALSE, FALSE, 4);
/* register button */
view->details->register_button = gtk_button_new ();
view->details->register_label = gtk_label_new (" Register Now! ");
gtk_widget_show (view->details->register_label);
gtk_container_add (GTK_CONTAINER (view->details->register_button), view->details->register_label);
button_box = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (button_box), view->details->register_button, FALSE, FALSE, 21);
gtk_box_pack_start (GTK_BOX (temp_box), view->details->register_button, FALSE, FALSE, 1);
gtk_signal_connect (GTK_OBJECT (view->details->register_button), "clicked", GTK_SIGNAL_FUNC (register_button_cb), view);
gtk_widget_show (view->details->register_button);
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (temp_box), button_box, FALSE, FALSE, 4);
/* maintenance button */
view->details->maintenance_button = gtk_button_new ();
view->details->maintenance_label = gtk_label_new (" I need some help! ");
gtk_widget_show (view->details->maintenance_label);
gtk_container_add (GTK_CONTAINER (view->details->maintenance_button), view->details->maintenance_label);
button_box = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (button_box), view->details->maintenance_button, FALSE, FALSE, 21);
gtk_box_pack_start (GTK_BOX (temp_box), view->details->maintenance_button, FALSE, FALSE, 1);
gtk_signal_connect (GTK_OBJECT (view->details->maintenance_button), "clicked", GTK_SIGNAL_FUNC (maintenance_button_cb), view);
gtk_widget_show (view->details->maintenance_button);
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (temp_box), button_box, FALSE, FALSE, 4);
/* logout button */
view->details->logout_button = gtk_button_new ();
view->details->logout_label = gtk_label_new (" Log me out! ");
gtk_widget_show (view->details->logout_label);
gtk_container_add (GTK_CONTAINER (view->details->logout_button), view->details->logout_label);
button_box = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (button_box), view->details->logout_button, FALSE, FALSE, 21);
gtk_box_pack_start (GTK_BOX (temp_box), view->details->logout_button, FALSE, FALSE, 1);
gtk_signal_connect (GTK_OBJECT (view->details->logout_button), "clicked", GTK_SIGNAL_FUNC (logout_button_cb), view);
gtk_widget_show (view->details->logout_button);
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (temp_box), button_box, FALSE, FALSE, 4);
/* community button */
view->details->community_button = gtk_button_new ();
view->details->community_label = gtk_label_new (" Go to Eazel Community! ");
gtk_widget_show (view->details->community_label);
gtk_container_add (GTK_CONTAINER (view->details->community_button), view->details->community_label);
button_box = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (button_box), view->details->community_button, FALSE, FALSE, 21);
gtk_box_pack_start (GTK_BOX (temp_box), view->details->community_button, FALSE, FALSE, 1);
gtk_signal_connect (GTK_OBJECT (view->details->community_button), "clicked", GTK_SIGNAL_FUNC (community_button_cb), view);
gtk_widget_show (view->details->community_button);
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (temp_box), button_box, FALSE, FALSE, 4);
/* draw parent vbox and connect it to the login frame */
gtk_widget_show (temp_box);
gtk_container_add (GTK_CONTAINER (frame), temp_box);
/* Create the Service News Frame */
frame = gtk_frame_new ("");
gtk_widget_show (frame);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_table_attach (GTK_TABLE (parent), frame,
0, 2,
1, 2,
GTK_FILL | GTK_EXPAND,
GTK_FILL | GTK_EXPAND,
0, 0);
/* create the parent service news box and a table to hold the data */
temp_box = gtk_vbox_new (FALSE, 0);
/* setup the large grey header */
title = create_summary_service_large_grey_header_widget ("Eazel News and Updates");
gtk_box_pack_start (GTK_BOX (temp_box), title, FALSE, FALSE, 0);
gtk_widget_show (title);
/* setup the small grey header */
small_title = create_summary_service_small_grey_header_widget ("Service News");
gtk_box_pack_start (GTK_BOX (temp_box), small_title, FALSE, FALSE, 0);
gtk_widget_show (small_title);
service_news_table = GTK_TABLE (gtk_table_new (4, 2, FALSE));
/* Generate first column with fake icon */
temp_hbox = gtk_hbox_new (TRUE, 4);
temp_icon = create_image_widget ("emblem-changed.gif", DEFAULT_BACKGROUND_COLOR);
g_assert (temp_icon != NULL);
gtk_box_pack_start (GTK_BOX (temp_hbox), temp_icon, 0, 0, 0);
gtk_widget_show (temp_icon);
gtk_table_attach (service_news_table, temp_hbox, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (temp_hbox);
/* Generate second Column with fake service title and summary */
temp_label = gtk_label_new ("The Eazel servers will be down this Friday!");
font = nautilus_font_factory_get_font_from_preferences (12);
nautilus_gtk_widget_set_font (temp_label, font);
gdk_font_unref (font);
gtk_table_attach (service_news_table, temp_label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (temp_label);
/* draw parent vbox and connect it to the login frame */
gtk_box_pack_start (GTK_BOX (temp_box), GTK_WIDGET (service_news_table), 0, 0, 0);
gtk_widget_show (GTK_WIDGET (service_news_table));
gtk_widget_show (temp_box);
gtk_container_add (GTK_CONTAINER (frame), temp_box);
/* Create the Update News Frame */
frame = gtk_frame_new ("");
gtk_widget_show (frame);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_table_attach (GTK_TABLE (parent), frame,
0, 2,
2, 3,
GTK_FILL | GTK_EXPAND,
GTK_FILL | GTK_EXPAND,
0, 0);
/* create the parent login box and a table to hold the labels and text entries */
temp_box = gtk_vbox_new (FALSE, 0);
/* setup the small grey header */
small_title = create_summary_service_small_grey_header_widget ("Software Updates");
gtk_box_pack_start (GTK_BOX (temp_box), small_title, FALSE, FALSE, 0);
gtk_widget_show (small_title);
updates_table = GTK_TABLE (gtk_table_new (4, 3, FALSE));
/* Generate first column with fake icon */
temp_hbox = gtk_hbox_new (TRUE, 4);
temp_icon = create_image_widget ("netscape.png", DEFAULT_BACKGROUND_COLOR);
g_assert (temp_icon != NULL);
gtk_box_pack_start (GTK_BOX (temp_hbox), temp_icon, 0, 0, 0);
gtk_widget_show (temp_icon);
gtk_table_attach (updates_table, temp_hbox, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (temp_hbox);
/* Generate second Column with fake service title and summary */
temp_label = gtk_label_new ("Netscape Communicator 4.75\n Everyone's favorite web browser.");
font = nautilus_font_factory_get_font_from_preferences (12);
nautilus_gtk_widget_set_font (temp_label, font);
gdk_font_unref (font);
gtk_table_attach (updates_table, temp_label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (temp_label);
/* Add the redirect button to the third column */
temp_button = gtk_button_new ();
temp_label = gtk_label_new (" Update Netscape Now! ");
gtk_widget_show (temp_label);
gtk_container_add (GTK_CONTAINER (temp_button), temp_label);
temp_hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (temp_hbox), temp_button, FALSE, FALSE, 13);
gtk_signal_connect (GTK_OBJECT (temp_button), "clicked", GTK_SIGNAL_FUNC (update_netscape_cb), view);
gtk_widget_show (temp_button);
gtk_table_attach (updates_table, temp_hbox, 2, 3, 0, 1, 0, 0, 0, 0);
gtk_widget_show (temp_hbox);
/* draw parent vbox and connect it to the login frame */
gtk_box_pack_start (GTK_BOX (temp_box), GTK_WIDGET (updates_table), 0, 0, 0);
gtk_widget_show (GTK_WIDGET (updates_table));
gtk_widget_show (temp_box);
gtk_container_add (GTK_CONTAINER (frame), temp_box);
/* draw the parent frame box */
gtk_box_pack_start (GTK_BOX (view->details->form), GTK_WIDGET (parent), 0, 0, 4);
gtk_widget_show (GTK_WIDGET (parent));
}
/* callback to enable / disable the login button when something is typed into the field */
static void
entry_changed_cb (GtkWidget *entry, NautilusSummaryView *view)
{
char *user_name;
char *password;
gboolean button_enabled;
user_name = gtk_entry_get_text (GTK_ENTRY (view->details->username_entry));
password = gtk_entry_get_text (GTK_ENTRY (view->details->password_entry));
button_enabled = user_name && strlen (user_name) && password && strlen (password)
&& (Pending_None == view->details->pending_operation);
gtk_widget_set_sensitive (view->details->login_button, button_enabled);
}
static void
authn_cb_succeeded (const EazelProxy_User *user, gpointer state, CORBA_Environment *ev)
{
NautilusSummaryView *view;
view = NAUTILUS_SUMMARY_VIEW (state);
g_assert (Pending_Login == view->details->pending_operation);
view->details->pending_operation = Pending_None;
gtk_widget_set_sensitive (view->details->login_button, TRUE);
/* FIXME bugzilla.eazel.com 2743: what now? */
g_message ("Login succeeded");
bonobo_object_unref (BONOBO_OBJECT (view->details->nautilus_view));
}
static void
authn_cb_failed (const EazelProxy_User *user, const EazelProxy_AuthnFailInfo *info, gpointer state, CORBA_Environment *ev)
{
NautilusSummaryView *view;
view = NAUTILUS_SUMMARY_VIEW (state);
g_assert (Pending_Login == view->details->pending_operation);
view->details->pending_operation = Pending_None;
gtk_widget_set_sensitive (view->details->login_button, TRUE);
/* FIXME bugzilla.eazel.com 2744: what now? */
g_message ("Login FAILED");
bonobo_object_unref (BONOBO_OBJECT (view->details->nautilus_view));
}
/* callback to handle the login button. Right now only does a simple redirect. */
static void
login_button_cb (GtkWidget *button, NautilusSummaryView *view)
{
char *user_name;
char *password;
EazelProxy_AuthnInfo *authinfo;
CORBA_Environment ev;
AmmoniteAuthCallbackWrapperFuncs cb_funcs = {
authn_cb_succeeded, authn_cb_failed
};
CORBA_exception_init (&ev);
g_assert (Pending_None == view->details->pending_operation);
gtk_widget_set_sensitive (view->details->login_button, FALSE);
if (CORBA_OBJECT_NIL != view->details->user_control) {
view->details->authn_callback = ammonite_auth_callback_wrapper_new (bonobo_poa(), &cb_funcs, view);
user_name = gtk_entry_get_text (GTK_ENTRY (view->details->username_entry));
password = gtk_entry_get_text (GTK_ENTRY (view->details->password_entry));
authinfo = EazelProxy_AuthnInfo__alloc ();
authinfo->username = CORBA_string_dup (user_name);
authinfo->password = CORBA_string_dup (password);
authinfo->services_redirect_uri = CORBA_string_dup ("");
authinfo->services_login_path = CORBA_string_dup ("");
/* Ref myself until the callback returns */
bonobo_object_ref (BONOBO_OBJECT (view->details->nautilus_view));
view->details->pending_operation = Pending_Login;
EazelProxy_UserControl_authenticate_user (
view->details->user_control,
authinfo, TRUE,
view->details->authn_callback, &ev
);
if (CORBA_NO_EXCEPTION != ev._major) {
g_warning ("Exception during EazelProxy login");
/* FIXME bugzilla.eazel.com 2745: cleanup after fail here */
}
g_free (user_name);
g_free (password);
}
/* go_to_uri (view->details->nautilus_view, "eazel-inventory:");*/
CORBA_exception_free (&ev);
}
/* callback to handle the logout button. Right now only does a simple redirect. */
static void
logout_button_cb (GtkWidget *button, NautilusSummaryView *view)
{
CORBA_Environment ev;
EazelProxy_UserList *users;
CORBA_unsigned_long i;
CORBA_exception_init (&ev);
if (CORBA_OBJECT_NIL != view->details->user_control) {
/* Get list of currently active users */
users = EazelProxy_UserControl_get_active_users (
view->details->user_control, &ev
);
if (CORBA_NO_EXCEPTION != ev._major) {
g_message ("Exception while logging out user");
return;
}
/* Log out the current default user */
for (i = 0; i < users->_length ; i++) {
EazelProxy_User *cur;
cur = users->_buffer + i;
if (cur->is_default) {
g_message ("Logging out user '%s'", cur->user_name);
EazelProxy_UserControl_logout_user (
view->details->user_control,
cur->proxy_port, &ev
);
break;
}
}
CORBA_free (users);
}
/* go_to_uri (view->details->nautilus_view, "eazel-inventory:"); */
CORBA_exception_free (&ev);
}
/* callback to handle the maintenance button. Right now only does a simple redirect. */
static void
maintenance_button_cb (GtkWidget *button, NautilusSummaryView *view)
{
go_to_uri (view->details->nautilus_view, "http://www.eazel.com/services.html");
}
/* callback to handle the community button. Right now only does a simple redirect. */
static void
community_button_cb (GtkWidget *button, NautilusSummaryView *view)
{
go_to_uri (view->details->nautilus_view, "http://www.eazel.com/services.html");
}
/* callback to handle the register button. Right now only does a simple redirect. */
static void
register_button_cb (GtkWidget *button, NautilusSummaryView *view)
{
go_to_uri (view->details->nautilus_view, "http://www.eazel.com/register.html");
}
/* callback to handle the goto vault button. Right now only does a simple redirect. */
static void
goto_vault_cb (GtkWidget *button, NautilusSummaryView *view)
{
go_to_uri (view->details->nautilus_view, "http://www.eazel.com/services.html");
}
/* callback to handle install netscape button. Right now only does a simple redirect. */
static void
update_netscape_cb (GtkWidget *button, NautilusSummaryView *view)
{
go_to_uri (view->details->nautilus_view, "http://www.eazel.com");
}
static void
nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
parent_class = gtk_type_class (gtk_event_box_get_type ());
object_class->destroy = nautilus_summary_view_destroy;
}
static void
nautilus_summary_view_initialize (NautilusSummaryView *view)
{
CORBA_Environment ev;
NautilusBackground *background;
CORBA_exception_init (&ev);
view->details = g_new0 (NautilusSummaryViewDetails, 1);
view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view));
gtk_signal_connect (GTK_OBJECT (view->details->nautilus_view),
"load_location",
GTK_SIGNAL_FUNC (summary_load_location_callback),
view);
background = nautilus_get_widget_background (GTK_WIDGET (view));
nautilus_background_set_color (background, SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
view->details->user_control = (EazelProxy_UserControl) oaf_activate_from_id (IID_EAZELPROXY, 0, NULL, &ev);
if ( CORBA_NO_EXCEPTION != ev._major ) {
/* FIXME bugzilla.eazel.com 2740: user should be warned that Ammonite may not be installed */
g_warning ("Couldn't instantiate eazel-proxy\n");
view->details->user_control = CORBA_OBJECT_NIL;
}
gtk_widget_show (GTK_WIDGET (view));
CORBA_exception_free (&ev);
}
static void
nautilus_summary_view_destroy (GtkObject *object)
{
NautilusSummaryView *view;
CORBA_Environment ev;
CORBA_exception_init (&ev);
view = NAUTILUS_SUMMARY_VIEW (object);
if (view->details->uri) {
g_free (view->details->uri);
}
g_assert (Pending_None == view->details->pending_operation);
CORBA_Object_release (view->details->user_control, &ev);
g_free (view->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
CORBA_exception_free (&ev);
}
NautilusView *
nautilus_summary_view_get_nautilus_view (NautilusSummaryView *view)
{
return view->details->nautilus_view;
}
void
nautilus_summary_view_load_uri (NautilusSummaryView *view,
const char *uri)
{
/* dispose of any old uri and copy in the new one */
g_free (view->details->uri);
view->details->uri = g_strdup (uri);
/* dispose of any old form that was installed */
if (view->details->form != NULL) {
gtk_widget_destroy (view->details->form);
view->details->form = NULL;
}
generate_summary_form (view);
}
static void
summary_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusSummaryView *view)
{
g_assert (nautilus_view == view->details->nautilus_view);
nautilus_view_report_load_underway (nautilus_view);
nautilus_summary_view_load_uri (view, location);
nautilus_view_report_load_complete (nautilus_view);
}
|