diff options
author | Tim Niemueller <tim@niemueller.de> | 2006-08-19 15:13:10 +0000 |
---|---|---|
committer | Tim Niemueller <tim@niemueller.de> | 2006-08-19 15:13:10 +0000 |
commit | ffaea942e292c03dcce63eeebfe8e8de5d4d43bd (patch) | |
tree | d29088538b30837204b4eed28e8680eff03a3702 | |
parent | cc82127acfefbd3b9d51d1deb84ca53c9964e77b (diff) | |
download | NetworkManager-ffaea942e292c03dcce63eeebfe8e8de5d4d43bd.tar.gz |
2006-08-19 Tim Niemueller <tim@niemueller.de>
* gnome/dialup-properties/*: Dialup properties dialog
* gnome/dialup-properties/modem/*: Dialup properties dialog for modem
connections
* gnome/dialup-properties/btbgrs/*: Dialup properties dialog for GPRS
connections over mobile via BT
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/branches/SoC_2006@1976 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
-rw-r--r-- | gnome/dialup-properties/.cvsignore | 3 | ||||
-rw-r--r-- | gnome/dialup-properties/Makefile.am | 51 | ||||
-rw-r--r-- | gnome/dialup-properties/btgprs/.cvsignore | 2 | ||||
-rw-r--r-- | gnome/dialup-properties/btgprs/Makefile.am | 33 | ||||
-rw-r--r-- | gnome/dialup-properties/btgprs/nm-btgprs-dialog.glade | 716 | ||||
-rw-r--r-- | gnome/dialup-properties/btgprs/nm-btgprs-properties.c | 841 | ||||
-rw-r--r-- | gnome/dialup-properties/clipboard.c | 74 | ||||
-rw-r--r-- | gnome/dialup-properties/clipboard.h | 6 | ||||
-rw-r--r-- | gnome/dialup-properties/modem/.cvsignore | 2 | ||||
-rw-r--r-- | gnome/dialup-properties/modem/Makefile.am | 33 | ||||
-rw-r--r-- | gnome/dialup-properties/modem/nm-modem-dialog.glade | 794 | ||||
-rw-r--r-- | gnome/dialup-properties/modem/nm-modem-properties.c | 935 | ||||
-rw-r--r-- | gnome/dialup-properties/nm-dialup-properties.c | 1131 | ||||
-rw-r--r-- | gnome/dialup-properties/nm-dialup-properties.glade | 436 | ||||
-rw-r--r-- | gnome/dialup-properties/nm-dialup-ui-interface.h | 84 |
15 files changed, 5141 insertions, 0 deletions
diff --git a/gnome/dialup-properties/.cvsignore b/gnome/dialup-properties/.cvsignore new file mode 100644 index 0000000000..5249c2847d --- /dev/null +++ b/gnome/dialup-properties/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +nm-dialup-properties diff --git a/gnome/dialup-properties/Makefile.am b/gnome/dialup-properties/Makefile.am new file mode 100644 index 0000000000..ca602453d2 --- /dev/null +++ b/gnome/dialup-properties/Makefile.am @@ -0,0 +1,51 @@ +SUBDIRS = modem btgprs + +bin_PROGRAMS = nm-dialup-properties + +nm_dialup_propertiesdir=$(includedir)/NetworkManager + +nm_dialup_properties_HEADERS = \ + nm-dialup-ui-interface.h + +nm_dialup_properties_SOURCES = \ + nm-dialup-properties.c \ + clipboard.c \ + clipboard.h \ + nm-dialup-ui-interface.h + +gladedir = $(datadir)/gnome-dialup-properties +glade_DATA = nm-dialup-properties.glade + +nm_dialup_properties_CFLAGS = \ + $(GLADE_CFLAGS) \ + $(GTK_CFLAGS) \ + $(GCONF_CFLAGS) \ + $(GMODULE_CFLAGS) \ + $(LIBGNOMEUI_CFLAGS) \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DICONDIR=\""$(datadir)/pixmaps"\" \ + -DGLADEDIR=\""$(gladedir)"\" \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGNOME_DISABLE_DEPRECATED \ + -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ + -DVERSION=\"$(VERSION)\" \ + -DDIALUP_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/dialup"\" \ + $(NULL) + +nm_dialup_properties_LDADD = \ + $(GLADE_LIBS) \ + $(GTK_LIBS) \ + $(GCONF_LIBS) \ + $(GMODULE_LIBS) \ + $(LIBGNOMEUI_LIBS) \ + $(NULL) + +CLEANFILES = $(server_DATA) *.bak *.gladep *~ + +EXTRA_DIST = \ + $(glade_DATA) \ + $(NULL) + + + diff --git a/gnome/dialup-properties/btgprs/.cvsignore b/gnome/dialup-properties/btgprs/.cvsignore new file mode 100644 index 0000000000..3dda72986f --- /dev/null +++ b/gnome/dialup-properties/btgprs/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile diff --git a/gnome/dialup-properties/btgprs/Makefile.am b/gnome/dialup-properties/btgprs/Makefile.am new file mode 100644 index 0000000000..c4b53604db --- /dev/null +++ b/gnome/dialup-properties/btgprs/Makefile.am @@ -0,0 +1,33 @@ +INCLUDES = -I${top_srcdir}/gnome/dialup-properties + +lib_LTLIBRARIES = libnm-btgprs-properties.la + +libnm_btgprs_properties_la_SOURCES = \ + nm-btgprs-properties.c + +gladedir = $(datadir)/gnome-dialup-properties +glade_DATA = nm-btgprs-dialog.glade + +libnm_btgprs_properties_la_CFLAGS = \ + $(GLADE_CFLAGS) \ + $(GTK_CFLAGS) \ + $(GCONF_CFLAGS) \ + $(LIBGNOMEUI_CFLAGS) \ + -DICONDIR=\""$(datadir)/pixmaps"\" \ + -DGLADEDIR=\""$(gladedir)"\" \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGNOME_DISABLE_DEPRECATED \ + -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ + -DVERSION=\"$(VERSION)\" + +libnm_btgprs_properties_la_LIBADD = \ + $(GLADE_LIBS) \ + $(GTK_LIBS) \ + $(GCONF_LIBS) \ + $(LIBGNOMEUI_LIBS) + +CLEANFILES = *.bak *.gladep *~ + +EXTRA_DIST = \ + $(glade_DATA) diff --git a/gnome/dialup-properties/btgprs/nm-btgprs-dialog.glade b/gnome/dialup-properties/btgprs/nm-btgprs-dialog.glade new file mode 100644 index 0000000000..1a8ebe9e05 --- /dev/null +++ b/gnome/dialup-properties/btgprs/nm-btgprs-dialog.glade @@ -0,0 +1,716 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> +<requires lib="gnome"/> + +<widget class="GtkWindow" id="nm-btgprs-widget-window"> + <property name="title" translatable="yes"></property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkVBox" id="nm-btgprs-widget"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Please enter the information provided by your internet service provider. Do not enter your password here as you will be prompted when connecting.</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Connection Name</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkAlignment" id="alignment7"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Name used to identify the dialup connection, e.g. "University Dialup" or "Corporate Dialup"</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="btgprs-connection-name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox9"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label28"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Required Information</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkAlignment" id="alignment8"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkTable" id="table3"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + + <child> + <widget class="GtkEntry" id="btgprs-device"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-btgprs-label-device"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Device Address:</property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">btgprs-device</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-btgprs-label-channel"> + <property name="visible">True</property> + <property name="label" translatable="yes">Channel:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="btgprs-channel"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">•</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="btgprs-flowcontrol"> + <property name="visible">True</property> + <property name="items" translatable="yes">None +Software (XON/XOFF) +Hardware (CRTSCTS)</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-btgprs-label-flowcontrol"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Flow Control:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkComboBoxEntry" id="btgprs-baudrate"> + <property name="visible">True</property> + <property name="items">460800 +230400 +115200 +57600 +38400 +19200 +9600 +4800 +2400 +1200 +300</property> + <property name="add_tearoffs">False</property> + <property name="has_frame">True</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-btgprs-label-baudrate"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Baud Rate:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="btgprs-apn"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">•</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-btgprs-label-apn"> + <property name="visible">True</property> + <property name="label" translatable="yes">Access Point Name:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">btgprs-apn</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">12</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkExpander" id="btgprs-compression-information-expander"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="expanded">False</property> + <property name="spacing">3</property> + + <child> + <widget class="GtkAlignment" id="alignment9"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox6"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label40"> + <property name="visible">True</property> + <property name="label" translatable="yes">Note that your provider must support the compression settings that you give here.</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="btgprs-use-data-comp"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Data Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="btgprs-use-header-comp"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Header Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label38"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Compression</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox12"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">4</property> + + <child> + <widget class="GtkHButtonBox" id="nm-btgprs-hbuttonbox-import"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkButton" id="btgprs-import"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + + <child> + <widget class="GtkAlignment" id="alignment10"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-add</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label39"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Import Saved Configuration...</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/gnome/dialup-properties/btgprs/nm-btgprs-properties.c b/gnome/dialup-properties/btgprs/nm-btgprs-properties.c new file mode 100644 index 0000000000..1167da1f55 --- /dev/null +++ b/gnome/dialup-properties/btgprs/nm-btgprs-properties.c @@ -0,0 +1,841 @@ +/* nm-btgprs-properties.c : GNOME UI dialogs for configuring btgprs connections + * + * Copyright (C) 2005-2006 Tim Niemueller <tim@niemueller.de> + * Based on work by David Zeuthen, <davidz@redhat.com> + * + * 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 + * + * $Id$ + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib/gi18n-lib.h> +#include <string.h> +#include <stdlib.h> +#include <glade/glade.h> + +#define NM_DIALUP_API_SUBJECT_TO_CHANGE + +#include "nm-dialup-ui-interface.h" + +typedef struct _NetworkManagerDialupUIImpl NetworkManagerDialupUIImpl; + +struct _NetworkManagerDialupUIImpl { + NetworkManagerDialupUI parent; + + NetworkManagerDialupUIDialogValidityCallback callback; + gpointer callback_user_data; + + gchar *last_fc_dir; + + GladeXML *xml; + + GtkWidget *widget; + + GtkEntry *w_connection_name; + GtkEntry *w_device; + GtkEntry *w_channel; + GtkEntry *w_apn; + GtkComboBox *w_baudrate; + GtkComboBox *w_flowcontrol; + GtkExpander *w_comp_info_expander; + GtkCheckButton *w_use_gprs_header_comp; + GtkCheckButton *w_use_gprs_data_comp; + GtkButton *w_import_button; +}; + + +static const char * +baudrate_itos(const gint baudrate_index) +{ + switch ( baudrate_index ) { + case 0: + return "460800"; + case 1: + return "230400"; + case 2: + return "115200"; + case 3: + return "57600"; + case 4: + return "38400"; + case 5: + return "19200"; + case 6: + return "9600"; + case 7: + return "4800"; + case 8: + return "2400"; + case 9: + return "1200"; + case 10: + return "300"; + default: + // seems to be a popular default + return "57600"; + } +} + + +static gint +baudrate_stoi(const gchar *baudrate_string) +{ + gint baudrate_index = -1; + + if ( strcmp (baudrate_string, "460800") == 0 ) { + baudrate_index = 0; + } else if ( strcmp (baudrate_string, "230400") == 0 ) { + baudrate_index = 1; + } else if ( strcmp (baudrate_string, "115200") == 0 ) { + baudrate_index = 2; + } else if ( strcmp (baudrate_string, "57600") == 0 ) { + baudrate_index = 3; + } else if ( strcmp (baudrate_string, "38400") == 0 ) { + baudrate_index = 4; + } else if ( strcmp (baudrate_string, "19200") == 0 ) { + baudrate_index = 5; + } else if ( strcmp (baudrate_string, "9600") == 0 ) { + baudrate_index = 6; + } else if ( strcmp (baudrate_string, "4800") == 0 ) { + baudrate_index = 7; + } else if ( strcmp (baudrate_string, "2400") == 0 ) { + baudrate_index = 8; + } else if ( strcmp (baudrate_string, "1200") == 0 ) { + baudrate_index = 9; + } else if ( strcmp (baudrate_string, "300") == 0 ) { + baudrate_index = 10; + } + + return baudrate_index; +} + + +static const gchar * +flowcontrol_itos(const gint flowcontrol_index) +{ + switch (flowcontrol_index) { + case 1: + return "xonxoff"; + case 2: + return "crtscts"; + default: + return "none"; + } +} + + +static gint +flowcontrol_stoi(const gchar *flowcontrol_string) +{ + gint flowcontrol_index = 0; + + if ( strcmp (flowcontrol_string, "xonxoff") == 0 ) { + flowcontrol_index = 1; + } else if ( strcmp (flowcontrol_string, "crtscts") == 0 ) { + flowcontrol_index = 2; + } + + return flowcontrol_index; +} + + +static void +btgprs_clear_widget (NetworkManagerDialupUIImpl *impl) +{ + gtk_entry_set_text (impl->w_connection_name, ""); + gtk_entry_set_text (impl->w_channel, ""); + gtk_entry_set_text (impl->w_device, ""); + gtk_entry_set_text (impl->w_apn, ""); + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_baudrate), 3); + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_flowcontrol), 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_header_comp), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_data_comp), FALSE); + gtk_expander_set_expanded (impl->w_comp_info_expander, FALSE); +} + +static const char * +impl_get_display_name (NetworkManagerDialupUI *self) +{ + return _("GPRS over mobile via Bluetooth"); +} + +static const char * +impl_get_service_name (NetworkManagerDialupUI *self) +{ + return "org.freedesktop.NetworkManager.ppp"; +} + +static const char * +impl_get_service_type (NetworkManagerDialupUI *self) +{ + return "btgprs"; +} + +static GtkWidget * +impl_get_widget (NetworkManagerDialupUI *self, GSList *properties, const char *connection_name) +{ + GSList *i; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + gboolean should_expand = FALSE; + + btgprs_clear_widget (impl); + + if (connection_name != NULL) + gtk_entry_set_text (impl->w_connection_name, connection_name); + + for (i = properties; i != NULL && g_slist_next (i) != NULL; i = g_slist_next (g_slist_next (i))) { + const char *key; + const char *value; + + key = i->data; + value = (g_slist_next (i))->data; + + if (strcmp (key, "device") == 0) { + gtk_entry_set_text (impl->w_device, value); + + } else if (strcmp (key, "channel") == 0) { + gtk_entry_set_text (impl->w_channel, value); + + } else if (strcmp (key, "apn") == 0) { + gtk_entry_set_text (impl->w_apn, value); + + } else if (strcmp (key, "baudrate") == 0) { + gint baudrate_cbox_sel = baudrate_stoi(value); + + if ( baudrate_cbox_sel >= 0 ) { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_baudrate), baudrate_cbox_sel); + } else { + // how to set custom text? + } + + } else if (strcmp (key, "flowcontrol") == 0) { + gint flowcontrol_cbox_sel = flowcontrol_stoi(value); + + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_flowcontrol), flowcontrol_cbox_sel); + + } else if ( (strcmp (key, "comp-gprs-header") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_header_comp), TRUE); + should_expand = TRUE; + + } else if ( (strcmp (key, "comp-gprs-data") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_data_comp), TRUE); + should_expand = TRUE; + + } + } + + gtk_expander_set_expanded (impl->w_comp_info_expander, should_expand); + gtk_container_resize_children (GTK_CONTAINER (impl->widget)); + + return impl->widget; +} + +static GSList * +impl_get_properties (NetworkManagerDialupUI *self) +{ + GSList *data; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + const char *connection_name; + const char *channel; + const char *apn; + const char *device; + gint baudrate_index; + gboolean use_gprs_header_comp; + gboolean use_gprs_data_comp; + + connection_name = gtk_entry_get_text (impl->w_connection_name); + device = gtk_entry_get_text (impl->w_device); + channel = gtk_entry_get_text (impl->w_channel); + apn = gtk_entry_get_text (impl->w_apn); + baudrate_index = gtk_combo_box_get_active (GTK_COMBO_BOX (impl->w_baudrate)); + + use_gprs_header_comp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_header_comp)); + use_gprs_data_comp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_data_comp)); + + data = NULL; + + data = g_slist_append (data, g_strdup ("wvdial")); + data = g_slist_append (data, g_strdup ("yes")); + + data = g_slist_append (data, g_strdup ("btdevice")); + data = g_slist_append (data, g_strdup (device)); + + data = g_slist_append (data, g_strdup ("btchannel")); + data = g_slist_append (data, g_strdup (channel)); + + data = g_slist_append (data, g_strdup ("apn")); + data = g_slist_append (data, g_strdup (apn)); + + data = g_slist_append (data, g_strdup ("baudrate")); + if ( baudrate_index == -1 ) { + data = g_slist_append (data, g_strdup (gtk_combo_box_get_active_text (GTK_COMBO_BOX (impl->w_baudrate)) )); + } else { + data = g_slist_append (data, g_strdup (baudrate_itos (baudrate_index))); + } + + data = g_slist_append (data, g_strdup ("flowcontrol")); + data = g_slist_append (data, g_strdup (flowcontrol_itos(gtk_combo_box_get_active (GTK_COMBO_BOX (impl->w_flowcontrol)))) ); + + data = g_slist_append (data, g_strdup ("comp-gprs-header")); + data = g_slist_append (data, use_gprs_header_comp ? g_strdup ("yes") : g_strdup("no")); + + data = g_slist_append (data, g_strdup ("comp-gprs-data")); + data = g_slist_append (data, use_gprs_data_comp ? g_strdup ("yes") : g_strdup("no")); + + return data; +} + +static char * +impl_get_connection_name (NetworkManagerDialupUI *self) +{ + const char *name; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + name = gtk_entry_get_text (impl->w_connection_name); + if (name != NULL) + return g_strdup (name); + else + return NULL; +} + + +static gboolean +impl_is_valid (NetworkManagerDialupUI *self) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + gboolean is_valid; + const char *connection_name; + const char *device; + const char *channel; + const char *apn; + + connection_name = gtk_entry_get_text (impl->w_connection_name); + device = gtk_entry_get_text (impl->w_device); + channel = gtk_entry_get_text (impl->w_channel); + apn = gtk_entry_get_text (impl->w_apn); + + is_valid = TRUE; + + if ( (strlen (connection_name) == 0) || + (strlen (device) == 0) || + (strstr (device, " ") != NULL) || + (strstr (device, "\t") != NULL) || + (strlen (apn) == 0) || + (strstr (apn, " ") != NULL) || + (strstr (apn, "\t") != NULL) || + (strlen (channel) == 0) || + (strstr (channel, " ") != NULL) || + (strstr (channel, "\t") != NULL) ) { + + is_valid = FALSE; + } + + return is_valid; +} + +static void +editable_changed (GtkEditable *editable, gpointer user_data) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) user_data; + + if (impl->callback != NULL) { + gboolean is_valid; + + is_valid = impl_is_valid (&(impl->parent)); + impl->callback (&(impl->parent), is_valid, impl->callback_user_data); + } +} + + +static void +impl_set_validity_changed_callback (NetworkManagerDialupUI *self, + NetworkManagerDialupUIDialogValidityCallback callback, + gpointer user_data) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + impl->callback = callback; + impl->callback_user_data = user_data; +} + +static void +impl_get_confirmation_details (NetworkManagerDialupUI *self, gchar **retval) +{ + GString *buf; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + const char *connection_name; + const char *device; + const char *channel; + const char *apn; + gint baudrate_index; + const char *baudrate; + gint flowcontrol_index; + gboolean use_gprs_header_comp; + gboolean use_gprs_data_comp; + + connection_name = gtk_entry_get_text (impl->w_connection_name); + device = gtk_entry_get_text (impl->w_device); + channel = gtk_entry_get_text (impl->w_channel); + apn = gtk_entry_get_text (impl->w_apn); + baudrate_index = gtk_combo_box_get_active( GTK_COMBO_BOX (impl->w_baudrate) ); + flowcontrol_index = gtk_combo_box_get_active( GTK_COMBO_BOX (impl->w_flowcontrol) ); + use_gprs_header_comp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_header_comp)); + use_gprs_data_comp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_data_comp)); + + if ( baudrate_index == -1 ) { + baudrate = gtk_combo_box_get_active_text( GTK_COMBO_BOX (impl->w_baudrate) ); + } else { + baudrate = baudrate_itos( baudrate_index ); + } + + + // This is risky, should be variable length depending on actual data! + buf = g_string_sized_new (1024); + + g_string_append (buf, _("The following GPRS via Bluetooth connection will be created:")); + g_string_append (buf, "\n\n\t"); + g_string_append_printf (buf, _("Name: %s"), connection_name); + g_string_append (buf, "\n\n\t"); + + g_string_append_printf (buf, _("BT Device: %s"), device); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("BT Channel: %s"), channel); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("Access Point Name: %s"), apn); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("Baud Rate: %s"), baudrate); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("Flow Control: %s"), flowcontrol_itos (flowcontrol_index)); + g_string_append (buf, "\n\t"); + + if ( use_gprs_header_comp || + use_gprs_data_comp ) { + + g_string_append_printf( buf, _("Use Header Compression: %s"), ((use_gprs_header_comp) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + g_string_append_printf( buf, _("Use Data Compression: %s"), ((use_gprs_data_comp) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + } + + *retval = g_string_free (buf, FALSE); +} + +static gboolean +import_from_file (NetworkManagerDialupUIImpl *impl, const char *path) +{ + char *basename; + GKeyFile *keyfile; + gboolean file_is_good; + + file_is_good = FALSE; + basename = g_path_get_basename (path); + + keyfile = g_key_file_new (); + if (g_key_file_load_from_file (keyfile, path, 0, NULL)) { + char *connection_name = NULL; + char *device = NULL; + char *channel = NULL; + char *apn = NULL; + char *baudrate = NULL; + char *flowcontrol = NULL; + char *comp_gprs_header = NULL; + char *comp_gprs_data = NULL; + gboolean should_expand; + int baudrate_index = -1; + + connection_name = g_key_file_get_string (keyfile, "btgprs", "description", NULL); + device = g_key_file_get_string (keyfile, "btgprs", "device", NULL); + channel = g_key_file_get_string (keyfile, "btgprs", "channel", NULL); + apn = g_key_file_get_string (keyfile, "btgprs", "apn", NULL); + baudrate = g_key_file_get_string (keyfile, "btgprs", "baudrate", NULL); + flowcontrol = g_key_file_get_string (keyfile, "btgprs", "flowcontrol", NULL); + comp_gprs_header = g_key_file_get_string (keyfile, "btgprs", "comp-gprs-header", NULL); + comp_gprs_data = g_key_file_get_string (keyfile, "btgprs", "comp-gprs-data", NULL); + + file_is_good = FALSE; + + /* sanity check data */ + if ( (connection_name != NULL) && + (device != NULL ) && + (channel != NULL) && + (apn != NULL) && + (baudrate != NULL) && + (strlen (connection_name) > 0) && + (strlen (device) > 0) && + (strlen (channel) > 0) && + (strlen (apn) > 0) && + (strlen (baudrate) > 0) && + (strlen (connection_name) > 0) ) { + + // basics ok + file_is_good = TRUE; + } + + if (flowcontrol != NULL) { + if ( (strlen (flowcontrol) == 0) || + ( (strcmp("none", flowcontrol) != 0) && + (strcmp("xonxoff", flowcontrol) != 0) && + (strcmp("crtscts", flowcontrol) != 0) ) + ) { + file_is_good = FALSE; + } + } + + if (baudrate != NULL) { + if ( (strlen (baudrate) == 0) ) { + baudrate_index = baudrate_stoi(baudrate); + file_is_good = FALSE; + } + } + + if (file_is_good) { + should_expand = FALSE; + + gtk_entry_set_text (impl->w_connection_name, connection_name); + gtk_entry_set_text (impl->w_device, device); + gtk_entry_set_text (impl->w_channel, channel); + gtk_entry_set_text (impl->w_apn, apn); + + if ( baudrate != NULL ) { + if (baudrate_index == -1 ) { + // custom, set text + } else { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_baudrate), baudrate_index); + } + } + + if (flowcontrol != NULL) { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_flowcontrol), + flowcontrol_stoi (flowcontrol) ); + } + + if ( (comp_gprs_header != NULL) && (strcmp(comp_gprs_header, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_header_comp), TRUE); + should_expand = TRUE; + } + + if ( (comp_gprs_data != NULL) && (strcmp(comp_gprs_data, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_gprs_data_comp), TRUE); + should_expand = TRUE; + } + + gtk_expander_set_expanded (impl->w_comp_info_expander, should_expand); + } else { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("Cannot import settings")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("The GPRS via Bluetooth dialup settings file '%s' does not contain valid data."), basename); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + + g_key_file_free (keyfile); + + g_free (connection_name); + g_free (device); + g_free (channel); + g_free (apn); + g_free (baudrate); + g_free (flowcontrol); + g_free (comp_gprs_header); + g_free (comp_gprs_data); + } + + g_free (basename); + + return file_is_good; +} + + +static void +import_button_clicked (GtkButton *button, gpointer user_data) +{ + char *filename = NULL; + GtkWidget *dialog; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) user_data; + + dialog = gtk_file_chooser_dialog_new (_("Select file to import"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + /*printf ("User selected '%s'\n", filename);*/ + + } + + gtk_widget_destroy (dialog); + + if (filename != NULL) { + import_from_file (impl, filename); + g_free (filename); + } +} + + +static gboolean +impl_can_export (NetworkManagerDialupUI *self) +{ + return TRUE; +} + +static gboolean +impl_import_file (NetworkManagerDialupUI *self, const char *path) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + return import_from_file (impl, path); +} + +static gboolean +export_to_file (NetworkManagerDialupUIImpl *impl, const char *path, + GSList *properties, const char *connection_name) +{ + FILE *f; + GSList *i; + const char *device = NULL; + const char *channel = NULL; + const char *apn = NULL; + const char *baudrate = NULL; + const char *flowcontrol = NULL; + const char *comp_gprs_header = NULL; + const char *comp_gprs_data = NULL; + gboolean ret; + + /*printf ("in export_to_file; path='%s'\n", path);*/ + + for (i = properties; i != NULL && g_slist_next (i) != NULL; i = g_slist_next (g_slist_next (i))) { + const char *k; + const char *value; + + k = i->data; + value = (g_slist_next (i))->data; + + if (strcmp (k, "device") == 0) { + device = value; + } else if (strcmp (k, "channel") == 0) { + channel = value; + } else if (strcmp (k, "apn") == 0) { + apn = value; + } else if (strcmp (k, "baudrate") == 0) { + baudrate = value; + } else if (strcmp (k, "flowcontrol") == 0) { + flowcontrol = value; + } else if (strcmp (k, "comp-gprs-header") == 0) { + comp_gprs_header = value; + } else if (strcmp (k, "comp-gprs-data") == 0) { + comp_gprs_data = value; + } + } + + + f = fopen (path, "w"); + if (f != NULL) { + + fprintf (f, + "[btgprs]\n" + "description=%s\n" + "device=%s\n" + "channel=%s\n" + "apn=%s\n" + "baudrate=%s\n" + "flowcontrol=%s\n" + "comp-gprs-header=%s\n" + "comp-gprs-data=%s\n", + /* Description */ connection_name, + /* Device */ device, + /* Channel */ channel, + /* APN */ apn, + /* Baud Rate */ baudrate, + /* Flow Ctrl */ flowcontrol, + /* Hdr Comp */ comp_gprs_header, + /* Data Comp */ comp_gprs_data + ); + + fclose (f); + ret = TRUE; + } + else + ret = FALSE; + return ret; +} + + +static gboolean +impl_export (NetworkManagerDialupUI *self, GSList *properties, const char *connection_name) +{ + char *suggested_name; + char *path = NULL; + GtkWidget *dialog; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + /*printf ("in impl_export\n");*/ + + dialog = gtk_file_chooser_dialog_new (_("Save as..."), + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + + suggested_name = g_strdup_printf ("%s.nmd", connection_name); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_name); + g_free (suggested_name); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) + { + + path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); +/* printf ("User selected '%s'\n", path); */ + + } + + gtk_widget_destroy (dialog); + + if (path != NULL) { + if (g_file_test (path, G_FILE_TEST_EXISTS)) { + int response; + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_CANCEL, + _("A file named \"%s\" already exists."), path); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), "_Replace", GTK_RESPONSE_OK, NULL); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("Do you want to replace it with the one you are saving?")); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + if (response != GTK_RESPONSE_OK) + goto out; + } + + if (!export_to_file (impl, path, properties, connection_name)) { + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("Failed to export configuration")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("Failed to save file %s"), path); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + } + +out: + g_free (path); + + return TRUE; +} + + +static NetworkManagerDialupUI* +impl_get_object (void) +{ + char *glade_file; + NetworkManagerDialupUIImpl *impl; + + impl = g_new0 (NetworkManagerDialupUIImpl, 1); + + impl->last_fc_dir = NULL; + + glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-btgprs-dialog.glade"); + impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE); + g_free( glade_file ); + if (impl->xml != NULL) { + + impl->widget = glade_xml_get_widget(impl->xml, "nm-btgprs-widget"); + + impl->w_connection_name = GTK_ENTRY (glade_xml_get_widget (impl->xml, "btgprs-connection-name")); + impl->w_device = GTK_ENTRY (glade_xml_get_widget (impl->xml, "btgprs-device")); + impl->w_channel = GTK_ENTRY (glade_xml_get_widget (impl->xml, "btgprs-channel")); + impl->w_apn = GTK_ENTRY (glade_xml_get_widget (impl->xml, "btgprs-apn")); + + impl->w_baudrate = GTK_COMBO_BOX (glade_xml_get_widget (impl->xml, "btgprs-baudrate")); + impl->w_flowcontrol = GTK_COMBO_BOX (glade_xml_get_widget (impl->xml, "btgprs-flowcontrol")); + + + impl->w_comp_info_expander = GTK_EXPANDER (glade_xml_get_widget (impl->xml, "btgprs-comp-information-expander")); + + impl->w_use_gprs_header_comp = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "btgprs-use-header-comp")); + impl->w_use_gprs_data_comp = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "btgprs-use-data-comp")); + impl->w_import_button = GTK_BUTTON (glade_xml_get_widget (impl->xml, "btgprs-import-button")); + + impl->callback = NULL; + + + gtk_signal_connect (GTK_OBJECT (impl->w_connection_name), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_device), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_channel), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_apn), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_import_button), + "clicked", GTK_SIGNAL_FUNC (import_button_clicked), impl); + + /* make the widget reusable */ + gtk_signal_connect (GTK_OBJECT (impl->widget), "delete-event", + GTK_SIGNAL_FUNC (gtk_widget_hide_on_delete), NULL); + + btgprs_clear_widget (impl); + + impl->parent.get_display_name = impl_get_display_name; + impl->parent.get_service_name = impl_get_service_name; + impl->parent.get_service_type = impl_get_service_type; + impl->parent.get_widget = impl_get_widget; + impl->parent.get_connection_name = impl_get_connection_name; + impl->parent.get_properties = impl_get_properties; + impl->parent.set_validity_changed_callback = impl_set_validity_changed_callback; + impl->parent.is_valid = impl_is_valid; + impl->parent.get_confirmation_details = impl_get_confirmation_details; + impl->parent.can_export = impl_can_export; + impl->parent.import_file = impl_import_file; + impl->parent.export = impl_export; + impl->parent.data = impl; + + return &(impl->parent); + } else { + g_free (impl); + return NULL; + } +} + +NetworkManagerDialupUI * nm_dialup_properties_factory(void); + +NetworkManagerDialupUI * +nm_dialup_properties_factory (void) +{ + return impl_get_object(); +} diff --git a/gnome/dialup-properties/clipboard.c b/gnome/dialup-properties/clipboard.c new file mode 100644 index 0000000000..d85163bc5a --- /dev/null +++ b/gnome/dialup-properties/clipboard.c @@ -0,0 +1,74 @@ +/* + * src/clipboard.c - X clipboard hack to detect if daemon is running + * + * Elliot Lee <sopwith@redhat.com> + * + * (C) Copyright 1999 Red Hat, Inc. + * + * Licensed under the GNU GPL v2. See COPYING. + */ + +#include "config.h" + +#include <gnome.h> +#include <gconf/gconf-client.h> +#include <gdk/gdkx.h> + +#include "clipboard.h" + +/* + * clipboard_get_func - dummy get_func for gtk_clipboard_set_with_data () + */ +static void +clipboard_get_func (GtkClipboard *clipboard __attribute__((__unused__)), + GtkSelectionData *selection_data __attribute__((__unused__)), + guint info __attribute__((__unused__)), + gpointer user_data_or_owner __attribute__((__unused__))) +{ +} + +/* + * clipboard_clear_func - dummy clear_func for gtk_clipboard_set_with_data () + */ +static void +clipboard_clear_func (GtkClipboard *clipboard __attribute__((__unused__)), + gpointer user_data_or_owner __attribute__((__unused__))) +{ +} + +#define CLIPBOARD_NAME "DIALUP_CLIPBOARD_FOO" + +/* + * dialup_get_clipboard - try and get the CLIPBOARD_NAME clipboard + * + * Returns TRUE if successfully retrieved and FALSE otherwise. + */ +gboolean +dialup_get_clipboard (void) +{ + static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} }; + gboolean retval = FALSE; + GtkClipboard *clipboard; + Atom atom; + + atom = gdk_x11_get_xatom_by_name (CLIPBOARD_NAME); + + XGrabServer (GDK_DISPLAY ()); + + if (XGetSelectionOwner (GDK_DISPLAY (), atom) != None) + goto out; + + clipboard = gtk_clipboard_get (gdk_atom_intern (CLIPBOARD_NAME, FALSE)); + + if (gtk_clipboard_set_with_data (clipboard, targets, + G_N_ELEMENTS (targets), + clipboard_get_func, + clipboard_clear_func, NULL)) + retval = TRUE; + +out: + XUngrabServer (GDK_DISPLAY ()); + gdk_flush (); + + return retval; +} diff --git a/gnome/dialup-properties/clipboard.h b/gnome/dialup-properties/clipboard.h new file mode 100644 index 0000000000..92b5b0620a --- /dev/null +++ b/gnome/dialup-properties/clipboard.h @@ -0,0 +1,6 @@ +#ifndef _DIALUP_PROPERTIES_CLIPBOARD_H +#define _DIALUP_PROPERTIES_CLIPBOARD_H + +gboolean dialup_get_clipboard (void); + +#endif /* _DIALUP_PROPERTIES_CLIPBOARD_H */ diff --git a/gnome/dialup-properties/modem/.cvsignore b/gnome/dialup-properties/modem/.cvsignore new file mode 100644 index 0000000000..3dda72986f --- /dev/null +++ b/gnome/dialup-properties/modem/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile diff --git a/gnome/dialup-properties/modem/Makefile.am b/gnome/dialup-properties/modem/Makefile.am new file mode 100644 index 0000000000..bddb960332 --- /dev/null +++ b/gnome/dialup-properties/modem/Makefile.am @@ -0,0 +1,33 @@ +INCLUDES = -I${top_srcdir}/gnome/dialup-properties + +lib_LTLIBRARIES = libnm-modem-properties.la + +libnm_modem_properties_la_SOURCES = \ + nm-modem-properties.c + +gladedir = $(datadir)/gnome-dialup-properties +glade_DATA = nm-modem-dialog.glade + +libnm_modem_properties_la_CFLAGS = \ + $(GLADE_CFLAGS) \ + $(GTK_CFLAGS) \ + $(GCONF_CFLAGS) \ + $(LIBGNOMEUI_CFLAGS) \ + -DICONDIR=\""$(datadir)/pixmaps"\" \ + -DGLADEDIR=\""$(gladedir)"\" \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGNOME_DISABLE_DEPRECATED \ + -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ + -DVERSION=\"$(VERSION)\" + +libnm_modem_properties_la_LIBADD = \ + $(GLADE_LIBS) \ + $(GTK_LIBS) \ + $(GCONF_LIBS) \ + $(LIBGNOMEUI_LIBS) + +CLEANFILES = *.bak *.gladep *~ + +EXTRA_DIST = \ + $(glade_DATA) diff --git a/gnome/dialup-properties/modem/nm-modem-dialog.glade b/gnome/dialup-properties/modem/nm-modem-dialog.glade new file mode 100644 index 0000000000..f5eb1d6de9 --- /dev/null +++ b/gnome/dialup-properties/modem/nm-modem-dialog.glade @@ -0,0 +1,794 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> +<requires lib="gnome"/> + +<widget class="GtkWindow" id="nm-modem-widget-window"> + <property name="title" translatable="yes"></property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkVBox" id="nm-modem-widget"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Please enter the information provided by your internet service provider. Do not enter your password here as you will be prompted when connecting.</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Connection Name</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkAlignment" id="alignment7"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Name used to identify the dialup connection, e.g. "University Dialup" or "Corporate Dialup"</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="modem-connection-name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox9"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label28"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Required Information</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkAlignment" id="alignment8"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkTable" id="table3"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + + <child> + <widget class="GtkEntry" id="modem-device"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-modem-label-device"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Device (<i>e.g. /dev/ttyS0</i>):</property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">1</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">modem-device</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-modem-label-number"> + <property name="visible">True</property> + <property name="label" translatable="yes">N_umber:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">modem-number</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="modem-number"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">•</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-modem-label-baudrate"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Baud Rate:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkComboBoxEntry" id="modem-baudrate"> + <property name="visible">True</property> + <property name="items">460800 +230400 +115200 +57600 +38400 +19200 +9600 +4800 +2400 +1200 +300</property> + <property name="add_tearoffs">False</property> + <property name="has_frame">True</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-modem-label-flowcontrol"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Flow Control:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="nm-modem-label-volume"> + <property name="visible">True</property> + <property name="label" translatable="yes">Speaker _Volume:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="modem-flowcontrol"> + <property name="visible">True</property> + <property name="items" translatable="yes">None +Software (XON/XOFF) +Hardware (CRTSCTS)</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + <property name="y_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="modem-volume"> + <property name="visible">True</property> + <property name="items" translatable="yes">Off +Low +Medium +High +Very High</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + <property name="y_options">fill</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">12</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkExpander" id="modem-compression-information-expander"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="expanded">False</property> + <property name="spacing">3</property> + + <child> + <widget class="GtkAlignment" id="alignment9"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox6"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label40"> + <property name="visible">True</property> + <property name="label" translatable="yes">Note that your provider must support the compression settings that you give here.</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="modem-use-vjheader"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable VJ TCP/IP _Header Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="modem-use-vjcid"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable VJ Connection-_ID Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="modem-use-acc"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable _Address/Control Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="modem-use-pfc"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable _Protocol Field Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="modem-use-bsd"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable _BSD Compression</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="modem-use-ccp"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable _CCP Compression Control Protocol</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label38"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Compression</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHSeparator" id="hseparator1"> + <property name="visible">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox12"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">4</property> + + <child> + <widget class="GtkHButtonBox" id="nm-modem-hbuttonbox-import"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkButton" id="modem-import"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + + <child> + <widget class="GtkAlignment" id="alignment10"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-add</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label39"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Import Saved Configuration...</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/gnome/dialup-properties/modem/nm-modem-properties.c b/gnome/dialup-properties/modem/nm-modem-properties.c new file mode 100644 index 0000000000..0207bd9a87 --- /dev/null +++ b/gnome/dialup-properties/modem/nm-modem-properties.c @@ -0,0 +1,935 @@ +/* nm-modem-properties.c : GNOME UI dialogs for configuring modem connections + * + * Copyright (C) 2005-2006 Tim Niemueller <tim@niemueller.de> + * Based on work by David Zeuthen, <davidz@redhat.com> + * + * 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 + * + * $Id$ + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib/gi18n-lib.h> +#include <string.h> +#include <stdlib.h> +#include <glade/glade.h> + +#define NM_DIALUP_API_SUBJECT_TO_CHANGE + +#include "nm-dialup-ui-interface.h" + +typedef struct _NetworkManagerDialupUIImpl NetworkManagerDialupUIImpl; + +struct _NetworkManagerDialupUIImpl { + NetworkManagerDialupUI parent; + + NetworkManagerDialupUIDialogValidityCallback callback; + gpointer callback_user_data; + + gchar *last_fc_dir; + + GladeXML *xml; + + GtkWidget *widget; + + GtkEntry *w_connection_name; + GtkEntry *w_device; + GtkEntry *w_number; + GtkComboBox *w_baudrate; + GtkComboBox *w_flowcontrol; + GtkComboBox *w_volume; + GtkExpander *w_comp_info_expander; + GtkCheckButton *w_use_vjheader; + GtkCheckButton *w_use_vjcid; + GtkCheckButton *w_use_acc; + GtkCheckButton *w_use_pfc; + GtkCheckButton *w_use_bsd; + GtkCheckButton *w_use_ccp; + GtkButton *w_import_button; +}; + + +static const char * +baudrate_itos(const gint baudrate_index) +{ + switch ( baudrate_index ) { + case 0: + return "460800"; + case 1: + return "230400"; + case 2: + return "115200"; + case 3: + return "57600"; + case 4: + return "38400"; + case 5: + return "19200"; + case 6: + return "9600"; + case 7: + return "4800"; + case 8: + return "2400"; + case 9: + return "1200"; + case 10: + return "300"; + default: + // seems to be a popular default + return "57600"; + } +} + + +static gint +baudrate_stoi(const gchar *baudrate_string) +{ + gint baudrate_index = -1; + + if ( strcmp (baudrate_string, "460800") == 0 ) { + baudrate_index = 0; + } else if ( strcmp (baudrate_string, "230400") == 0 ) { + baudrate_index = 1; + } else if ( strcmp (baudrate_string, "115200") == 0 ) { + baudrate_index = 2; + } else if ( strcmp (baudrate_string, "57600") == 0 ) { + baudrate_index = 3; + } else if ( strcmp (baudrate_string, "38400") == 0 ) { + baudrate_index = 4; + } else if ( strcmp (baudrate_string, "19200") == 0 ) { + baudrate_index = 5; + } else if ( strcmp (baudrate_string, "9600") == 0 ) { + baudrate_index = 6; + } else if ( strcmp (baudrate_string, "4800") == 0 ) { + baudrate_index = 7; + } else if ( strcmp (baudrate_string, "2400") == 0 ) { + baudrate_index = 8; + } else if ( strcmp (baudrate_string, "1200") == 0 ) { + baudrate_index = 9; + } else if ( strcmp (baudrate_string, "300") == 0 ) { + baudrate_index = 10; + } + + return baudrate_index; +} + + +static const gchar * +flowcontrol_itos(const gint flowcontrol_index) +{ + switch (flowcontrol_index) { + case 1: + return "xonxoff"; + case 2: + return "crtscts"; + default: + return "none"; + } +} + + +static gint +flowcontrol_stoi(const gchar *flowcontrol_string) +{ + gint flowcontrol_index = 0; + + if ( strcmp (flowcontrol_string, "xonxoff") == 0 ) { + flowcontrol_index = 1; + } else if ( strcmp (flowcontrol_string, "crtscts") == 0 ) { + flowcontrol_index = 2; + } + + return flowcontrol_index; +} + + +static void +modem_clear_widget (NetworkManagerDialupUIImpl *impl) +{ + gtk_entry_set_text (impl->w_connection_name, ""); + gtk_entry_set_text (impl->w_number, ""); + gtk_entry_set_text (impl->w_device, ""); + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_baudrate), 3); + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_flowcontrol), 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_volume), 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_vjheader), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_vjcid), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_acc), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_pfc), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_bsd), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_ccp), FALSE); + gtk_expander_set_expanded (impl->w_comp_info_expander, FALSE); +} + +static const char * +impl_get_display_name (NetworkManagerDialupUI *self) +{ + return _("Modem"); +} + +static const char * +impl_get_service_name (NetworkManagerDialupUI *self) +{ + return "org.freedesktop.NetworkManager.ppp"; +} + +static const char * +impl_get_service_type (NetworkManagerDialupUI *self) +{ + return "modem"; +} + +static GtkWidget * +impl_get_widget (NetworkManagerDialupUI *self, GSList *properties, const char *connection_name) +{ + GSList *i; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + gboolean should_expand = FALSE; + + modem_clear_widget (impl); + + if (connection_name != NULL) + gtk_entry_set_text (impl->w_connection_name, connection_name); + + for (i = properties; i != NULL && g_slist_next (i) != NULL; i = g_slist_next (g_slist_next (i))) { + const char *key; + const char *value; + + key = i->data; + value = (g_slist_next (i))->data; + + if (strcmp (key, "device") == 0) { + gtk_entry_set_text (impl->w_device, value); + + } else if (strcmp (key, "number") == 0) { + gtk_entry_set_text (impl->w_number, value); + + } else if (strcmp (key, "baudrate") == 0) { + gint baudrate_cbox_sel = baudrate_stoi(value); + + if ( baudrate_cbox_sel >= 0 ) { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_baudrate), baudrate_cbox_sel); + } else { + // how to set custom text? + } + + } else if (strcmp (key, "flowcontrol") == 0) { + gint flowcontrol_cbox_sel = flowcontrol_stoi(value); + + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_flowcontrol), flowcontrol_cbox_sel); + + } else if (strcmp (key, "volume") == 0) { + gint volume = atoi( value ); + if ( (volume >= 0) && (volume <= 4) ) { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_volume), volume); + } + + } else if ( (strcmp (key, "comp-vjheader") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_vjheader), TRUE); + should_expand = TRUE; + + } else if ( (strcmp (key, "comp-vjcid") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_vjcid), TRUE); + should_expand = TRUE; + + } else if ( (strcmp (key, "comp-acc") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_acc), TRUE); + should_expand = TRUE; + + } else if ( (strcmp (key, "comp-pfc") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_pfc), TRUE); + should_expand = TRUE; + + } else if ( (strcmp (key, "comp-bsd") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_bsd), TRUE); + should_expand = TRUE; + + } else if ( (strcmp (key, "comp-ccp") == 0) && + (strcmp (value, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_ccp), TRUE); + should_expand = TRUE; + } + } + + gtk_expander_set_expanded (impl->w_comp_info_expander, should_expand); + gtk_container_resize_children (GTK_CONTAINER (impl->widget)); + + return impl->widget; +} + +static GSList * +impl_get_properties (NetworkManagerDialupUI *self) +{ + GSList *data; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + const char *connection_name; + const char *number; + const char *device; + gint baudrate_index; + gboolean use_vjheader; + gboolean use_vjcid; + gboolean use_acc; + gboolean use_pfc; + gboolean use_bsd; + gboolean use_ccp; + + connection_name = gtk_entry_get_text (impl->w_connection_name); + device = gtk_entry_get_text (impl->w_device); + number = gtk_entry_get_text (impl->w_number); + baudrate_index = gtk_combo_box_get_active (GTK_COMBO_BOX (impl->w_baudrate)); + + use_vjheader = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_vjheader)); + use_vjcid = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_vjcid)); + use_acc = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_acc)); + use_pfc = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_pfc)); + use_bsd = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_bsd)); + use_ccp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_ccp)); + + data = NULL; + + data = g_slist_append (data, g_strdup ("wvdial")); + data = g_slist_append (data, g_strdup ("yes")); + + data = g_slist_append (data, g_strdup ("device")); + data = g_slist_append (data, g_strdup (device)); + + data = g_slist_append (data, g_strdup ("number")); + data = g_slist_append (data, g_strdup (number)); + + data = g_slist_append (data, g_strdup ("baudrate")); + if ( baudrate_index == -1 ) { + data = g_slist_append (data, g_strdup (gtk_combo_box_get_active_text (GTK_COMBO_BOX (impl->w_baudrate)) )); + } else { + data = g_slist_append (data, g_strdup (baudrate_itos (baudrate_index))); + } + + data = g_slist_append (data, g_strdup ("flowcontrol")); + data = g_slist_append (data, g_strdup (flowcontrol_itos(gtk_combo_box_get_active (GTK_COMBO_BOX (impl->w_flowcontrol)))) ); + + data = g_slist_append (data, g_strdup ("volume")); + data = g_slist_append (data, g_strdup_printf ("%i", gtk_combo_box_get_active (GTK_COMBO_BOX (impl->w_volume)))); + + data = g_slist_append (data, g_strdup ("comp-vjheader")); + data = g_slist_append (data, use_vjheader ? g_strdup ("yes") : g_strdup("no")); + + data = g_slist_append (data, g_strdup ("comp-vjcid")); + data = g_slist_append (data, use_vjcid ? g_strdup ("yes") : g_strdup("no")); + + data = g_slist_append (data, g_strdup ("comp-acc")); + data = g_slist_append (data, use_acc ? g_strdup ("yes") : g_strdup("no")); + + data = g_slist_append (data, g_strdup ("comp-pfc")); + data = g_slist_append (data, use_pfc ? g_strdup ("yes") : g_strdup("no")); + + data = g_slist_append (data, g_strdup ("comp-bsd")); + data = g_slist_append (data, use_bsd ? g_strdup ("yes") : g_strdup("no")); + + data = g_slist_append (data, g_strdup ("comp-ccp")); + data = g_slist_append (data, use_ccp ? g_strdup ("yes") : g_strdup("no")); + + return data; +} + +static char * +impl_get_connection_name (NetworkManagerDialupUI *self) +{ + const char *name; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + name = gtk_entry_get_text (impl->w_connection_name); + if (name != NULL) + return g_strdup (name); + else + return NULL; +} + + +static gboolean +impl_is_valid (NetworkManagerDialupUI *self) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + gboolean is_valid; + const char *connection_name; + const char *device; + const char *number; + + connection_name = gtk_entry_get_text (impl->w_connection_name); + device = gtk_entry_get_text (impl->w_device); + number = gtk_entry_get_text (impl->w_number); + + is_valid = TRUE; + + if ( (strlen (connection_name) == 0) || + (strlen (device) == 0) || + (strstr (device, " ") != NULL) || + (strstr (device, "\t") != NULL) || + (strlen (number) == 0) || + (strstr (number, " ") != NULL) || + (strstr (number, "\t") != NULL) ) { + + is_valid = FALSE; + } + + return is_valid; +} + +static void +editable_changed (GtkEditable *editable, gpointer user_data) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) user_data; + + if (impl->callback != NULL) { + gboolean is_valid; + + is_valid = impl_is_valid (&(impl->parent)); + impl->callback (&(impl->parent), is_valid, impl->callback_user_data); + } +} + + +static void +impl_set_validity_changed_callback (NetworkManagerDialupUI *self, + NetworkManagerDialupUIDialogValidityCallback callback, + gpointer user_data) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + impl->callback = callback; + impl->callback_user_data = user_data; +} + +static void +impl_get_confirmation_details (NetworkManagerDialupUI *self, gchar **retval) +{ + GString *buf; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + const char *connection_name; + const char *device; + const char *number; + gint baudrate_index; + const char *baudrate; + gint flowcontrol_index; + gboolean use_vjheader; + gboolean use_vjcid; + gboolean use_acc; + gboolean use_pfc; + gboolean use_bsd; + gboolean use_ccp; + + connection_name = gtk_entry_get_text (impl->w_connection_name); + device = gtk_entry_get_text (impl->w_device); + number = gtk_entry_get_text (impl->w_number); + baudrate_index = gtk_combo_box_get_active( GTK_COMBO_BOX (impl->w_baudrate) ); + flowcontrol_index = gtk_combo_box_get_active( GTK_COMBO_BOX (impl->w_flowcontrol) ); + use_vjheader = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_vjheader)); + use_vjcid = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_vjcid)); + use_acc = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_acc)); + use_pfc = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_pfc)); + use_bsd = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_bsd)); + use_ccp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (impl->w_use_ccp)); + + if ( baudrate_index == -1 ) { + baudrate = gtk_combo_box_get_active_text( GTK_COMBO_BOX (impl->w_baudrate) ); + } else { + baudrate = baudrate_itos( baudrate_index ); + } + + + // This is risky, should be variable length depending on actual data! + buf = g_string_sized_new (1024); + + g_string_append (buf, _("The following modem connection will be created:")); + g_string_append (buf, "\n\n\t"); + g_string_append_printf (buf, _("Name: %s"), connection_name); + g_string_append (buf, "\n\n\t"); + + g_string_append_printf (buf, _("Device: %s"), device); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("Number: %s"), number); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("Baud Rate: %s"), baudrate); + g_string_append (buf, "\n\t"); + g_string_append_printf (buf, _("Flow Control: %s"), flowcontrol_itos (flowcontrol_index)); + g_string_append (buf, "\n\t"); + + if ( use_vjheader || + use_vjcid || + use_acc || + use_pfc || + use_bsd || + use_ccp ) { + + g_string_append_printf( buf, _("Use VJ TCP/IP Header Compression: %s"), ((use_vjheader) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + g_string_append_printf( buf, _("Use VJ Connection-ID Compression: %s"), ((use_vjcid) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + g_string_append_printf( buf, _("Use Access/Control Compression: %s"), ((use_acc) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + g_string_append_printf( buf, _("Use Protocol Field Compression: %s"), ((use_pfc) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + g_string_append_printf( buf, _("Use BSD Compression: %s"), ((use_bsd) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + g_string_append_printf( buf, _("Use CCP Compression Control Protocol: %s"), ((use_ccp) ? _("Yes") : _("No"))); + g_string_append (buf, "\n\t"); + } + + *retval = g_string_free (buf, FALSE); +} + +static gboolean +import_from_file (NetworkManagerDialupUIImpl *impl, const char *path) +{ + char *basename; + GKeyFile *keyfile; + gboolean file_is_good; + + file_is_good = FALSE; + basename = g_path_get_basename (path); + + keyfile = g_key_file_new (); + if (g_key_file_load_from_file (keyfile, path, 0, NULL)) { + char *connection_name = NULL; + char *device = NULL; + char *number = NULL; + char *baudrate = NULL; + char *flowcontrol = NULL; + char *volume = NULL; + char *comp_vjheader = NULL; + char *comp_vjcid = NULL; + char *comp_acc = NULL; + char *comp_pfc = NULL; + char *comp_bsd = NULL; + char *comp_ccp = NULL; + gboolean should_expand; + int baudrate_index = -1; + + connection_name = g_key_file_get_string (keyfile, "modem", "description", NULL); + device = g_key_file_get_string (keyfile, "modem", "device", NULL); + number = g_key_file_get_string (keyfile, "modem", "number", NULL); + baudrate = g_key_file_get_string (keyfile, "modem", "baudrate", NULL); + flowcontrol = g_key_file_get_string (keyfile, "modem", "flowcontrol", NULL); + volume = g_key_file_get_string (keyfile, "modem", "volume", NULL); + comp_vjheader = g_key_file_get_string (keyfile, "modem", "comp-vjheader", NULL); + comp_vjcid = g_key_file_get_string (keyfile, "modem", "comp-vjcid", NULL); + comp_acc = g_key_file_get_string (keyfile, "modem", "comp-acc", NULL); + comp_pfc = g_key_file_get_string (keyfile, "modem", "comp-pfc", NULL); + comp_bsd = g_key_file_get_string (keyfile, "modem", "comp-bsd", NULL); + comp_ccp = g_key_file_get_string (keyfile, "modem", "comp-ccp", NULL); + + file_is_good = FALSE; + + /* sanity check data */ + if ( (connection_name != NULL) && + (device != NULL ) && + (number != NULL) && + (baudrate != NULL) && + (volume != NULL) && + (strlen (connection_name) > 0) && + (strlen (device) > 0) && + (strlen (number) > 0) && + (strlen (baudrate) > 0) && + (strlen (volume) > 0) && + (strlen (connection_name) > 0) ) { + + // basics ok + file_is_good = TRUE; + } + + if (flowcontrol != NULL) { + if ( (strlen (flowcontrol) == 0) || + ( (strcmp("none", flowcontrol) != 0) && + (strcmp("xonxoff", flowcontrol) != 0) && + (strcmp("crtscts", flowcontrol) != 0) ) + ) { + file_is_good = FALSE; + } + } + + if (baudrate != NULL) { + if ( (strlen (baudrate) == 0) ) { + baudrate_index = baudrate_stoi(baudrate); + file_is_good = FALSE; + } + } + + if (volume != NULL) { + if ( strlen (volume) != 1 ) { + int volint = atoi(volume); + if ( (volint < 0) || (volint > 4) ) { + file_is_good = FALSE; + } + } + } + + if (file_is_good) { + should_expand = FALSE; + + gtk_entry_set_text (impl->w_connection_name, connection_name); + gtk_entry_set_text (impl->w_device, device); + gtk_entry_set_text (impl->w_number, number); + + if ( baudrate != NULL ) { + if (baudrate_index == -1 ) { + // custom, set text + } else { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_baudrate), baudrate_index); + } + } + + if (flowcontrol != NULL) { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_flowcontrol), + flowcontrol_stoi (flowcontrol) ); + } + + if ( volume != NULL ) { + gtk_combo_box_set_active (GTK_COMBO_BOX (impl->w_volume), atoi(volume)); + } + + if ( (comp_vjheader != NULL) && (strcmp(comp_vjheader, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_vjheader), TRUE); + should_expand = TRUE; + } + + if ( (comp_vjcid != NULL) && (strcmp(comp_vjcid, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_vjcid), TRUE); + should_expand = TRUE; + } + + if ( (comp_acc != NULL) && (strcmp(comp_acc, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_acc), TRUE); + should_expand = TRUE; + } + + if ( (comp_pfc != NULL) && (strcmp(comp_pfc, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_pfc), TRUE); + should_expand = TRUE; + } + + if ( (comp_bsd != NULL) && (strcmp(comp_bsd, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_bsd), TRUE); + should_expand = TRUE; + } + + if ( (comp_ccp != NULL) && (strcmp(comp_ccp, "yes") == 0) ) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (impl->w_use_ccp), TRUE); + should_expand = TRUE; + } + + + gtk_expander_set_expanded (impl->w_comp_info_expander, should_expand); + } else { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("Cannot import settings")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("The modem dialup settings file '%s' does not contain valid data."), basename); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + + g_key_file_free (keyfile); + + g_free (connection_name); + g_free (device); + g_free (number); + g_free (baudrate); + g_free (flowcontrol); + g_free (volume); + g_free (comp_vjheader); + g_free (comp_vjcid); + g_free (comp_acc); + g_free (comp_pfc); + g_free (comp_bsd); + g_free (comp_ccp); + } + + g_free (basename); + + return file_is_good; +} + +static void +import_button_clicked (GtkButton *button, gpointer user_data) +{ + char *filename = NULL; + GtkWidget *dialog; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) user_data; + + dialog = gtk_file_chooser_dialog_new (_("Select file to import"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + /*printf ("User selected '%s'\n", filename);*/ + + } + + gtk_widget_destroy (dialog); + + if (filename != NULL) { + import_from_file (impl, filename); + g_free (filename); + } +} + + +static gboolean +impl_can_export (NetworkManagerDialupUI *self) +{ + return TRUE; +} + +static gboolean +impl_import_file (NetworkManagerDialupUI *self, const char *path) +{ + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + return import_from_file (impl, path); +} + +static gboolean +export_to_file (NetworkManagerDialupUIImpl *impl, const char *path, + GSList *properties, const char *connection_name) +{ + FILE *f; + GSList *i; + const char *device = NULL; + const char *number = NULL; + const char *baudrate = NULL; + const char *flowcontrol = NULL; + const char *volume = NULL; + gboolean ret; + + /*printf ("in export_to_file; path='%s'\n", path);*/ + + for (i = properties; i != NULL && g_slist_next (i) != NULL; i = g_slist_next (g_slist_next (i))) { + const char *k; + const char *value; + + k = i->data; + value = (g_slist_next (i))->data; + + if (strcmp (k, "device") == 0) { + device = value; + } else if (strcmp (k, "number") == 0) { + number = value; + } else if (strcmp (k, "baudrate") == 0) { + baudrate = value; + } else if (strcmp (k, "flowcontrol") == 0) { + flowcontrol = value; + } else if (strcmp (k, "volume") == 0) { + volume = value; + } + } + + + f = fopen (path, "w"); + if (f != NULL) { + + fprintf (f, + "[modem]\n" + "description=%s\n" + "device=%s\n" + "number=%s\n" + "baudrate=%s\n" + "flowcontrol=%s\n" + "volume=%s\n", + /* Description */ connection_name, + /* Device */ device, + /* Number */ number, + /* Baud Rate */ baudrate, + /* Flow Ctrl */ flowcontrol, + /* Volume */ volume ); + + fclose (f); + ret = TRUE; + } + else + ret = FALSE; + return ret; +} + + +static gboolean +impl_export (NetworkManagerDialupUI *self, GSList *properties, const char *connection_name) +{ + char *suggested_name; + char *path = NULL; + GtkWidget *dialog; + NetworkManagerDialupUIImpl *impl = (NetworkManagerDialupUIImpl *) self->data; + + /*printf ("in impl_export\n");*/ + + dialog = gtk_file_chooser_dialog_new (_("Save as..."), + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + + suggested_name = g_strdup_printf ("%s.nmd", connection_name); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_name); + g_free (suggested_name); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) + { + + path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); +/* printf ("User selected '%s'\n", path); */ + + } + + gtk_widget_destroy (dialog); + + if (path != NULL) { + if (g_file_test (path, G_FILE_TEST_EXISTS)) { + int response; + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_CANCEL, + _("A file named \"%s\" already exists."), path); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), "_Replace", GTK_RESPONSE_OK, NULL); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("Do you want to replace it with the one you are saving?")); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + if (response != GTK_RESPONSE_OK) + goto out; + } + + if (!export_to_file (impl, path, properties, connection_name)) { + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("Failed to export configuration")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("Failed to save file %s"), path); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + } + +out: + g_free (path); + + return TRUE; +} + + +static NetworkManagerDialupUI* +impl_get_object (void) +{ + char *glade_file; + NetworkManagerDialupUIImpl *impl; + + impl = g_new0 (NetworkManagerDialupUIImpl, 1); + + impl->last_fc_dir = NULL; + + glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-modem-dialog.glade"); + impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE); + g_free( glade_file ); + if (impl->xml != NULL) { + + impl->widget = glade_xml_get_widget(impl->xml, "nm-modem-widget"); + + impl->w_connection_name = GTK_ENTRY (glade_xml_get_widget (impl->xml, "modem-connection-name")); + impl->w_device = GTK_ENTRY (glade_xml_get_widget (impl->xml, "modem-device")); + impl->w_number = GTK_ENTRY (glade_xml_get_widget (impl->xml, "modem-number")); + + impl->w_baudrate = GTK_COMBO_BOX (glade_xml_get_widget (impl->xml, "modem-baudrate")); + impl->w_flowcontrol = GTK_COMBO_BOX (glade_xml_get_widget (impl->xml, "modem-flowcontrol")); + impl->w_volume = GTK_COMBO_BOX (glade_xml_get_widget (impl->xml, "modem-volume")); + + + impl->w_comp_info_expander = GTK_EXPANDER (glade_xml_get_widget (impl->xml, "modem-comp-information-expander")); + + impl->w_use_vjheader = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "modem-use-vjheader")); + impl->w_use_vjcid = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "modem-use-vjcid")); + impl->w_use_acc = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "modem-use-acc")); + impl->w_use_pfc = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "modem-use-pfc")); + impl->w_use_bsd = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "modem-use-bsd")); + impl->w_use_ccp = GTK_CHECK_BUTTON (glade_xml_get_widget (impl->xml, "modem-use-ccp")); + impl->w_import_button = GTK_BUTTON (glade_xml_get_widget (impl->xml, "modem-import-button")); + + impl->callback = NULL; + + + gtk_signal_connect (GTK_OBJECT (impl->w_connection_name), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_device), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_number), + "changed", GTK_SIGNAL_FUNC (editable_changed), impl); + gtk_signal_connect (GTK_OBJECT (impl->w_import_button), + "clicked", GTK_SIGNAL_FUNC (import_button_clicked), impl); + + /* make the widget reusable */ + gtk_signal_connect (GTK_OBJECT (impl->widget), "delete-event", + GTK_SIGNAL_FUNC (gtk_widget_hide_on_delete), NULL); + + modem_clear_widget (impl); + + impl->parent.get_display_name = impl_get_display_name; + impl->parent.get_service_name = impl_get_service_name; + impl->parent.get_service_type = impl_get_service_type; + impl->parent.get_widget = impl_get_widget; + impl->parent.get_connection_name = impl_get_connection_name; + impl->parent.get_properties = impl_get_properties; + impl->parent.set_validity_changed_callback = impl_set_validity_changed_callback; + impl->parent.is_valid = impl_is_valid; + impl->parent.get_confirmation_details = impl_get_confirmation_details; + impl->parent.can_export = impl_can_export; + impl->parent.import_file = impl_import_file; + impl->parent.export = impl_export; + impl->parent.data = impl; + + return &(impl->parent); + } else { + g_free (impl); + return NULL; + } +} + +NetworkManagerDialupUI * nm_dialup_properties_factory(void); + +NetworkManagerDialupUI * +nm_dialup_properties_factory (void) +{ + return impl_get_object(); +} diff --git a/gnome/dialup-properties/nm-dialup-properties.c b/gnome/dialup-properties/nm-dialup-properties.c new file mode 100644 index 0000000000..d81256787e --- /dev/null +++ b/gnome/dialup-properties/nm-dialup-properties.c @@ -0,0 +1,1131 @@ +/*************************************************************************** + * CVSID: $Id$ + * + * nm-dialup-properties.c : GNOME UI dialogs for manipulating dialup connections + * + * Copyright (C) 2005 David Zeuthen, <davidz@redhat.com> + * + * === + * NOTE NOTE NOTE: All source for nm-dialup-properties is licensed to you + * under your choice of the Academic Free License version 2.0, or the + * GNU General Public License version 2. + * === + * + * Licensed under the Academic Free License version 2.0 + * + * 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 + * + **************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> +#include <gnome.h> +#include <gdk/gdkx.h> +#include <gtk/gtkwindow.h> +#include <glade/glade.h> +#include <gconf/gconf-client.h> +#include <glib/gi18n.h> + +#define NM_DIALUP_API_SUBJECT_TO_CHANGE +#include "nm-dialup-ui-interface.h" +#include "clipboard.h" + +#define NM_GCONF_DIALUP_CONNECTIONS_PATH "/system/networking/dialup_connections" + +static GladeXML *xml; +static GConfClient *gconf_client; +static GtkWidget *dialog; +static GtkWindow *druid_window; +static GtkTreeView *dialup_conn_view; +static GtkListStore *dialup_conn_list; +static GtkWidget *dialup_edit; +static GtkWidget *dialup_export; +static GtkWidget *dialup_delete; +static GnomeDruid *druid; +static GnomeDruidPageEdge *druid_confirm_page; +static GtkComboBox *dialup_type_combo_box; +static GtkVBox *dialup_type_details; +static GtkDialog *edit_dialog; +static GSList *dialup_types; + +static NetworkManagerDialupUI * +find_dialup_ui_by_service_type (const char *service_type) +{ + GSList *i; + + g_return_val_if_fail (service_type != NULL, NULL); + + for (i = dialup_types; i != NULL; i = g_slist_next (i)) { + NetworkManagerDialupUI *dialup_ui; + const char * dialup_ui_service_type; + + dialup_ui = i->data; + dialup_ui_service_type = dialup_ui->get_service_type (dialup_ui); + if (dialup_ui_service_type && strcmp (dialup_ui_service_type, service_type) == 0) + return dialup_ui; + } + + return NULL; +} + +enum { + DIALUPCONN_NAME_COLUMN, + DIALUPCONN_SVC_NAME_COLUMN, + DIALUPCONN_SVC_TYPE_COLUMN, + DIALUPCONN_GCONF_COLUMN, + DIALUPCONN_USER_CAN_EDIT_COLUMN, + DIALUPCONN_N_COLUMNS +}; + +static void +update_edit_del_sensitivity (void) +{ + GtkTreeSelection *selection; + gboolean is_editable = FALSE, is_exportable = FALSE; + GtkTreeIter iter; + + selection = gtk_tree_view_get_selection (dialup_conn_view); + if (!selection || !gtk_tree_selection_get_selected (selection, NULL, &iter)) + is_editable = is_exportable = FALSE; + else { + NetworkManagerDialupUI *dialup_ui; + const char *service_type = NULL; + + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), &iter, DIALUPCONN_USER_CAN_EDIT_COLUMN, &is_editable, -1); + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), &iter, DIALUPCONN_SVC_TYPE_COLUMN, &service_type, -1); + + dialup_ui = find_dialup_ui_by_service_type (service_type); + if (dialup_ui) + is_exportable = dialup_ui->can_export (dialup_ui); + } + + gtk_widget_set_sensitive (dialup_edit, is_editable); + gtk_widget_set_sensitive (dialup_delete, is_editable); + gtk_widget_set_sensitive (dialup_export, is_editable && is_exportable); +} + +static gboolean +add_dialup_connection (const char *conn_name, const char *service_name, + const char *service_type, GSList *conn_data) +{ + char *gconf_key; + GtkTreeIter iter; + char conn_gconf_path[PATH_MAX]; + char *escaped_conn_name; + gboolean ret; + gboolean conn_user_can_edit = TRUE; + + ret = FALSE; + + escaped_conn_name = gconf_escape_key (conn_name, strlen (conn_name)); + + g_snprintf (conn_gconf_path, + sizeof (conn_gconf_path), + NM_GCONF_DIALUP_CONNECTIONS_PATH "/%s", + escaped_conn_name); + + if (gconf_client_dir_exists (gconf_client, conn_gconf_path, NULL)) + goto out; + + /* User-visible name of connection */ + gconf_key = g_strdup_printf ("%s/name", conn_gconf_path); + gconf_client_set_string (gconf_client, gconf_key, conn_name, NULL); + + /* Service name of connection */ + gconf_key = g_strdup_printf ("%s/service_name", conn_gconf_path); + gconf_client_set_string (gconf_client, gconf_key, service_name, NULL); + + /* Service name of connection */ + gconf_key = g_strdup_printf ("%s/service_type", conn_gconf_path); + gconf_client_set_string (gconf_client, gconf_key, service_type, NULL); + + /* dialup-daemon specific data */ + gconf_key = g_strdup_printf ("%s/dialup_data", conn_gconf_path); + { + gconf_client_set_list (gconf_client, gconf_key, GCONF_VALUE_STRING, conn_data, NULL); + } + + + gconf_client_suggest_sync (gconf_client, NULL); + + conn_user_can_edit = TRUE; + + gtk_list_store_append (dialup_conn_list, &iter); + gtk_list_store_set (dialup_conn_list, &iter, + DIALUPCONN_NAME_COLUMN, conn_name, + DIALUPCONN_SVC_NAME_COLUMN, service_name, + DIALUPCONN_SVC_TYPE_COLUMN, service_type, + DIALUPCONN_GCONF_COLUMN, conn_gconf_path, + DIALUPCONN_USER_CAN_EDIT_COLUMN, &conn_user_can_edit, + -1); + + ret = TRUE; + +out: + g_free (escaped_conn_name); + return ret; +} + +static void +dialup_druid_dialup_validity_changed (NetworkManagerDialupUI *dialup_ui, + gboolean is_valid, + gpointer user_data) +{ + char *conn_name; + GtkTreeIter iter; + + /*printf ("dialup_druid_dialup_validity_changed %d!\n", is_valid);*/ + + conn_name = dialup_ui->get_connection_name (dialup_ui); + + /* get list of existing connection names */ + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialup_conn_list), &iter)) { + do { + char *name; + + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), + &iter, + DIALUPCONN_NAME_COLUMN, + &name, + -1); + + if (strcmp (name, conn_name) == 0) { + /*printf ("name '%s' is already in use\n", conn_name);*/ + is_valid = FALSE; + break; + } + + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (dialup_conn_list), &iter)); + } + + g_free (conn_name); + + gnome_druid_set_buttons_sensitive (druid, + TRUE, + is_valid, + TRUE, + FALSE); +} + + +static gboolean dialup_druid_dialup_type_page_next (GnomeDruidPage *druidpage, + GtkWidget *widget, + gpointer user_data) +{ + GtkWidget *w; + NetworkManagerDialupUI *dialup_ui; + + /*printf ("dialup_type_next!\n");*/ + + /* first hide existing child */ + w = g_list_nth_data (gtk_container_children (GTK_CONTAINER (dialup_type_details)), 0); + if (w) + gtk_widget_hide (w); + /* hide the previous widget from the next page, in case the user hit 'back' */ + w = g_list_nth_data (gtk_container_children (GTK_CONTAINER (dialup_type_details)), 1); + if (w) + gtk_widget_hide (w); + + /* show appropriate child */ + dialup_ui = (NetworkManagerDialupUI *) g_slist_nth_data (dialup_types, gtk_combo_box_get_active (dialup_type_combo_box)); + if (dialup_ui != NULL) { + w = dialup_ui->get_widget (dialup_ui, NULL, NULL); + if (w != NULL) { + GtkWidget *old_parent; + gtk_widget_ref (w); + old_parent = gtk_widget_get_parent (w); + if (old_parent != NULL) + gtk_container_remove (GTK_CONTAINER (old_parent), w); + gtk_container_add (GTK_CONTAINER (dialup_type_details), w); + gtk_widget_unref (w); + + gtk_widget_show_all (w); + } + + dialup_ui->set_validity_changed_callback (dialup_ui, dialup_druid_dialup_validity_changed, NULL); + } + + return FALSE; +} + +static void dialup_druid_dialup_details_page_prepare (GnomeDruidPage *druidpage, + GtkWidget *widget, + gpointer user_data) +{ + gboolean is_valid; + NetworkManagerDialupUI *dialup_ui; + + is_valid = FALSE; + + /*printf ("dialup_druid_von_details_page_prepare!\n");*/ + + /* validate input, in case we are coming in via 'Back' */ + dialup_ui = (NetworkManagerDialupUI *) g_slist_nth_data (dialup_types, gtk_combo_box_get_active (dialup_type_combo_box)); + if (dialup_ui != NULL) + is_valid = dialup_ui->is_valid (dialup_ui); + + gnome_druid_set_buttons_sensitive (druid, TRUE, is_valid, TRUE, FALSE); +} + +static gboolean dialup_druid_dialup_details_page_next (GnomeDruidPage *druidpage, + GtkWidget *widget, + gpointer user_data) +{ + gboolean is_valid; + NetworkManagerDialupUI *dialup_ui; + + is_valid = FALSE; + + /*printf ("dialup_details_next!\n");*/ + + /* validate input */ + dialup_ui = (NetworkManagerDialupUI *) g_slist_nth_data (dialup_types, gtk_combo_box_get_active (dialup_type_combo_box)); + if (dialup_ui != NULL) + is_valid = dialup_ui->is_valid (dialup_ui); + + return !is_valid; +} + +static void +dialup_druid_dialup_confirm_page_prepare (GnomeDruidPage *druidpage, + GtkWidget *widget, + gpointer user_data) +{ + NetworkManagerDialupUI *dialup_ui; + + /*printf ("dialup_confirm_prepare!\n");*/ + + dialup_ui = (NetworkManagerDialupUI *) g_slist_nth_data (dialup_types, gtk_combo_box_get_active (dialup_type_combo_box)); + if (dialup_ui != NULL) { + gchar *confirm_text; + + dialup_ui->get_confirmation_details (dialup_ui, &confirm_text); + + gnome_druid_page_edge_set_text (druid_confirm_page, + confirm_text); + + g_free (confirm_text); + } +} + +static gboolean +dialup_druid_dialup_confirm_page_finish (GnomeDruidPage *druidpage, + GtkWidget *widget, + gpointer user_data) +{ + GSList *conn_data; + char *conn_name; + NetworkManagerDialupUI *dialup_ui; + + /*printf ("dialup_confirm_finish!\n");*/ + + dialup_ui = (NetworkManagerDialupUI *) g_slist_nth_data (dialup_types, gtk_combo_box_get_active (dialup_type_combo_box)); + conn_name = dialup_ui->get_connection_name (dialup_ui); + conn_data = dialup_ui->get_properties (dialup_ui); + + add_dialup_connection (conn_name, dialup_ui->get_service_name (dialup_ui), + dialup_ui->get_service_type( dialup_ui ), + conn_data); + + gtk_widget_hide_all (GTK_WIDGET (druid_window)); + + return FALSE; +} + +static gboolean dialup_druid_cancel (GnomeDruid *ignored_druid, gpointer user_data) +{ + gtk_widget_hide_all (GTK_WIDGET (druid_window)); + return FALSE; +} + +static gboolean dialup_window_close (GtkWidget *ignored, gpointer user_data) +{ + gtk_widget_hide_all (GTK_WIDGET (druid_window)); + return TRUE; +} + +static void +add_cb (GtkButton *button, gpointer user_data) +{ + GtkWidget *w; + GList *i; + GList *children; + + /* Bail out if we don't have any dialup implementations on our system */ + if (dialup_types == NULL || g_slist_length (dialup_types) == 0) { + GtkWidget *err_dialog; + + err_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Cannot add dialup connection")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog), + _("No suitable dialup plugin was found on your system. Contact your system administrator.")); + gtk_dialog_run (GTK_DIALOG (err_dialog)); + gtk_widget_destroy (err_dialog); + goto out; + } + + /* remove existing dialup widget */ + children = gtk_container_get_children (GTK_CONTAINER (dialup_type_details)); + for (i = children; i != NULL; i = g_list_next (i)) { + w = GTK_WIDGET (i->data); + g_object_ref (G_OBJECT (w)); + gtk_container_remove (GTK_CONTAINER (dialup_type_details), w); + } + g_list_free (children); + + w = glade_xml_get_widget (xml, "dialup-druid-dialup-start"); + gnome_druid_set_page (druid, GNOME_DRUID_PAGE (w)); + + gtk_widget_set_sensitive (w, TRUE); + + gtk_window_set_policy (druid_window, FALSE, FALSE, TRUE); + + gtk_widget_show_all (GTK_WIDGET (druid_window)); + +out: + ; +} + + +static void +import_settings (const char *svc_type, const char *name) +{ + GtkWidget *w; + GList *i; + GList *children; + NetworkManagerDialupUI *dialup_ui; + + /*printf ("import_settings svc_name='%s', name='%s' dialup-ui-=\n", svc_name, name);*/ + + dialup_ui = find_dialup_ui_by_service_type (svc_type); + + /* Bail out if we don't have the requested dialup implementation on our system */ + if (dialup_ui == NULL) { + char *basename; + GtkWidget *err_dialog; + + basename = g_path_get_basename (name); + + err_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Cannot import dialup connection")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog), + _("Cannot find suitable software for dialup connection type '%s' to import the file '%s'. Contact your system administrator."), + svc_type, basename); + gtk_dialog_run (GTK_DIALOG (err_dialog)); + gtk_widget_destroy (err_dialog); + g_free (basename); + goto out; + } + + /* remove existing dialup widget */ + children = gtk_container_get_children (GTK_CONTAINER (dialup_type_details)); + for (i = children; i != NULL; i = g_list_next (i)) { + w = GTK_WIDGET (i->data); + g_object_ref (G_OBJECT (w)); + gtk_container_remove (GTK_CONTAINER (dialup_type_details), w); + } + g_list_free (children); + + w = glade_xml_get_widget (xml, "dialup-druid-dialup-details-page"); + gnome_druid_set_page (druid, GNOME_DRUID_PAGE (w)); + + /* show appropriate child */ + w = dialup_ui->get_widget (dialup_ui, NULL, NULL); + if (w != NULL) { + GtkWidget *old_parent; + gtk_widget_ref (w); + old_parent = gtk_widget_get_parent (w); + if (old_parent != NULL) + gtk_container_remove (GTK_CONTAINER (old_parent), w); + gtk_container_add (GTK_CONTAINER (dialup_type_details), w); + gtk_widget_unref (w); + gtk_widget_show_all (w); + } + + dialup_ui->set_validity_changed_callback (dialup_ui, dialup_druid_dialup_validity_changed, NULL); + + dialup_ui->import_file (dialup_ui, name); + + gtk_widget_set_sensitive (w, TRUE); + + gtk_window_set_policy (druid_window, FALSE, FALSE, TRUE); + gtk_widget_show_all (GTK_WIDGET (druid_window)); + +out: + ; +} + + +static void +dialup_edit_dialup_validity_changed (NetworkManagerDialupUI *dialup_ui, + gboolean is_valid, + gpointer user_data) +{ + const char *orig_conn_name; + char *conn_name; + GtkTreeIter iter; + + orig_conn_name = (const char *) user_data; + + /*printf ("dialup_edit_dialup_validity_changed %d!\n", is_valid);*/ + + conn_name = dialup_ui->get_connection_name (dialup_ui); + + /* get list of existing connection names */ + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialup_conn_list), &iter)) { + do { + char *name; + + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), + &iter, + DIALUPCONN_NAME_COLUMN, + &name, + -1); + + /* Can override the original name (stored in user_data, see edit_cb()) */ + if (strcmp (name, orig_conn_name) != 0) { + if (strcmp (name, conn_name) == 0) { + /*printf ("name '%s' is already in use\n", conn_name);*/ + is_valid = FALSE; + break; + } + } + + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (dialup_conn_list), &iter)); + } + + g_free (conn_name); + + gtk_dialog_set_response_sensitive (edit_dialog, GTK_RESPONSE_ACCEPT, is_valid); + +} + +static gboolean +retrieve_data_from_selected_connection (NetworkManagerDialupUI **dialup_ui, + GSList **conn_dialup_data, + const char **conn_name, + char **conn_gconf_path) +{ + gboolean result; + const char *conn_service_name; + const char *conn_service_type; + GSList *conn_dialup_data_gconfvalue; + GSList *i; + char key[PATH_MAX]; + GtkTreeSelection *selection; + GtkTreeIter iter; + GConfValue *value; + + result = FALSE; + + if ((selection = gtk_tree_view_get_selection (dialup_conn_view)) == NULL) + goto out; + + if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) + goto out; + + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), + &iter, + DIALUPCONN_GCONF_COLUMN, + conn_gconf_path, + -1); + + g_snprintf (key, sizeof (key), "%s/name", *conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + (*conn_name = gconf_value_get_string (value)) == NULL) + goto out; + + g_snprintf (key, sizeof (key), "%s/service_name", *conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + (conn_service_name = gconf_value_get_string (value)) == NULL) + goto out; + + g_snprintf (key, sizeof (key), "%s/service_type", *conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + (conn_service_type = gconf_value_get_string (value)) == NULL) + goto out; + + *dialup_ui = find_dialup_ui_by_service_type (conn_service_type); + if (*dialup_ui == NULL) { + GtkWidget *err_dialog; + + err_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Error retrieving dialup connection '%s'"), + *conn_name); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog), + _("Could not find the UI files for dialup connection type '%s'. Contact your system administrator."), + conn_service_type); + gtk_dialog_run (GTK_DIALOG (err_dialog)); + gtk_widget_destroy (err_dialog); + goto out; + } + + g_snprintf (key, sizeof (key), "%s/dialup_data", *conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + gconf_value_get_list_type (value) != GCONF_VALUE_STRING || + (conn_dialup_data_gconfvalue = gconf_value_get_list (value)) == NULL) + goto out; + + *conn_dialup_data = NULL; + for (i = conn_dialup_data_gconfvalue; i != NULL; i = g_slist_next (i)) { + const char *val; + val = gconf_value_get_string ((GConfValue *) i->data); + *conn_dialup_data = g_slist_append (*conn_dialup_data, (gpointer) val); + } + + + result = TRUE; + +out: + return result; +} + +static void +edit_cb (GtkButton *button, gpointer user_data) +{ + gint result; + GtkWidget *dialup_edit_widget; + NetworkManagerDialupUI *dialup_ui; + GSList *conn_dialup_data; + const char *conn_name; + char key[PATH_MAX]; + char *conn_gconf_path; + GtkTreeIter iter; + + /*printf ("edit_cb\n");*/ + + if (!retrieve_data_from_selected_connection (&dialup_ui, &conn_dialup_data, &conn_name, &conn_gconf_path)) + goto out; + + dialup_edit_widget = dialup_ui->get_widget (dialup_ui, conn_dialup_data, conn_name); + + g_slist_free (conn_dialup_data); + + dialup_ui->set_validity_changed_callback (dialup_ui, dialup_edit_dialup_validity_changed, (gpointer) conn_name); + + gtk_widget_reparent (dialup_edit_widget, GTK_WIDGET (edit_dialog->vbox)); + + gtk_widget_show_all (dialup_edit_widget); + /*gtk_widget_set_sensitive (dialup_edit_widget, TRUE);*/ + + /* auto-shrink our window */ + gtk_window_set_policy (GTK_WINDOW (edit_dialog), FALSE, FALSE, TRUE); + + gtk_widget_show (GTK_WIDGET (edit_dialog)); + + result = gtk_dialog_run (GTK_DIALOG (edit_dialog)); + + if (result == GTK_RESPONSE_ACCEPT) { + char *new_conn_name; + GSList *new_conn_data; + + new_conn_name = dialup_ui->get_connection_name (dialup_ui); + new_conn_data = dialup_ui->get_properties (dialup_ui); + + if (strcmp (new_conn_name, conn_name) == 0) { + /* same name, just update properties */ + g_snprintf (key, sizeof (key), "%s/dialup_data", conn_gconf_path); + gconf_client_set_list (gconf_client, key, GCONF_VALUE_STRING, new_conn_data, NULL); + + gconf_client_suggest_sync (gconf_client, NULL); + } else { + /* remove old entry */ + g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/service_name", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/service_type", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/dialup_data", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/user_name", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + gconf_client_unset (gconf_client, conn_gconf_path, NULL); + gconf_client_suggest_sync (gconf_client, NULL); + gtk_list_store_remove (dialup_conn_list, &iter); + + /* add new entry */ + add_dialup_connection (new_conn_name, + dialup_ui->get_service_name (dialup_ui), + dialup_ui->get_service_type( dialup_ui ), + new_conn_data); + } + + if (new_conn_data != NULL) { + g_slist_foreach (new_conn_data, (GFunc)g_free, NULL); + g_slist_free (new_conn_data); + } + } + + gtk_widget_hide (GTK_WIDGET (dialup_edit_widget)); + gtk_widget_hide (GTK_WIDGET (edit_dialog)); + +out: + ; +} + +static void +delete_cb (GtkButton *button, gpointer user_data) +{ + GtkTreeIter iter; + GtkTreeSelection *selection; + gchar *conn_gconf_path; + gchar *conn_name; + GtkWidget *confirm_dialog; + int response; + + /*printf ("delete\n");*/ + + if ((selection = gtk_tree_view_get_selection (dialup_conn_view)) == NULL) + goto out; + + if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) + goto out; + + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), &iter, DIALUPCONN_NAME_COLUMN, &conn_name, -1); + confirm_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CANCEL, + _("Delete dialup connection \"%s\"?"), conn_name); + gtk_dialog_add_buttons (GTK_DIALOG (confirm_dialog), GTK_STOCK_DELETE, GTK_RESPONSE_OK, NULL); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (confirm_dialog), + _("All information about the dialup connection \"%s\" will be lost and you may need your system administrator to provide information to create a new connection."), conn_name); + response = gtk_dialog_run (GTK_DIALOG (confirm_dialog)); + gtk_widget_destroy (confirm_dialog); + + if (response != GTK_RESPONSE_OK) + goto out; + + gtk_tree_model_get (GTK_TREE_MODEL (dialup_conn_list), &iter, DIALUPCONN_GCONF_COLUMN, &conn_gconf_path, -1); + + if (conn_gconf_path != NULL) { + char key[PATH_MAX]; + + g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/service_name", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/service_type", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/dialup_data", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/last_attempt_success", conn_gconf_path); + gconf_client_unset (gconf_client, key, NULL); + + gconf_client_unset (gconf_client, conn_gconf_path, NULL); + + gconf_client_suggest_sync (gconf_client, NULL); + + if (gtk_list_store_remove (dialup_conn_list, &iter)) + gtk_tree_selection_select_iter (selection, &iter); + } + + update_edit_del_sensitivity (); + +out: + ; +} + +static void +response_cb (void) +{ + gtk_widget_destroy (dialog); + gtk_main_quit (); +} + +static gboolean +delete_event_cb (GtkDialog *the_dialog) +{ + gtk_dialog_response (the_dialog, GTK_RESPONSE_DELETE_EVENT); + return TRUE; +} + +static void +export_cb (GtkButton *button, gpointer user_data) +{ + NetworkManagerDialupUI *dialup_ui; + GSList *conn_dialup_data; + const char *conn_name; + char *conn_gconf_path; + + /*printf ("export_cb\n");*/ + + if (!retrieve_data_from_selected_connection (&dialup_ui, &conn_dialup_data, &conn_name, &conn_gconf_path)) + goto out; + + dialup_ui->export (dialup_ui, conn_dialup_data, conn_name); + +out: + ; +} + +static void get_all_dialup_connections (void) +{ + GtkTreeIter iter; + GSList *dialup_conn = NULL; + + for (dialup_conn = gconf_client_all_dirs (gconf_client, NM_GCONF_DIALUP_CONNECTIONS_PATH, NULL); + dialup_conn != NULL; + dialup_conn = g_slist_next (dialup_conn)) { + char key[PATH_MAX]; + GConfValue *value; + const char *conn_gconf_path; + const char *conn_name; + const char *conn_service_name; + const char *conn_service_type; + GSList *conn_dialup_data; + gboolean conn_user_can_edit = TRUE; + + conn_gconf_path = (const char *) (dialup_conn->data); + + g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path); + conn_user_can_edit = gconf_client_key_is_writable (gconf_client, key, NULL); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + (conn_name = gconf_value_get_string (value)) == NULL) + goto error; + + g_snprintf (key, sizeof (key), "%s/service_name", conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + (conn_service_name = gconf_value_get_string (value)) == NULL) + goto error; + + g_snprintf (key, sizeof (key), "%s/service_type", conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + (conn_service_type = gconf_value_get_string (value)) == NULL) + goto error; + + g_snprintf (key, sizeof (key), "%s/dialup_data", conn_gconf_path); + if ((value = gconf_client_get (gconf_client, key, NULL)) == NULL || + gconf_value_get_list_type (value) != GCONF_VALUE_STRING || + (conn_dialup_data = gconf_value_get_list (value)) == NULL) + goto error; + + // do conn_user_can_edit check here if appropriate + + gtk_list_store_append (dialup_conn_list, &iter); + gtk_list_store_set (dialup_conn_list, &iter, + DIALUPCONN_NAME_COLUMN, conn_name, + DIALUPCONN_SVC_NAME_COLUMN, conn_service_name, + DIALUPCONN_SVC_TYPE_COLUMN, conn_service_type, + DIALUPCONN_GCONF_COLUMN, conn_gconf_path, + DIALUPCONN_USER_CAN_EDIT_COLUMN, conn_user_can_edit, + -1); + +#if 0 + printf ("conn_name = '%s'\n", conn_name); + printf ("conn_service_name = '%s'\n", conn_service_name); + printf ("conn_service_type = '%s'\n", conn_service_type); + printf ("conn_dialup_data = {"); + { + GSList *i; + for (i = conn_dialup_data; i != NULL; i = g_slist_next (i)) { + printf ("'%s'", gconf_value_get_string ((GConfValue *) i->data)); + if (g_slist_next (i) != NULL) + printf (", "); + } + printf ("}\n"); + } +#endif + +error: + g_free (dialup_conn->data); + } +} + +static void +dialup_list_cursor_changed_cb (GtkTreeView *treeview, + gpointer user_data) +{ + /*printf ("*** dialup_list_cursor_changed_cb\n");*/ + + update_edit_del_sensitivity (); +} + +/* TODO: remove these once we get the GModule thing going */ +//extern NetworkManagerDialupUI* dialup_ui_factory_dialupc (void); +extern NetworkManagerDialupUI* dialup_ui_factory_dummy (void); + +static void +load_properties_module (GSList **dialup_types_list, const char *path) +{ + GModule *module; + NetworkManagerDialupUI* (*nm_dialup_properties_factory) (void) = NULL; + NetworkManagerDialupUI* impl; + + module = g_module_open (path, G_MODULE_BIND_LAZY); + if (module == NULL) { + g_warning ("Cannot open module '%s'", path); + goto out; + } + + if (!g_module_symbol (module, "nm_dialup_properties_factory", + (gpointer) &nm_dialup_properties_factory)) { + g_warning ("Cannot locate function 'nm_dialup_properties_factory' in '%s': %s", + path, g_module_error ()); + g_module_close (module); + goto out; + } + + impl = nm_dialup_properties_factory (); + if (impl == NULL) { + g_warning ("Function 'nm_dialup_properties_factory' in '%s' returned NULL", path); + g_module_close (module); + goto out; + } + + *dialup_types_list = g_slist_append (*dialup_types_list, impl); + +out: + ; +} + +static gboolean +init_app (void) +{ + GtkWidget *w; + gchar *glade_file; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GSList *i; + GtkHBox *dialup_type_hbox1; + GtkWidget *toplevel; + GDir *dir; + + if (!dialup_get_clipboard ()) + return FALSE; + + gconf_client = gconf_client_get_default (); + gconf_client_add_dir (gconf_client, NM_GCONF_DIALUP_CONNECTIONS_PATH, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-dialup-properties.glade"); + xml = glade_xml_new (glade_file, NULL, NULL); + g_free (glade_file); + if (!xml) { + GtkWidget *err_dialog; + + err_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Unable to load")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog), + _("Cannot find some needed resources (the glade file)!")); + gtk_dialog_run (GTK_DIALOG (err_dialog)); + gtk_widget_destroy (err_dialog); + + return FALSE; + } + + /* Load all dialup UI modules by inspecting .name files */ + dialup_types = NULL; + if ((dir = g_dir_open (DIALUP_NAME_FILES_DIR, 0, NULL)) != NULL) { + const char *f; + + while ((f = g_dir_read_name (dir)) != NULL) { + char *path; + GKeyFile *keyfile; + + if (!g_str_has_suffix (f, ".name")) + continue; + + path = g_strdup_printf ("%s/%s", DIALUP_NAME_FILES_DIR, f); + + keyfile = g_key_file_new (); + if (g_key_file_load_from_file (keyfile, path, 0, NULL)) { + char *so_path; + + if ((so_path = g_key_file_get_string (keyfile, + "GNOME", + "properties", NULL)) != NULL) { + load_properties_module (&dialup_types, so_path); + g_free (so_path); + } + } + g_key_file_free (keyfile); + g_free (path); + } + g_dir_close (dir); + } + + dialog = glade_xml_get_widget (xml, "dialup-ui-properties"); + + dialup_type_details = GTK_VBOX (glade_xml_get_widget (xml, "dialup-connection-druid-details-box")); + + w = glade_xml_get_widget (xml, "add"); + gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (add_cb), NULL); + dialup_edit = glade_xml_get_widget (xml, "edit"); + gtk_signal_connect (GTK_OBJECT (dialup_edit), "clicked", GTK_SIGNAL_FUNC (edit_cb), NULL); + dialup_export = glade_xml_get_widget (xml, "export"); + gtk_signal_connect (GTK_OBJECT (dialup_export), "clicked", GTK_SIGNAL_FUNC (export_cb), NULL); + dialup_delete = glade_xml_get_widget (xml, "delete"); + gtk_signal_connect (GTK_OBJECT (dialup_delete), "clicked", GTK_SIGNAL_FUNC (delete_cb), NULL); + g_signal_connect (dialog, "response", + G_CALLBACK (response_cb), NULL); + g_signal_connect (dialog, "delete_event", + G_CALLBACK (delete_event_cb), NULL); + + dialup_conn_view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "dialuplist")); + dialup_conn_list = gtk_list_store_new (DIALUPCONN_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); + + gtk_signal_connect_after (GTK_OBJECT (dialup_conn_view), "cursor-changed", + GTK_SIGNAL_FUNC (dialup_list_cursor_changed_cb), NULL); + + get_all_dialup_connections (); + + column = gtk_tree_view_column_new (); + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (column, renderer, TRUE); + gtk_tree_view_column_set_attributes (column, renderer, + "text", DIALUPCONN_NAME_COLUMN, + NULL); + gtk_tree_view_append_column (dialup_conn_view, column); + + gtk_tree_view_set_model (dialup_conn_view, GTK_TREE_MODEL (dialup_conn_list)); + gtk_tree_view_expand_all (dialup_conn_view); + + gtk_widget_show_all (dialog); + + /* fill in possibly choices in the druid when adding a connection */ + dialup_type_hbox1 = GTK_HBOX (glade_xml_get_widget (xml, "dialup-create-connection-druid-hbox1")); + dialup_type_combo_box = GTK_COMBO_BOX (gtk_combo_box_new_text ()); + for (i = dialup_types; i != NULL; i = g_slist_next (i)) { + NetworkManagerDialupUI *dialup_ui = i->data; + gtk_combo_box_append_text (dialup_type_combo_box, dialup_ui->get_display_name (dialup_ui)); + } + gtk_combo_box_set_active (dialup_type_combo_box, 0); + gtk_box_pack_end (GTK_BOX (dialup_type_hbox1), GTK_WIDGET (dialup_type_combo_box), TRUE, TRUE, 0); + + /* Druid */ + druid = GNOME_DRUID (glade_xml_get_widget (xml, "dialup-create-connection-druid")); + gtk_signal_connect (GTK_OBJECT (druid), "cancel", GTK_SIGNAL_FUNC (dialup_druid_cancel), NULL); + druid_confirm_page = GNOME_DRUID_PAGE_EDGE (glade_xml_get_widget (xml, "dialup-druid-dialup-confirm-page")); + /* use connect_after, otherwise gnome_druid_set_buttons_sensitive() won't work in prepare handlers */ + w = glade_xml_get_widget (xml, "dialup-druid-dialup-type-page"); + gtk_signal_connect_after (GTK_OBJECT (w), "next", GTK_SIGNAL_FUNC (dialup_druid_dialup_type_page_next), NULL); + w = glade_xml_get_widget (xml, "dialup-druid-dialup-details-page"); + gtk_signal_connect_after (GTK_OBJECT (w), "prepare", GTK_SIGNAL_FUNC (dialup_druid_dialup_details_page_prepare), NULL); + gtk_signal_connect_after (GTK_OBJECT (w), "next", GTK_SIGNAL_FUNC (dialup_druid_dialup_details_page_next), NULL); + w = glade_xml_get_widget (xml, "dialup-druid-dialup-confirm-page"); + gtk_signal_connect_after (GTK_OBJECT (w), "prepare", GTK_SIGNAL_FUNC (dialup_druid_dialup_confirm_page_prepare), NULL); + gtk_signal_connect_after (GTK_OBJECT (w), "finish", GTK_SIGNAL_FUNC (dialup_druid_dialup_confirm_page_finish), NULL); + + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (druid)); + gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event", GTK_SIGNAL_FUNC (dialup_window_close), NULL); + + druid_window = GTK_WINDOW (glade_xml_get_widget (xml, "dialup-create-connection")); + + /* make the druid window modal wrt. our main window */ + gtk_window_set_modal (druid_window, TRUE); + gtk_window_set_transient_for (druid_window, GTK_WINDOW (dialog)); + + /* Edit dialog */ + edit_dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Edit dialup Connection"), + NULL, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + GTK_STOCK_APPLY, + GTK_RESPONSE_ACCEPT, + NULL)); + + /* update "Edit" and "Delete" for current selection */ + update_edit_del_sensitivity (); + + return TRUE; +} + +int +main (int argc, char *argv[]) +{ + GOptionContext *context; + int ret; + gboolean bad_opts; + gboolean do_import; + gchar *import_svc = NULL; + gchar *import_file = NULL; + GOptionEntry entries[] = { + { "import-service", 's', 0, G_OPTION_ARG_STRING, &import_svc, "Dialup Service for importing", NULL}, + { "import-file", 'f', 0, G_OPTION_ARG_FILENAME, &import_file, "File to import", NULL}, + { NULL } + }; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + context = g_option_context_new ("- NetworkManager dialup properties"); + g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); + +#ifdef HAVE_LIBGNOME_2_14 + gnome_program_init ("nm-dialup-properties", VERSION, LIBGNOMEUI_MODULE, argc, argv, + GNOME_PARAM_GOPTION_CONTEXT, context, + GNOME_PARAM_NONE); +#else + { + GError *error = NULL; + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + g_option_context_parse (context, &argc, &argv, &error); + g_option_context_free (context); + } + + gnome_program_init ("nm-dialup-properties", VERSION, LIBGNOMEUI_MODULE, argc, argv, + GNOME_PARAM_NONE, GNOME_PARAM_NONE); +#endif + + bad_opts = FALSE; + do_import = FALSE; + if (import_svc != NULL) { + if (import_file != NULL) + do_import = TRUE; + else + bad_opts = TRUE; + } else if (import_file != NULL) + bad_opts = TRUE; + + if (bad_opts) { + fprintf (stderr, "Have to supply both service and file\n"); + ret = EXIT_FAILURE; + goto out; + } + + if (init_app () == FALSE) { + ret = EXIT_FAILURE; + goto out; + } + + if (do_import) + import_settings (import_svc, import_file); + + gtk_main (); + + ret = EXIT_SUCCESS; + +out: + return ret; +} diff --git a/gnome/dialup-properties/nm-dialup-properties.glade b/gnome/dialup-properties/nm-dialup-properties.glade new file mode 100644 index 0000000000..3821515e64 --- /dev/null +++ b/gnome/dialup-properties/nm-dialup-properties.glade @@ -0,0 +1,436 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> +<requires lib="gnome"/> + +<widget class="GtkDialog" id="dialup-ui-properties"> + <property name="border_width">5</property> + <property name="width_request">400</property> + <property name="height_request">300</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Dialup Connections</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="icon_name">gtk-network</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">False</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="closebutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-close</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-7</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox25"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkLabel" id="label29"> + <property name="visible">True</property> + <property name="label" translatable="yes">Manage Dialup Connections</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox70"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="dialuplist"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">False</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkVButtonBox" id="vbuttonbox1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_START</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkButton" id="add"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Add a new VPN connection</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-add</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="edit"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Edit the selected VPN connection</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-edit</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="export"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Export the selected VPN connection to a file</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox71"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-save</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label33"> + <property name="visible">True</property> + <property name="label" translatable="yes">E_xport</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + <accessibility> + <atkproperty name="AtkObject::accessible_description" translatable="yes">Export the VPN settings to a file</atkproperty> + </accessibility> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkButton" id="delete"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Delete the selected VPN connection</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-delete</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +<widget class="GtkWindow" id="dialup-create-connection"> + <property name="border_width">5</property> + <property name="title" translatable="yes">Create Dialup Connection</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GnomeDruid" id="dialup-create-connection-druid"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="show_help">False</property> + + <child> + <widget class="GnomeDruidPageEdge" id="dialup-druid-dialup-start"> + <property name="visible">True</property> + <property name="position">GNOME_EDGE_START</property> + <property name="title" translatable="yes">Create Dialup Connection</property> + <property name="text" translatable="yes">This assistant will guide you through the creation of a dialup connection (for example via PPP). + +It will require some information, such as login data and phone numbers. Please see ask your Internet service provider to obtain this information.</property> + </widget> + </child> + + <child> + <widget class="GnomeDruidPageStandard" id="dialup-druid-dialup-type-page"> + <property name="visible">True</property> + <property name="title" translatable="yes">Create Dialup Connection - 1 of 2</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="druid-vbox4"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkVBox" id="vbox24"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label31"> + <property name="visible">True</property> + <property name="label" translatable="yes">Choose which type of dialup connection you wish to create.</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">12</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="dialup-create-connection-druid-hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkLabel" id="label32"> + <property name="visible">True</property> + <property name="label" translatable="yes">Connect via:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GnomeDruidPageStandard" id="dialup-druid-dialup-details-page"> + <property name="visible">True</property> + <property name="title" translatable="yes">Create Dialup Connection - 2 of 2</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialup-connection-druid-details-box"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <placeholder/> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GnomeDruidPageEdge" id="dialup-druid-dialup-confirm-page"> + <property name="visible">True</property> + <property name="position">GNOME_EDGE_FINISH</property> + <property name="title" translatable="yes">Finish Creating Dialup Connection</property> + <property name="text" translatable="yes"></property> + </widget> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/gnome/dialup-properties/nm-dialup-ui-interface.h b/gnome/dialup-properties/nm-dialup-ui-interface.h new file mode 100644 index 0000000000..fa30d557c0 --- /dev/null +++ b/gnome/dialup-properties/nm-dialup-ui-interface.h @@ -0,0 +1,84 @@ +/*************************************************************************** + * CVSID: $Id$ + * + * nm-dialup-ui-interface.h : Public interface for dialup UI editing widgets + * + * Copyright (C) 2005 David Zeuthen, <davidz@redhat.com> + * Copyright (C) 2006 Tim Niemueller [www.niemueller.de] + * + * === + * NOTE NOTE NOTE: All source for nm-dialup-properties is licensed to you + * under your choice of the Academic Free License version 2.0, or the + * GNU General Public License version 2. + * === + * + * Licensed under the Academic Free License version 2.0 + * + * 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 + * + **************************************************************************/ + +#ifndef NM_DIALUP_UI_INTERFACE_H +#define NM_DIALUP_UI_INTERFACE_H + +#ifndef NM_DIALUP_API_SUBJECT_TO_CHANGE +#error "Please define NM_DIALUP_API_SUBJECT_TO_CHANGE to acknowledge your understanding that NetworkManager hasn't reached 1.0 and is subject to protocol and API churn. See the README for a full explanation." +#endif + +#include <gtk/gtk.h> + +struct _NetworkManagerDialupUI; +typedef struct _NetworkManagerDialupUI NetworkManagerDialupUI; + +typedef void (*NetworkManagerDialupUIDialogValidityCallback) (NetworkManagerDialupUI *self, + gboolean is_valid, + gpointer user_data); + + +struct _NetworkManagerDialupUI { + const char *(*get_display_name) (NetworkManagerDialupUI *self); + + const char *(*get_service_name) (NetworkManagerDialupUI *self); + const char *(*get_service_type) (NetworkManagerDialupUI *self); + + GtkWidget *(*get_widget) (NetworkManagerDialupUI *self, GSList *properties, const char *connection_name); + + void (*set_validity_changed_callback) (NetworkManagerDialupUI *self, + NetworkManagerDialupUIDialogValidityCallback cb, + gpointer user_data); + + gboolean (*is_valid) (NetworkManagerDialupUI *self); + + /* + * get_confirmation_details: + * retval is allocated and must be freed + */ + void (*get_confirmation_details)(NetworkManagerDialupUI *self, gchar **retval); + + char *(*get_connection_name) (NetworkManagerDialupUI *self); + + GSList *(*get_properties) (NetworkManagerDialupUI *self); + + gboolean (*can_export) (NetworkManagerDialupUI *self); + + gboolean (*import_file) (NetworkManagerDialupUI *self, const char *path); + + gboolean (*export) (NetworkManagerDialupUI *self, GSList *properties, const char *connection_name); + + gpointer data; +}; + +#endif /* NM_DIALUP_UI_INTERFACE_H */ + |