Get rid of a bunch of "Ethereal"s and "ethereal"s in comments, GUI
[obnox/wireshark/wip.git] / gtk / main.c
index 1c5e8e2ff0138445fa9ffa636ead1db2ab17cc98..4d64ce84ef1c7a73571e1fcca041d9e5b4e1e071 100644 (file)
@@ -2,8 +2,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * Richard Sharpe, 13-Feb-1999, added support for initializing structures
@@ -99,6 +99,7 @@
 #ifdef _WIN32
 #include "capture-wpcap.h"
 #include "capture_wpcap_packet.h"
+#include <tchar.h> /* Needed for Unicode */
 #if GTK_MAJOR_VERSION >= 2
 #include <commctrl.h>
 #endif /* GTK_MAJOR_VERSION >= 2 */
 /* GTK related */
 #include "statusbar.h"
 #include "alert_box.h"
+#if 0
 #include "dlg_utils.h"
+#endif
+#include "file_dlg.h"
 #include "gtkglobals.h"
 #include "colors.h"
 #include "gui_utils.h"
 #include "menu.h"
 #include "../main_window.h"
 #include "../menu.h"
-#include "file_dlg.h"
+#include "capture_file_dlg.h"
 #include <epan/column.h>
 #include "proto_draw.h"
 #include "keys.h"
 
 /*
  * Files under personal and global preferences directories in which
- * GTK settings for Ethereal are stored.
+ * GTK settings for Wireshark are stored.
  */
 #define RC_FILE "gtkrc"
 
@@ -378,7 +382,6 @@ selected_ptree_ref_cb(GtkWidget *widget _U_, gpointer data _U_)
     }
 }
 
-
 static gchar *
 get_text_from_packet_list(gpointer data)
 {
@@ -427,6 +430,36 @@ match_selected_plist_cb(GtkWidget *w _U_, gpointer data, MATCH_SELECTED_E action
         get_text_from_packet_list(data));
 }
 
+/* This function allows users to right click in the details window and copy the text
+ * information to the operating systems clipboard. 
+ *
+ * We first check to see if a string representation is setup in the tree and then
+ * read the string. If not available then we try to grab the value. If all else
+ * fails we display a message to the user to indicate the copy could not be completed.
+ */
+void
+copy_selected_plist_cb(GtkWidget *w _U_, gpointer data _U_)
+{
+       GString *gtk_text_str = g_string_new("");
+    char labelstring[256];
+    char *stringpointer = labelstring;
+
+    if (cfile.finfo_selected->rep->representation != 0) {
+        g_string_sprintfa(gtk_text_str, "%s", cfile.finfo_selected->rep->representation);   /* Get the represented data */
+    }
+    if (gtk_text_str->len == 0) {                                                           /* If no representation then... */
+        proto_item_fill_label(cfile.finfo_selected, stringpointer);                         /* Try to read the value */
+        g_string_sprintfa(gtk_text_str, "%s", stringpointer);
+    }
+    if (gtk_text_str->len == 0) {                                                           /* Could not get item so display error msg */
+        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to copy, try expanding or choosing another item");
+    }
+    else
+    {
+        copy_to_clipboard(gtk_text_str);                     /* Copy string to clipboard */
+    }
+    g_string_free(gtk_text_str, TRUE);                       /* Free the memory */
+}
 
 
 /* XXX: use a preference for this setting! */
@@ -1086,7 +1119,7 @@ print_usage(gboolean print_ver) {
 
   if (print_ver) {
     output = stdout;
-    fprintf(output, "Ethereal " VERSION "%s\n"
+    fprintf(output, "Wireshark " VERSION "%s\n"
         "Interactively dump and analyze network traffic.\n"
         "See http://www.ethereal.com for more information.\n"
         "\n"
@@ -1106,7 +1139,7 @@ print_usage(gboolean print_ver) {
   fprintf(output, "  -s <snaplen>             packet snapshot length (def: 65535)\n");
   fprintf(output, "  -p                       don't capture in promiscuous mode\n");
   fprintf(output, "  -k                       start capturing immediately (def: do nothing)\n");
-  fprintf(output, "  -Q                       quit Ethereal after capturing\n");
+  fprintf(output, "  -Q                       quit Wireshark after capturing\n");
   fprintf(output, "  -S                       update packet display when new packets are captured\n");
   fprintf(output, "  -l                       turn on automatic scrolling while -S is in use\n");
 #ifdef _WIN32
@@ -1134,7 +1167,7 @@ print_usage(gboolean print_ver) {
 
   fprintf(output, "\n");
   fprintf(output, "Processing:\n");
-  fprintf(output, "  -R <read filter>         packet filter in Ethereal display filter syntax\n");
+  fprintf(output, "  -R <read filter>         packet filter in Wireshark display filter syntax\n");
   fprintf(output, "  -n                       disable all name resolutions (def: all enabled)\n");
   fprintf(output, "  -N <name resolve flags>  enable specific name resolution(s): \"mntC\"\n");
 
@@ -1238,7 +1271,7 @@ update_cb(gpointer data _U_)
 }
 #else
 
-/* if these three functions are copied to gtk1 ethereal, since gtk1 does not
+/* if these three functions are copied to gtk1 Wireshark, since gtk1 does not
    use threads all updte_thread_mutex can be dropped and protect/unprotect
    would just be empty functions.
 
@@ -1320,7 +1353,7 @@ set_display_filename(capture_file *cf)
   g_free(status_msg);
 
   /* window title */
-  win_name = g_strdup_printf("%s - Ethereal", name_ptr);
+  win_name = g_strdup_printf("%s - Wireshark", name_ptr);
   set_main_window_name(win_name);
   g_free(win_name);
 }
@@ -1356,7 +1389,7 @@ main_cf_cb_file_closing(capture_file *cf)
     statusbar_pop_file_msg();
 
     /* Restore the standard title bar message. */
-    set_main_window_name("The Ethereal Network Analyzer");
+    set_main_window_name("The Wireshark Network Analyzer");
 
     /* Disable all menu items that make sense only if you have a capture. */
     set_menus_for_capture_file(FALSE);
@@ -1468,10 +1501,10 @@ main_cf_cb_live_capture_prepared(capture_options *capture_opts)
 
 
     if(capture_opts->iface) {
-        title = g_strdup_printf("%s: Capturing - Ethereal",
+        title = g_strdup_printf("%s: Capturing - Wireshark",
                             get_interface_descriptive_name(capture_opts->iface));
     } else {
-        title = g_strdup_printf("Capturing - Ethereal");
+        title = g_strdup_printf("Capturing - Wireshark");
     }
     set_main_window_name(title);
     g_free(title);
@@ -1503,10 +1536,10 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts)
     /* We've done this in "prepared" above, but it will be cleared while
        switching to the next multiple file. */
     if(capture_opts->iface) {
-        title = g_strdup_printf("%s: Capturing - Ethereal",
+        title = g_strdup_printf("%s: Capturing - Wireshark",
                             get_interface_descriptive_name(capture_opts->iface));
     } else {
-        title = g_strdup_printf("Capturing - Ethereal");
+        title = g_strdup_printf("Capturing - Wireshark");
     }
     set_main_window_name(title);
     g_free(title);
@@ -1676,7 +1709,7 @@ main_cf_cb_live_capture_fixed_finished(capture_file *cf _U_)
 
     /* Restore the standard title bar message */
     /* (just in case we have trouble opening the capture file). */
-    set_main_window_name("The Ethereal Network Analyzer");
+    set_main_window_name("The Wireshark Network Analyzer");
 
 #if GTK_MAJOR_VERSION >= 2
     if(icon_list == NULL) {
@@ -1872,6 +1905,7 @@ static void main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
 int
 main(int argc, char *argv[])
 {
+  char                *init_progfile_dir_error;
   char                *s;
   int                  i;
   int                  opt;
@@ -1924,7 +1958,7 @@ main(int argc, char *argv[])
   /*
    * Attempt to get the pathname of the executable file.
    */
-  init_progfile_dir(argv[0]);
+  init_progfile_dir_error = init_progfile_dir(argv[0]);
 
   /*
    * Get credential information for later use.
@@ -2098,7 +2132,15 @@ main(int argc, char *argv[])
 #endif
 
   /* We won't come till here, if we had a "console only" command line parameter. */
-  splash_win = splash_new("Loading Ethereal ...");
+  splash_win = splash_new("Loading Wireshark ...");
+  if (init_progfile_dir_error != NULL) {
+    simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
+        "Can't get pathname of Wireshark: %s.\n"
+        "It won't be possible to capture traffic.\n"
+        "Report this to the Wireshark developers.",
+        init_progfile_dir_error);
+    g_free(init_progfile_dir_error);
+  }
 
   splash_update(splash_win, "Init dissectors ...");
 
@@ -2466,7 +2508,7 @@ main(int argc, char *argv[])
   if (arg_error) {
 #ifndef HAVE_LIBPCAP
     if (capture_option_specified) {
-      cmdarg_err("This version of Ethereal was not built with support for capturing packets.");
+      cmdarg_err("This version of Wireshark was not built with support for capturing packets.");
     }
 #endif
     print_usage(FALSE);
@@ -2812,7 +2854,7 @@ WinMain (struct HINSTANCE__ *hInstance,
   InitCommonControlsEx(&comm_ctrl);
 
   /* RichEd20.DLL is needed for filter entries. */
-  LoadLibrary("riched20.dll");
+  LoadLibrary(_T("riched20.dll"));
 #endif /* GTK_MAJOR_VERSION >= 2 */
 
   has_console = FALSE;
@@ -2845,7 +2887,7 @@ create_console(void)
        the message(s) we put in there). */
     atexit(destroy_console);
 
-       SetConsoleTitle("Ethereal Debug Console");
+       SetConsoleTitle(_T("Wireshark Debug Console"));
   }
 }
 
@@ -3199,9 +3241,9 @@ welcome_new(void)
     gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 5);
 
 #if GTK_MAJOR_VERSION < 2
-    message = "Welcome to Ethereal!";
+    message = "Welcome to Wireshark!";
 #else
-    message = "<span weight=\"bold\" size=\"25000\">" "Welcome to Ethereal!" "</span>";
+    message = "<span weight=\"bold\" size=\"25000\">" "Welcome to Wireshark!" "</span>";
 #endif
     w = gtk_label_new(message);
 #if GTK_MAJOR_VERSION >= 2
@@ -3400,19 +3442,19 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
     GList         *dfilter_list = NULL;
     GtkTooltips   *tooltips;
     GtkAccelGroup *accel;
-       gchar         *title;
+    gchar         *title;
     /* Display filter construct dialog has an Apply button, and "OK" not
        only sets our text widget, it activates it (i.e., it causes us to
        filter the capture). */
     static construct_args_t args = {
-        "Ethereal: Display Filter",
+        "Wireshark: Display Filter",
         TRUE,
         TRUE,
         FALSE
     };
 
     /* use user-defined title if preference is set */
-    title = create_user_window_title("The Ethereal Network Analyzer");
+    title = create_user_window_title("The Wireshark Network Analyzer");
 
     /* Main window */
     top_level = window_new(GTK_WINDOW_TOPLEVEL, title);