ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/src console_session.c,1.1.1.1,1.2 main.c,1.2


From: Colin Leroy <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/src console_session.c,1.1.1.1,1.2 main.c,1.2,1.3 status.c,1.10,1.11 status.h,1.1.1.1,1.2
Date: Thu, 02 Jan 2003 06:16:46 -0500

Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv18864/src

Modified Files:
        console_session.c main.c status.c status.h 
Log Message:
bring yattm back to front when duplicate launch


Index: console_session.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/console_session.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- console_session.c   23 Dec 2002 22:05:31 -0000      1.1.1.1
+++ console_session.c   2 Jan 2003 11:16:44 -0000       1.2
@@ -4,7 +4,7 @@
 #include <stdlib.h>
 #include "chat_window.h"
 #include "util.h"
-
+#include "status.h"
 
 static void console_session_close(int * session)
 {
@@ -34,39 +34,44 @@
                console_session_close((int*)data);
                return;
        }
-       if(read(source, &len, sizeof(short))<=0)
-       {
-               console_session_close((int*)data);
-               return;
-       }
-       message = alloca(len);
-       if(read(source, message, len)<=0)
-       {
-               console_session_close((int*)data);
-               return;
-       }
-
-       remote_contact = find_contact_by_nick(contact_name);
-       if(!remote_contact)
-       {
-               ret = -1;
-               write(source, &ret, sizeof(int));
-               return;
+       if(strcmp(contact_name, "focus-yattm")) {
+               if(read(source, &len, sizeof(short))<=0)
+               {
+                       console_session_close((int*)data);
+                       return;
+               }
+               message = alloca(len);
+               if(read(source, message, len)<=0)
+               {
+                       console_session_close((int*)data);
+                       return;
+               }
+
+               remote_contact = find_contact_by_nick(contact_name);
+               if(!remote_contact)
+               {
+                       ret = -1;
+                       write(source, &ret, sizeof(int));
+                       return;
+               }
+               eb_chat_window_display_contact(remote_contact);
+               remote_contact->chatwindow->perfered= 
+                               
find_suitable_remote_account(remote_contact->chatwindow->perfered, 
+                                                                               
        remote_contact->chatwindow->contact);
+               if(!remote_contact->chatwindow->perfered)
+               {
+                       ret = -2;
+                       write(source, &ret, sizeof(int));
+                       return;
+               }
+
+               
gtk_editable_insert_text(GTK_EDITABLE(remote_contact->chatwindow->entry),
+                                                                message, 
strlen(message), &pos);
+               send_message(NULL, remote_contact->chatwindow);
+       } else {
+               focus_statuswindow();
        }
-       eb_chat_window_display_contact(remote_contact);
-       remote_contact->chatwindow->perfered= 
-                       
find_suitable_remote_account(remote_contact->chatwindow->perfered, 
-                                                                               
remote_contact->chatwindow->contact);
-       if(!remote_contact->chatwindow->perfered)
-       {
-               ret = -2;
-               write(source, &ret, sizeof(int));
-               return;
-       }
-
-       
gtk_editable_insert_text(GTK_EDITABLE(remote_contact->chatwindow->entry),
-                                                        message, 
strlen(message), &pos);
-       send_message(NULL, remote_contact->chatwindow);
+       
        ret = 0;
        write(source, &ret, sizeof(int));
 
@@ -81,6 +86,6 @@
        
        sock = accept(source, (struct sockaddr *)&remote, &len);
        *listener = gdk_input_add(sock, GDK_INPUT_READ,
-                                                               
console_session_get_command, 
-                                                               
(gpointer)listener);
+                                       console_session_get_command, 
+                                       (gpointer)listener);
 }

Index: main.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- main.c      1 Jan 2003 17:32:43 -0000       1.2
+++ main.c      2 Jan 2003 11:16:44 -0000       1.3
@@ -341,11 +341,37 @@
        /* Mizhi 04-04-2001 */
        g_snprintf(buff, 1024, "%s.lock", config_dir);
        if ((pid = create_lock_file(buff)) > 0) {
-         g_snprintf(buff, 1024, _("Yattm already running, pid=%d\n"), pid);
-         wid = do_error_dialog(buff, _("Already logged on"));
-         /* UGLY UGLY HACK... */
-         while (GTK_CHECK_TYPE(wid, GTK_TYPE_WINDOW) && 
GTK_WIDGET_VISIBLE(wid)){while (g_main_iteration(FALSE));}
-         exit(1);
+#ifndef __MINGW32__
+               struct sockaddr_un remote;
+#else
+               struct sockaddr_in remote;
+#endif
+               short length;
+               int ret;
+#ifndef __MINGW32__
+               sock = socket(AF_UNIX, SOCK_STREAM, 0);
+               strcpy(remote.sun_path, config_dir);
+               strcat(remote.sun_path, "eb_socket");
+               remote.sun_family = AF_UNIX;
+               len = strlen(remote.sun_path) + sizeof(remote.sun_family) +1;
+#else
+               sock = socket(AF_INET, SOCK_STREAM, 0);
+#endif
+               if(connect(sock, (struct sockaddr*)&remote, len) == -1 )
+               {
+                       perror("connect");
+                       g_snprintf(buff, 1024, _("Yattm already running, 
pid=%d\n"), pid);
+                       wid = do_error_dialog(buff, _("Already logged on"));
+                       /* UGLY UGLY HACK... */ 
+                       while (GTK_CHECK_TYPE(wid, GTK_TYPE_WINDOW) && 
GTK_WIDGET_VISIBLE(wid)){while (g_main_iteration(FALSE));}
+                       exit(1);
+               }
+               length = strlen("focus-yattm")+1;
+               write(sock, &length, sizeof(short));
+               write(sock, "focus-yattm", length);
+               read(sock, &ret, sizeof(int));
+               close(sock);
+               exit(ret);
        }
 
        gtk_set_locale ();
@@ -354,8 +380,6 @@
        mkdir(buff, 0700);
        g_snprintf(buff, 1024, "%slogs",config_dir);
        mkdir(buff, 0700);
-/*     g_snprintf(buff, 1024, "%sfiles",config_dir);
-       mkdir(buff, 0700);*/
 
        if(!disable_console_server) {
 #ifndef __MINGW32__

Index: status.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/status.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- status.c    2 Jan 2003 06:48:19 -0000       1.10
+++ status.c    2 Jan 2003 11:16:44 -0000       1.11
@@ -84,6 +84,11 @@
 
 static time_t last_sound_played = 0;
 
+
+void focus_statuswindow (void) 
+{
+       gdk_window_raise(statuswindow->window);
+}
 static void delete_event( GtkWidget *widget,
                                   GdkEvent *event,
                                   gpointer data )

Index: status.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/status.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- status.h    23 Dec 2002 22:05:40 -0000      1.1.1.1
+++ status.h    2 Jan 2003 11:16:44 -0000       1.2
@@ -67,7 +67,7 @@
 void update_contact_list ();
 void update_user(eb_account * ea );
 void update_contact_window_length ();
-
+void focus_statuswindow (void);
 #ifdef __cplusplus
 } /* extern "C" */
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]