[Freeswitch-branches] [commit] r11675 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk

FreeSWITCH SVN gmaruzz at freeswitch.org
Fri Feb 6 11:45:39 PST 2009


Author: gmaruzz
Date: Fri Feb  6 13:45:38 2009
New Revision: 11675

Log:
skypiax: cleaning skypiax_protocol.c

Modified:
   freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile
   freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
   freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c

Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile	Fri Feb  6 13:45:38 2009
@@ -21,7 +21,7 @@
 #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_160/include
 #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_12/include
 #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_14/include
-AST_INCLUDE_DIR=/home/user/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include
+AST_INCLUDE_DIR=/home/maruzz/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include
 
 #ASTERISK
 CFLAGS+=-DASTERISK

Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h	Fri Feb  6 13:45:38 2009
@@ -188,7 +188,6 @@
   char language[80];            /*!< \brief default Asterisk dialplan language for this interface */
   char exten[80];               /*!< \brief default Asterisk dialplan extension for this interface */
   int skypiax_sound_rate;       /*!< \brief rate of the sound device, in Hz, eg: 8000 */
-  switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
   char callid_name[50];
   char callid_number[50];
   double playback_boost;
@@ -205,9 +204,11 @@
 #ifdef WIN32
   switch_file_t *audiopipe[2];
   switch_file_t *audioskypepipe[2];
+  switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
 #else                           /* WIN32 */
   int audiopipe[2];
   int audioskypepipe[2];
+  int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
 #endif                          /* WIN32 */
   switch_thread_t *tcp_srv_thread;
   switch_thread_t *tcp_cli_thread;

Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c	Fri Feb  6 13:45:38 2009
@@ -3,7 +3,6 @@
 #ifdef ASTERISK
 #define skypiax_sleep usleep
 #define tech_pvt p
-#define SKYPIAX_DIR_CONFIG "directoriax.conf"
 extern int skypiax_debug;
 #define skypiax_file_write switch_file_write
 #define skypiax_file_read switch_file_read
@@ -19,8 +18,6 @@
 extern int option_debug;
 extern int running;
 
-/* GLOBALS */
-int skypiax_dir_entry_extension=1;
 /*************************************/
 #ifndef WIN32
 XErrorHandler old_handler = 0;
@@ -481,6 +478,9 @@
   }
 #endif /* WIN32 */
 
+/* the pipe is the audio fd for asterisk to poll on during a call */
+  tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0];
+
   if (option_debug > 10) {
     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
   }
@@ -1635,376 +1635,3 @@
   return 0;
 }
 
-#ifdef ASTERISK
-int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[])
-{
-  //int res;
-  struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
-  //char list_command[64];
-  char fn[256];
-  char date[256] = "";
-  time_t t;
-  char *configfile = SKYPIAX_DIR_CONFIG;
-  int add_to_skypiax_dir_conf = 1;
-  //int fromskype = 0;
-  //int fromcell = 0;
-
-#if 0
-  if(directoriax_entry_extension){
-    skypiax_dir_entry_extension=directoriax_entry_extension;
-  }else{
-    ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n");
-    return RESULT_SUCCESS;
-  }
-#endif
-
-  if (argc != 2)
-    return RESULT_SHOWUSAGE;
-  if (!p) {
-    ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n");
-    return RESULT_SUCCESS;
-  }
-
-  if (!strcasecmp(argv[1], "add"))
-    add_to_skypiax_dir_conf = 1;
-  else if (!strcasecmp(argv[1], "replace"))
-    add_to_skypiax_dir_conf = 0;
-  else {
-    ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n");
-    return RESULT_SHOWUSAGE;
-  }
-
-#if 0
-  if (!strcasecmp(argv[2], "fromskype"))
-    fromskype = 1;
-  else if (!strcasecmp(argv[2], "fromcell"))
-    fromcell = 1;
-  else {
-    ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n");
-    return RESULT_SHOWUSAGE;
-  }
-
-  if (fromcell) {
-    ast_cli(fd,
-            "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n");
-    //fclose(p->phonebook_writing_fp);
-    //skypiax_dir_create_extensions();
-    return RESULT_SUCCESS;
-  }
-
-  if (fromskype)
-    if (!p->skype) {
-      ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n");
-      //fclose(p->phonebook_writing_fp);
-      //skypiax_dir_create_extensions();
-      return RESULT_SUCCESS;
-    }
-
-  if (fromcell || fromskype)
-    if (argc != 3) {
-      ast_cli(fd,
-              "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n");
-      return RESULT_SHOWUSAGE;
-    }
-#endif
-
-  /*******************************************************************************************/
-
-  if (configfile[0] == '/') {
-    ast_copy_string(fn, configfile, sizeof(fn));
-  } else {
-    snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
-  }
-  if (option_debug)
-    NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
-  time(&t);
-  ast_copy_string(date, ctime(&t), sizeof(date));
-
-  if (add_to_skypiax_dir_conf)
-    p->phonebook_writing_fp = fopen(fn, "a+");
-  else
-    p->phonebook_writing_fp = fopen(fn, "w+");
-
-  if (p->phonebook_writing_fp) {
-    if (add_to_skypiax_dir_conf) {
-      if (option_debug)
-        NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
-      fprintf(p->phonebook_writing_fp, ";!\n");
-      fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date);
-      fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__);
-      fprintf(p->phonebook_writing_fp, ";!\n");
-    } else {
-      if (option_debug)
-        NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
-      fprintf(p->phonebook_writing_fp, ";!\n");
-      fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n");
-      fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn);
-      fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date);
-      fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__);
-      fprintf(p->phonebook_writing_fp, ";!\n");
-      fprintf(p->phonebook_writing_fp, "[general]\n\n");
-      fprintf(p->phonebook_writing_fp, "[default]\n");
-    }
-
-  /*******************************************************************************************/
-    //if (fromskype) {
-      if (p->skype) {
-        WARNINGA
-          ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n",
-           SKYPIAX_P_LOG);
-        if (p->skype_thread != AST_PTHREADT_NULL) {
-          char msg_to_skype[1024];
-
-          p->skype_friends[0] = '\0';
-          sprintf(msg_to_skype, "#333 SEARCH FRIENDS");
-          if (skypiax_skype_write(p, msg_to_skype) < 0) {
-            return -1;
-          }
-
-          int friends_count = 0;
-          while (p->skype_friends[0] == '\0') {
-            /* FIXME needs a timeout, can't wait forever! 
-             * eg. when skype is running but not connected! */
-            usleep(100);
-            friends_count++;
-            if (friends_count > 20000) {
-              return -1;        /* FIXME */
-            }
-          }
-
-        }
-
-        if (p->skype_thread != AST_PTHREADT_NULL) {
-          char msg_to_skype[1024];
-
-          if (p->skype_friends[0] != '\0') {
-            char *buf, *where;
-            char **stringp;
-            int skype_dir_file_written = 0;
-
-            buf = p->skype_friends;
-            stringp = &buf;
-            where = strsep(stringp, ", ");
-            while (where) {
-              if (where[0] != '\0') {
-                /*
-                 * So, we have the Skype username (the HANDLE, I think is called).
-                 * But we want to call the names we see in the Skype contact list
-                 * So, let's check the DISPLAYNAME (the end user modified contact name)
-                 * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME 
-                 * if the end user has not modify it)
-                 * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the 
-                 * Skipe username (the HANDLE)
-                 */
-
-                p->skype_displayname[0] = '\0';
-                sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where);
-                skypiax_skype_write(p, msg_to_skype);
-                int displayname_count = 0;
-                while (p->skype_displayname[0] == '\0') {
-                  /* FIXME needs a timeout, can't wait forever! 
-                   * eg. when skype is running but not connected! */
-                  usleep(100);
-                  displayname_count++;
-                  if (displayname_count > 20000)
-                    return -1;  /* FIXME */
-                }
-                if (p->skype_displayname[0] != '\0') {
-                  char *where2;
-                  char sanitized[300];
-
-                  sanitized[0] = '\0';
-
-                  where2 = strstr(p->skype_displayname, "DISPLAYNAME ");
-                  if (where2) {
-
-                    /* there can be some *smart* that makes a displayname 
-                     * that is different than first<space>last, */
-                    /* maybe initials, simbols, slashes, 
-                     * something smartish... let's check */
-
-                    if (where2[12] != '\0') {
-                      int i = 12;
-                      int x = 0;
-                      int spaces = 0;
-                      int last_char_was_space = 0;
-
-                      for (i = 12; i < strlen(where2) && x < 299; i++) {
-                        if (!isalnum(where2[i])) {
-                          if (!isblank(where2[i])) {
-                            /* bad char */
-                            continue;
-                          }
-                          /* is a space */
-                          if (last_char_was_space == 1) /* do not write 2 consecutive spaces */
-                            continue;
-                          last_char_was_space = 1;
-                          sanitized[x] = ' ';
-                          x++;
-                          continue;
-                        }
-                        /* is alphanum */
-                        last_char_was_space = 0;
-                        sanitized[x] = where2[i];
-                        x++;
-                        continue;
-                      }
-
-                      sanitized[x] = '\0';
-                      if (spaces == 0) {
-                      }
-                      DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
-                                   SKYPIAX_P_LOG, sanitized, where, &where2[12]);
-                    }
-
-                    if (where2[12] != '\0') {
-                      skypiax_dir_entry_extension++;
-                      if (where[0] == '+' || isdigit(where[0])) {   /* is a skypeout number */
-                        fprintf(p->phonebook_writing_fp,
-                                "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                where, sanitized, "no",
-                                p->skypiax_dir_entry_extension_prefix, "2",
-                                skypiax_dir_entry_extension, "yes", "not_specified");
-                      } else {  /* is a skype name */
-                        fprintf(p->phonebook_writing_fp,
-                                "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                where, sanitized, "no",
-                                p->skypiax_dir_entry_extension_prefix, "1",
-                                skypiax_dir_entry_extension, "yes", "not_specified");
-                      }
-                      skype_dir_file_written = 1;
-
-                    }
-                  }
-                }
-                p->skype_displayname[0] = '\0';
-
-                p->skype_fullname[0] = '\0';
-                sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where);
-                skypiax_skype_write(p, msg_to_skype);
-                int fullname_count = 0;
-                while (p->skype_fullname[0] == '\0') {
-                  /* FIXME needs a timeout, can't wait forever! 
-                   * eg. when skype is running but not connected! */
-                  usleep(100);
-                  fullname_count++;
-                  if (fullname_count > 20000)
-                    return -1;  /* FIXME */
-                }
-                if (p->skype_fullname[0] != '\0') {
-                  char *where2;
-                  char sanitized[300];
-
-                  where2 = strstr(p->skype_fullname, "FULLNAME ");
-                  if (where2) {
-
-                    /* there can be some *smart* that makes a fullname 
-                     * that is different than first<space>last, */
-                    /* maybe initials, simbols, slashes,
-                     *  something smartish... let's check */
-
-                    if (where2[9] != '\0') {
-                      int i = 9;
-                      int x = 0;
-                      int spaces = 0;
-                      int last_char_was_space = 0;
-
-                      for (i = 9; i < strlen(where2) && x < 299; i++) {
-                        if (!isalnum(where2[i])) {
-                          if (!isblank(where2[i])) {
-                            /* bad char */
-                            continue;
-                          }
-                          /* is a space */
-                          if (last_char_was_space == 1) /* do not write 2 consecutive spaces */
-                            continue;
-                          last_char_was_space = 1;
-                          sanitized[x] = ' ';
-                          x++;
-                          continue;
-                        }
-                        /* alphanum */
-                        last_char_was_space = 0;
-                        sanitized[x] = where2[i];
-                        x++;
-                        continue;
-                      }
-
-                      sanitized[x] = '\0';
-                      if (spaces == 0) {
-                      }
-                      DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
-                                   SKYPIAX_P_LOG, sanitized, where, &where2[9]);
-                    }
-
-                    if (skype_dir_file_written == 0) {
-                      skypiax_dir_entry_extension++;
-                      if (where2[9] != '\0') {
-                        if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, sanitized, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "2",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
-                        } else {    /* is a skype name */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, sanitized, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "1",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
-
-                        }
-
-                      } else {
-                        if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, where, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "2",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
-                        } else {    /* is a skype name */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, where, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "1",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
-
-                        }
-                      }
-                    }
-
-                    skype_dir_file_written = 0;
-
-                  }
-
-                }
-                p->skype_fullname[0] = '\0';
-
-              }
-              where = strsep(stringp, ", ");
-            }
-
-            p->skype_friends[0] = '\0';
-          }
-        }
-      } else {
-
-        ast_cli(fd,
-                "Skype not configured on the 'current' console, not importing from Skype client!\n");
-      }
-    //}
-  /*******************************************************************************************/
-  /*******************************************************************************************/
-  } else {
-    ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn);
-    ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG,
-           fn);
-    return RESULT_FAILURE;
-  }
-
-  fclose(p->phonebook_writing_fp);
-  //skypiax_dir_create_extensions();
-
-  return RESULT_SUCCESS;
-}
-#endif /* ASTERISK */



More information about the Freeswitch-branches mailing list