few minor bugfixes
[ovirt-viewer.git] / internal.h
index 2fbf2c7..80e675e 100644 (file)
@@ -39,6 +39,21 @@ extern gboolean debug;
     }                                                                  \
   } while (0)
 
+/* Verbose messages are always compiled in, but have to
+ * be turned on using the --verbose command line switch.
+ */
+extern gboolean verbose;
+
+#define VERBOSE(fs,...)                                                        \
+  do {                                                                         \
+    if (verbose) {                                                     \
+      fprintf (stderr, "%s:%d: [thread %p] ", __FILE__, __LINE__,      \
+              g_thread_self ());                                       \
+      fprintf (stderr, (fs), ## __VA_ARGS__);                          \
+      fprintf (stderr, "\n");                                          \
+    }                                                                  \
+  } while (0)
+
 /* String equality tests, suggested by Jim Meyering. */
 #define STREQ(a,b) (strcmp((a),(b)) == 0)
 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
@@ -53,6 +68,12 @@ extern gboolean debug;
 extern const char *cainfo;
 extern gboolean check_cert;
 
+/* server we're connecting to */
+extern const char* hostname;
+
+/* vm currently in focus */
+extern struct vm* vm_in_focus;
+
 /* Communications between the main thread and the WUI thread.  For
  * an explanation of the threading model, please see the comment in
  * main().
@@ -61,6 +82,12 @@ extern gboolean check_cert;
 extern void start_wui_thread (void);
 extern void stop_wui_thread (void);
 
+extern void assert_is_main_thread (const char *, int);
+extern void assert_is_wui_thread (const char *, int);
+
+#define ASSERT_IS_MAIN_THREAD() assert_is_main_thread(__FILE__,__LINE__)
+#define ASSERT_IS_WUI_THREAD() assert_is_wui_thread(__FILE__,__LINE__)
+
 /* These are messages (instructions) which can be sent from the main
  * thread to the WUI thread.
  */
@@ -97,13 +124,20 @@ struct vm {
   char *description;
   int hostid;
   int id;
+  int vnc_port;
+  int forward_vnc_port;
+  char *uuid;                  /* Printable UUID. */
+  char *state;
+
+  /* Only the fields above this point are required.  The remainder may
+   * be NULL / -1 to indicate they were missing in the data we got
+   * back from the WUI.
+   */
+
   long mem_allocated;          /* Kbytes */
   long mem_used;               /* Kbytes */
   int vcpus_allocated;
   int vcpus_used;
-  char *state;
-  char *uuid;                  /* Printable UUID. */
-  int vnc_port;
   char *mac_addr;              /* Printable MAC addr. */
 };
 
@@ -131,6 +165,20 @@ extern gboolean wui_thread_has_valid_vmlist (void);
  */
 extern gboolean wui_thread_is_busy (void);
 
+
+/* Communications between the main thread and the tunnel thread.*/
+extern void start_tunnel (void);
+extern void stop_tunnel  (void);
+
+/* port which local tunnel is listening on */
+extern int tunnel_port;
+
+
+/* Returns true if the main vm list contains a
+ * running vm w/ the same name as specified one
+ */
+extern gboolean main_vmlist_has_running_vm(struct vm*);
+
 /* Callbacks from the WUI thread to the main thread.  The WUI thread
  * adds these to the Glib main loop using g_idle_add, which means they
  * actually get executed in the context of the main thread.
@@ -163,4 +211,7 @@ extern gboolean main_login_error (gpointer str);
 /* The WUI thread reports a general status error. */
 extern gboolean main_status_error (gpointer str);
 
+/* The WUI thread has updated the vm list. */
+extern gboolean main_vmlist_updated (gpointer);
+
 #endif /* OVIRT_VIEWER_INTERNAL_H */