On Sun, Jul 11, 2004 at 03:14:41PM +0200, Miloslav Trmac wrote:
> The attached patch ...
Of course, forgot the patch.
        Mirek
diff -urN cvs/B/multisync/plugins/irmc_sync/irmc_sync.glade2 
multisync/plugins/irmc_sync/irmc_sync.glade2
--- cvs/B/multisync/plugins/irmc_sync/irmc_sync.glade2  2004-04-06 11:47:22.000000000 
+0200
+++ multisync/plugins/irmc_sync/irmc_sync.glade2        2004-07-11 14:35:09.957249992 
+0200
@@ -712,6 +712,14 @@
                                          <signal name="activate" 
handler="on_siemenscable_activate" last_modification_time="Mon, 01 Dec 2003 19:58:20 
GMT"/>
                                        </widget>
                                      </child>
+
+                                     <child>
+                                       <widget class="GtkMenuItem" id="philipscable">
+                                         <property name="visible">True</property>
+                                         <property name="label" 
translatable="yes">Philips</property>
+                                         <property 
name="use_underline">True</property>
+                                         <signal name="activate" 
handler="on_philipscable_activate" last_modification_time="Mon, 01 Dec 2003 19:58:20 
GMT"/>
+                                       </widget>
                                    </widget>
                                  </child>
                                </widget>
diff -urN cvs/B/multisync/plugins/irmc_sync/src/callbacks.c 
multisync/plugins/irmc_sync/src/callbacks.c
--- cvs/B/multisync/plugins/irmc_sync/src/callbacks.c   2003-12-01 21:22:30.000000000 
+0100
+++ multisync/plugins/irmc_sync/src/callbacks.c 2004-07-11 14:35:09.957249992 +0200
@@ -143,3 +143,11 @@
   irmcconn->cabletype = IRMC_CABLE_SIEMENS;
 }
 
+
+void
+on_philipscable_activate               (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  irmcconn->cabletype = IRMC_CABLE_PHILIPS;
+}
+
diff -urN cvs/B/multisync/plugins/irmc_sync/src/callbacks.h 
multisync/plugins/irmc_sync/src/callbacks.h
--- cvs/B/multisync/plugins/irmc_sync/src/callbacks.h   2003-12-01 21:22:30.000000000 
+0100
+++ multisync/plugins/irmc_sync/src/callbacks.h 2004-07-11 14:35:09.958249840 +0200
@@ -91,3 +91,7 @@
 void
 on_siemenscable_activate               (GtkMenuItem     *menuitem,
                                         gpointer         user_data);
+
+void
+on_philipscable_activate               (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
diff -urN cvs/B/multisync/plugins/irmc_sync/src/cobex_bfb.c 
multisync/plugins/irmc_sync/src/cobex_bfb.c
--- cvs/B/multisync/plugins/irmc_sync/src/cobex_bfb.c   2004-02-09 19:53:31.000000000 
+0100
+++ multisync/plugins/irmc_sync/src/cobex_bfb.c 2004-07-11 14:35:09.977246952 +0200
@@ -78,7 +78,7 @@
   return_val_if_fail (data != NULL, -1);
   c = (obexdata_t *) data;
 
-  if (c->cabletype == IRMC_CABLE_ERICSSON)
+  if (c->cabletype != IRMC_CABLE_SIEMENS)
     obex_cable_disconnect(self, data);
     
   if (c->fd >= 0) {
@@ -110,7 +110,7 @@
 
   DEBUG(3, "%s() Data %d bytes\n", __func__, length);
 
-  if (c->cabletype == IRMC_CABLE_ERICSSON)
+  if (c->cabletype != IRMC_CABLE_SIEMENS)
     return(obex_cable_write(self, data, buffer, length));
 
   if (c->cobex.seq == 0){
@@ -138,7 +138,7 @@
   return_val_if_fail (data != NULL, -1);
   c = (obexdata_t *) data;
   
-  if (c->cabletype == IRMC_CABLE_ERICSSON)
+  if (c->cabletype != IRMC_CABLE_SIEMENS)
     return(obex_cable_handleinput(self, data, timeout));
 
   if (c->state < 0)
@@ -167,7 +167,7 @@
     actual = read(c->fd, &(c->cobex.recv[c->cobex.recv_len]), sizeof(c->cobex.recv) - 
c->cobex.recv_len);
     DEBUG(2, "%s() Read %d bytes (%d bytes already buffered)\n", __func__, actual, 
c->cobex.recv_len);
          
-    if (c->cabletype == IRMC_CABLE_ERICSSON) {
+    if (c->cabletype != IRMC_CABLE_SIEMENS) {
       if (actual > 0) {
        OBEX_CustomDataFeed(self, c->cobex.recv, actual);
        return 1;
diff -urN cvs/B/multisync/plugins/irmc_sync/src/gui.c 
multisync/plugins/irmc_sync/src/gui.c
--- cvs/B/multisync/plugins/irmc_sync/src/gui.c 2004-04-06 11:47:22.000000000 +0200
+++ multisync/plugins/irmc_sync/src/gui.c       2004-07-11 14:35:09.979246648 +0200
@@ -304,6 +304,8 @@
       int cablemenu = 0;
       if (irmcconn->cabletype == IRMC_CABLE_SIEMENS)
        cablemenu = 1;
+      else if (irmcconn->cabletype == IRMC_CABLE_PHILIPS)
+       cablemenu = 2;
       gtk_option_menu_set_history (GTK_OPTION_MENU(lookup_widget(irmcwindow, 
"cablemanumenu")), cablemenu);
     }
 
diff -urN cvs/B/multisync/plugins/irmc_sync/src/interface.c 
multisync/plugins/irmc_sync/src/interface.c
--- cvs/B/multisync/plugins/irmc_sync/src/interface.c   2004-04-06 11:47:31.000000000 
+0200
+++ multisync/plugins/irmc_sync/src/interface.c 2004-07-11 14:35:09.996244064 +0200
@@ -68,6 +68,13 @@
     GNOME_APP_PIXMAP_NONE, NULL,
     0, (GdkModifierType) 0, NULL
   },
+  {
+    GNOME_APP_UI_ITEM, "Philips",
+    NULL,
+    (gpointer) on_philipscable_activate, NULL, NULL,
+    GNOME_APP_PIXMAP_NONE, NULL,
+    0, (GdkModifierType) 0, NULL
+  },
   GNOMEUIINFO_END
 };
 
@@ -728,6 +735,7 @@
   GLADE_HOOKUP_OBJECT (optionwin, menu1, "menu1");
   GLADE_HOOKUP_OBJECT (optionwin, menu1_uiinfo[0].widget, "sonyericssoncable");
   GLADE_HOOKUP_OBJECT (optionwin, menu1_uiinfo[1].widget, "siemenscable");
+  GLADE_HOOKUP_OBJECT (optionwin, menu1_uiinfo[1].widget, "philipscable");
   GLADE_HOOKUP_OBJECT (optionwin, label29, "label29");
   GLADE_HOOKUP_OBJECT (optionwin, testconnbutton, "testconnbutton");
   GLADE_HOOKUP_OBJECT (optionwin, alignment1, "alignment1");
diff -urN cvs/B/multisync/plugins/irmc_sync/src/irmc_obex.c 
multisync/plugins/irmc_sync/src/irmc_obex.c
--- cvs/B/multisync/plugins/irmc_sync/src/irmc_obex.c   2004-02-09 19:53:31.000000000 
+0100
+++ multisync/plugins/irmc_sync/src/irmc_obex.c 2004-07-11 14:35:10.018240720 +0200
@@ -124,6 +124,7 @@
 
   switch(obex_cmd)     {
   case OBEX_CMD_CONNECT:
+    connect_client_done(handle, object, obex_rsp);
     break;
   case OBEX_CMD_DISCONNECT:
     break;
@@ -167,6 +168,30 @@
   return(SYNC_MSG_REQFAILED);
 }
 
+void connect_client_done(obex_t *handle, obex_object_t *object, gint obex_rsp) {
+  obex_headerdata_t hv;
+  guint8 hi;
+  gint hlen;
+  obexdata_t *ud;
+  const char *body = NULL;
+  int body_len = 0;
+  
+  ud = OBEX_GetUserData(handle);
+
+  if(obex_rsp != OBEX_RSP_SUCCESS) {
+    ud->state = IRMC_OBEX_REQFAILED;
+    return;
+  }
+
+  ud->connection = 0xFFFFFFFF;
+  while(OBEX_ObjectGetNextHeader(handle, object, &hi, &hv, &hlen))     {
+    if(hi == OBEX_HDR_CONNECTION)      {
+      ud->connection = hv.bq4;
+      break;
+    }
+  }
+}
+
 void put_client_done(obex_t *handle, obex_object_t *object, gint obex_rsp) {
   obexdata_t *ud;
   obex_headerdata_t hv;
@@ -286,8 +311,11 @@
       /* Answer didn't come within the length of the buffer. Cancel! */
       if(total == sizeof(tmpbuf))
        return -1;
+      tmpbuf[total] = 0;
       
       if( (answer = index(tmpbuf, '\n')) )     {
+       while (*answer == '\n' || *answer == '\r')
+         answer++;
        // Remove first line (echo)
        if( (answer_end = index(answer+1, '\n')) )      {
          // Found end of answer
@@ -347,7 +375,8 @@
 
   if (userdata->cabletype == IRMC_CABLE_SIEMENS)
     return(cobex_connect(handle, ud));
-  if (userdata->cabletype != IRMC_CABLE_ERICSSON)
+  if (userdata->cabletype != IRMC_CABLE_ERICSSON
+      && userdata->cabletype != IRMC_CABLE_PHILIPS)
     goto err;
 
   /*if(obex_cable_at(userdata, "ATZ\r", rspbuf, sizeof(rspbuf), 1) < 0)        {
@@ -392,14 +421,26 @@
     dd(printf("Error doing ATZ (%s)\n", rspbuf));
     goto err;
   }
-  if(obex_cable_at(userdata, 
-                  "AT*EOBEX\r", rspbuf, sizeof(rspbuf), 1) < 0)        {
-    dd(printf("Comm-error sending AT*EOBEX\n"));
-    goto err;
-  }
-  if(strcasecmp("CONNECT", rspbuf) != 0)       {
-    dd(printf("Error doing AT*EOBEX (%s)\n", rspbuf));
-    goto err;
+  if(userdata->cabletype == IRMC_CABLE_ERICSSON) {
+    if(obex_cable_at(userdata,
+                    "AT*EOBEX\r", rspbuf, sizeof(rspbuf), 1) < 0) {
+      dd(printf("Comm-error sending AT*EOBEX\n"));
+      goto err;
+    }
+    if(strcasecmp("CONNECT", rspbuf) != 0)     {
+      dd(printf("Error doing AT*EOBEX (%s)\n", rspbuf));
+      goto err;
+    }
+  } else { /* IRMC_CABLE_PHILIPS */
+    if(obex_cable_at(userdata,
+                    "AT+CPROT=0\r", rspbuf, sizeof(rspbuf), 1) < 0) {
+      dd(printf("Comm-error sending AT+CPROT=0\n"));
+      goto err;
+    }
+    if(strcasecmp("CONNECT", rspbuf) != 0)     {
+      dd(printf("Error doing AT+CPROT=0 (%s)\n", rspbuf));
+      goto err;
+    }
   }
   fcntl(userdata->fd, F_SETFL, O_NONBLOCK);
   return(0);
@@ -629,10 +670,15 @@
 gint irmc_obex_disconnect(obex_t* handle) {
   obex_object_t *object; 
   obexdata_t *userdata;
+  obex_headerdata_t hd;
 
   userdata = (obexdata_t*) OBEX_GetUserData(handle);  
   if (userdata->connected) {
     if ((object = OBEX_ObjectNew(handle, OBEX_CMD_DISCONNECT))) {
+      if (userdata->connection != 0xFFFFFFFF) {
+       hd.bq4 = userdata->connection;
+       OBEX_ObjectAddHeader (handle, object, OBEX_HDR_CONNECTION, hd, 4, 0);
+      }
       if(OBEX_Request(handle, object) < 0) 
        return(SYNC_MSG_CONNECTIONERROR);
     }
@@ -692,6 +738,10 @@
 
   userdata = (obexdata_t*) OBEX_GetUserData(handle);  
   if ((object = OBEX_ObjectNew(handle, OBEX_CMD_PUT))) {
+    if (userdata->connection != 0xFFFFFFFF) {
+      hd.bq4 = userdata->connection;
+      OBEX_ObjectAddHeader (handle, object, OBEX_HDR_CONNECTION, hd, 4, 0);
+    }
     hd.bq4 = body_size; 
     OBEX_ObjectAddHeader(handle, object, OBEX_HDR_LENGTH, hd, 4, 0); 
     /* Add unicode name header*/ 
@@ -736,6 +786,10 @@
 
   userdata = (obexdata_t*) OBEX_GetUserData(handle);  
   if((object = OBEX_ObjectNew(handle, OBEX_CMD_GET))) {
+    if (userdata->connection != 0xFFFFFFFF) {
+      hd.bq4 = userdata->connection;
+      OBEX_ObjectAddHeader (handle, object, OBEX_HDR_CONNECTION, hd, 4, 0);
+    }
     /* Add unicode name header*/ 
     namesize = OBEX_CharToUnicode(unicodename, name, 1024);
     hd.bs = unicodename; 
diff -urN cvs/B/multisync/plugins/irmc_sync/src/irmc_obex.h 
multisync/plugins/irmc_sync/src/irmc_obex.h
--- cvs/B/multisync/plugins/irmc_sync/src/irmc_obex.h   2004-02-09 19:53:31.000000000 
+0100
+++ multisync/plugins/irmc_sync/src/irmc_obex.h 2004-07-11 14:35:10.032238592 +0200
@@ -55,6 +55,7 @@
 #if HAVE_IRDA
   __u32 ir_addr;   
 #endif
+  guint32 connection;
   int channel;
   int state;
   int error; // One of SYNC_MSG_*
@@ -83,6 +84,7 @@
                 gint obex_cmd, gint obex_rsp);
 void client_done(obex_t *handle, obex_object_t *object, 
                 gint obex_cmd, gint obex_rsp);
+void connect_client_done(obex_t *handle, obex_object_t *object, gint obex_rsp);
 void get_client_done(obex_t *handle, obex_object_t *object, gint obex_rsp);
 void put_client_done(obex_t *handle, obex_object_t *object, gint obex_rsp);
 
diff -urN cvs/B/multisync/plugins/irmc_sync/src/irmc_sync.h 
multisync/plugins/irmc_sync/src/irmc_sync.h
--- cvs/B/multisync/plugins/irmc_sync/src/irmc_sync.h   2004-04-06 11:47:31.000000000 
+0200
+++ multisync/plugins/irmc_sync/src/irmc_sync.h 2004-07-11 14:35:10.067233272 +0200
@@ -23,7 +23,8 @@
 typedef enum {
   IRMC_CABLE_UNKNOWN = 0,
   IRMC_CABLE_ERICSSON,
-  IRMC_CABLE_SIEMENS
+  IRMC_CABLE_SIEMENS,
+  IRMC_CABLE_PHILIPS
 } cable_type;
 
 #include "irmc_obex.h"

Reply via email to