Commit beb8289c authored by smorlat's avatar smorlat

-update translations

-automatic wakeup of running instance when spanwing a second linphone


git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@65 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 50b6b44e
......@@ -43,7 +43,7 @@ You can download:
- libxml2 from http://xmlsoft.org/sources/win32/
- libglade bin and dev package from http://gladewin32.sourceforge.net
or directly http://sourceforge.net/project/showfiles.php?group_id=98754&package_id=107065
Unzip gtk+ bundle, iconv and libxml2 into the c:\Dev-Cpp directory.
Unzip gtk+ bundle, iconv and libxml2 into the same directory as "linphone-deps"
Inside the gtk+ bundle, unzip libglade bin and dev zips.
Once you have all this, you are ready to build linphone.
......
......@@ -903,15 +903,40 @@ void linphone_registration_success(LinphoneCore *lc,eXosip_event_t *ev){
gstate_new_state(lc, GSTATE_REG_OK, NULL);
}
static bool_t comes_from_local_if(osip_message_t *msg){
osip_via_t *via=NULL;
osip_message_get_via(msg,0,&via);
if (via){
const char *host;
host=osip_via_get_host(via);
if (strcmp(host,"127.0.0.1")==0 || strcmp(host,"::1")==0){
osip_generic_param_t *param=NULL;
osip_via_param_get_byname(via,"received",&param);
if (param==NULL) return TRUE;
if (param->gvalue &&
(strcmp(param->gvalue,"127.0.0.1")==0 || strcmp(param->gvalue,"::1")==0)){
return TRUE;
}
}
}
return FALSE;
}
static void linphone_other_request(LinphoneCore *lc, eXosip_event_t *ev){
ms_message("in linphone_other_request");
if (ev->request==NULL) return;
if (strcmp(ev->request->sip_method,"MESSAGE")==0){
linphone_core_text_received(lc,ev);
eXosip_message_send_answer(ev->tid,200,NULL);
}else if (strcmp(ev->request->sip_method,"OPTIONS")==0){
eXosip_options_send_answer(ev->tid,200,NULL);
}
else {
}else if (strcmp(ev->request->sip_method,"WAKEUP")==0
&& comes_from_local_if(ev->request)) {
eXosip_message_send_answer(ev->tid,200,NULL);
ms_message("Receiving WAKEUP request !");
if (lc->vtable.show)
lc->vtable.show(lc);
}else {
ms_message("Unsupported request received.");
/*answer with a 501 Not implemented*/
eXosip_message_send_answer(ev->tid,501,NULL);
......@@ -1018,6 +1043,7 @@ void linphone_core_process_event(LinphoneCore *lc,eXosip_event_t *ev)
}
break;
default:
ms_message("Unhandled exosip event !");
break;
}
eXosip_event_free(ev);
......
......@@ -699,6 +699,11 @@ void *linphone_core_get_user_data(LinphoneCore *lc);
the config file with your own sections */
struct _LpConfig *linphone_core_get_config(LinphoneCore *lc);
/* attempts to wake up another linphone engine already running.
The "show" callback is called for the other linphone, causing gui to show up.
The method returns 0 if an already running linphone was found*/
int linphone_core_wake_up_possible_already_running_instance(const char *config_file);
void linphone_core_uninit(LinphoneCore *lc);
void linphone_core_destroy(LinphoneCore *lc);
......
......@@ -509,7 +509,7 @@ static int parse_stun_server_addr(const char *server, struct sockaddr_storage *s
char *p;
host[NI_MAXHOST-1]='\0';
strncpy(host,server,sizeof(host)-1);
p=strchr(server,':');
p=strchr(host,':');
if (p) {
*p='\0';
port=p+1;
......@@ -617,4 +617,62 @@ void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){
}
}
static int extract_sip_port(const char *config){
char line[512];
char port[12];
int ret=-1;
FILE *f=fopen(config,"r");
if (f){
while(fgets(line,sizeof(line),f)!=NULL){
if (fmtp_get_value(line,"sip_port",port,sizeof(port))){
ret=atoi(port);
}
}
fclose(f);
}
return ret;
}
int linphone_core_wake_up_possible_already_running_instance(const char *config_file){
int port=extract_sip_port(config_file);
const char *wakeup="WAKEUP sip:127.0.0.1 SIP/2.0\r\n"
"Via: SIP/2.0/UDP 127.0.0.1:57655;rport;branch=z9hG4bK%u\r\n"
"From: <sip:another_linphone@127.0.0.1>;tag=%u\r\n"
"To: <sip:you@127.0.0.1>\r\n"
"CSeq: 1 WAKEUP\r\n"
"Call-ID: %u@onsantape\r\n"
"Content-length: 0\r\n\r\n";
/*make sure ortp is initialized (it initializes win32 socket api)*/
ortp_init();
if (port>0){
struct sockaddr_storage ss;
socklen_t sslen;
char tmp[100];
snprintf(tmp,sizeof(tmp),"127.0.0.1:%i",port);
if (parse_stun_server_addr(tmp,&ss,&sslen)==0){
int sock=create_socket(57655);
if (sock>=0){
char req[512];
snprintf(req,sizeof(req),wakeup,random(),random(),random());
if (sendto(sock,req,strlen(req),0,(struct sockaddr*)&ss,sslen)>0){
/*wait a bit for a response*/
int i;
for(i=0;i<10;++i){
if (recv(sock,tmp,sizeof(tmp),0)>0){
ms_message("Another linphone has been woken-up !");
close(sock);
return 0;
}
#ifdef WIN32
Sleep(10);
#else
usleep(10000);
#endif
}
}
}else ms_error("Fail to create socket on port 57655");
close(sock);
}
}
return -1;
}
......@@ -89,26 +89,31 @@ static GOptionEntry linphone_options[2]={
#define BUILD_TREE_XML_DIR "gtk-glade"
#define CONFIG_FILE ".linphonerc"
static void linphone_gtk_init_liblinphone(){
static char _config_file[1024];
const char *linphone_gtk_get_config_file(){
const char *home;
char file[1024];
/*try accessing a local file first if exists*/
if (access(CONFIG_FILE,F_OK)==0){
snprintf(file,sizeof(file),"%s",CONFIG_FILE);
snprintf(_config_file,sizeof(_config_file),"%s",CONFIG_FILE);
}else{
#ifdef WIN32
const char *appdata=getenv("APPDATA");
if (appdata){
snprintf(file,sizeof(file),"%s\\%s",appdata,"Linphone\\");
CreateDirectory(file,NULL);
snprintf(file,sizeof(file),"%s\\%s",appdata,"Linphone\\linphonerc");
snprintf(_config_file,sizeof(_config_file),"%s\\%s",appdata,"Linphone\\");
CreateDirectory(_config_file,NULL);
snprintf(_config_file,sizeof(_config_file),"%s\\%s",appdata,"Linphone\\linphonerc");
}
#else
home=getenv("HOME");
if (home==NULL) home="";
snprintf(file,sizeof(file),"%s/%s",home,CONFIG_FILE);
snprintf(_config_file,sizeof(_config_file),"%s/%s",home,CONFIG_FILE);
#endif
}
return _config_file;
}
static void linphone_gtk_init_liblinphone(const char *file){
the_core=linphone_core_new(&vtable,file,NULL);
}
......@@ -685,6 +690,7 @@ void linphone_gtk_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
int main(int argc, char *argv[]){
void *p;
const char *config_file;
g_thread_init(NULL);
gdk_threads_init();
#ifdef ENABLE_NLS
......@@ -695,6 +701,12 @@ int main(int argc, char *argv[]){
#else
g_message("NLS disabled.\n");
#endif
config_file=linphone_gtk_get_config_file();
if (linphone_core_wake_up_possible_already_running_instance(config_file)==0){
g_warning("Another running instance of linphone has been detected. It has been woken-up.");
g_warning("This instance is going to exit now.");
return 0;
}
gdk_threads_enter();
if (!gtk_init_with_args(&argc,&argv,_("A free SIP video-phone"),
linphone_options,NULL,NULL)){
......@@ -710,7 +722,7 @@ int main(int argc, char *argv[]){
linphone_gtk_create_log_window();
linphone_core_enable_logs_with_cb(linphone_gtk_log_handler);
linphone_gtk_init_liblinphone();
linphone_gtk_init_liblinphone(config_file);
gtk_timeout_add(20,(GtkFunction)linphone_gtk_iterate,(gpointer)linphone_gtk_get_core());
gtk_timeout_add(20,(GtkFunction)linphone_gtk_check_logs,(gpointer)NULL);
linphone_gtk_init_main_window();
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Thu Jul 31 11:31:30 2008 -->
<!--Generated with glade3 3.4.5 on Thu Oct 2 16:20:18 2008 -->
<glade-interface>
<widget class="GtkWindow" id="main">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
......@@ -18,7 +18,7 @@
<widget class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">É_dition</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu2">
......@@ -27,15 +27,10 @@
<child>
<widget class="GtkImageMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">_Properties</property>
<property name="label" translatable="yes">gtk-preferences</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="linphone_gtk_show_parameters"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image3">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
</widget>
</child>
</widget>
</child>
<child>
......@@ -69,7 +64,7 @@
<widget class="GtkMenuItem" id="modes">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Modes</property>
<property name="label" translatable="yes">_Modes</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu1">
......@@ -103,11 +98,12 @@
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem4">
<widget class="GtkImageMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Aid_e</property>
<property name="label" translatable="yes">gtk-help</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<child>
<widget class="GtkMenu" id="menu3">
<property name="visible">True</property>
......@@ -129,15 +125,10 @@
<child>
<widget class="GtkImageMenuItem" id="menuitem6">
<property name="visible">True</property>
<property name="label" translatable="yes">_About</property>
<property name="label" translatable="yes">gtk-about</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="linphone_gtk_show_about"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image2">
<property name="visible">True</property>
<property name="stock">gtk-about</property>
</widget>
</child>
</widget>
</child>
</widget>
......
......@@ -105,6 +105,8 @@ mblk_t * yuv_buf_alloc(MSPicture *buf, int w, int h);
void yuv_buf_copy(uint8_t *src_planes[], const int src_strides[],
uint8_t *dst_planes[], const int dst_strides[3], MSVideoSize roi);
void yuv_buf_mirror(YuvBuf *buf);
void rgb24_revert(uint8_t *buf, int w, int h, int linesize);
#ifdef __cplusplus
}
#endif
......
......@@ -153,3 +153,21 @@ MSPixFmt ms_fourcc_to_pix_fmt(uint32_t fourcc){
return ret;
}
void rgb24_revert(uint8_t *buf, int w, int h, int linesize){
uint8_t *p,*pe;
int i,j;
uint8_t *end=buf+(h*linesize*3);
uint8_t exch;
p=buf;
pe=end-1;
for(i=0;i<h/2;++i){
for(j=0;i<w;++j){
exch=p[i];
p[i]=pe[-i];
pe[-i]=exch;
}
p+=linesize;
pe-=linesize;
}
}
......@@ -6,8 +6,17 @@ gtk-glade/chat.c
gtk-glade/main.c
gtk-glade/friendlist.c
gtk-glade/propertybox.c
gtk-glade/main.glade
gtk-glade/about.glade
gtk-glade/contact.glade
gtk-glade/log.glade
gtk-glade/password.glade
gtk-glade/call_logs.glade
gtk-glade/main.glade
gtk-glade/sip_account.glade
gtk-glade/chatroom.glade
gtk-glade/incoming_call.glade
gtk-glade/parameters.glade
coreapi/linphonecore.c
coreapi/misc.c
coreapi/exevents.c
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment