mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 05:38:14 +00:00
add update notification
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@217 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
parent
0cc94ad35b
commit
0899a2bdc9
5 changed files with 140 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[Project]
|
||||
FileName=linphone.dev
|
||||
Name=linphone
|
||||
UnitCount=8
|
||||
UnitCount=9
|
||||
PchHead=-1
|
||||
PchSource=-1
|
||||
Ver=3
|
||||
|
|
@ -120,7 +120,7 @@ ResourceIncludes=
|
|||
MakeIncludes=
|
||||
Compiler=-ggdb -O2_@@_-DENABLE_NLS_@@__@@_
|
||||
CppCompiler=
|
||||
Linker=-mwindows_@@_-Wl,--export-all-symbols_@@_-Wl,--add-stdcall-alias_@@_-llinphone_@@_-lmediastreamer2_@@_-lortp_@@_-lglade-2.0_@@_-lgtk-win32-2.0_@@_-lglib-2.0_@@_-lintl_@@_-lgdk_pixbuf-2.0_@@_-latk-1.0_@@_-lgobject-2.0_@@_-lgthread-2.0_@@_-lgdk-win32-2.0_@@_-losip2_@@_-losipparser2_@@_-leXosip2_@@_-lws2_32_@@_
|
||||
Linker=-mwindows_@@_-Wl,--export-all-symbols_@@_-Wl,--add-stdcall-alias_@@_-llinphone_@@_-lmediastreamer2_@@_-lortp_@@_-lglade-2.0_@@_-lgtk-win32-2.0_@@_-lglib-2.0_@@_-lintl_@@_-lgdk_pixbuf-2.0_@@_-latk-1.0_@@_-lgobject-2.0_@@_-lgthread-2.0_@@_-lgdk-win32-2.0_@@_-losip2_@@_-losipparser2_@@_-leXosip2_@@_-lws2_32_@@_-lwininet_@@_
|
||||
PreprocDefines=
|
||||
CompilerSettings=0000000000000000000000
|
||||
Icon=linphone.ico
|
||||
|
|
@ -164,3 +164,13 @@ SupportXPThemes=0
|
|||
CompilerSet=1
|
||||
compilerType=1
|
||||
|
||||
[Unit9]
|
||||
FileName=update.c
|
||||
CompileCpp=0
|
||||
Folder=
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd= $(CC) -c update.c -o Objects/update.o $(CFLAGS)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,4 +59,5 @@ void linphone_gtk_destroy_log_window(void);
|
|||
gboolean linphone_gtk_check_logs();
|
||||
const gchar *linphone_gtk_get_ui_config(const char *key, const char *def);
|
||||
int linphone_gtk_get_ui_config_int(const char *key, int def);
|
||||
|
||||
void linphone_gtk_open_browser(const char *url);
|
||||
void linphone_gtk_check_for_new_version(void);
|
||||
|
|
|
|||
|
|
@ -611,17 +611,21 @@ static void icon_popup_menu(GtkStatusIcon *status_icon, guint button, guint acti
|
|||
gtk_menu_popup(GTK_MENU(menu),NULL,NULL,gtk_status_icon_position_menu,status_icon,button,activate_time);
|
||||
}
|
||||
|
||||
void linphone_gtk_link_to_website(GtkWidget *item){
|
||||
const gchar *home=(const gchar*)g_object_get_data(G_OBJECT(item),"home");
|
||||
void linphone_gtk_open_browser(const char *url){
|
||||
#ifdef WIN32
|
||||
ShellExecute(0,"open",home,NULL,NULL,1);
|
||||
ShellExecute(0,"open",url,NULL,NULL,1);
|
||||
#else
|
||||
char cl[255];
|
||||
snprintf(cl,sizeof(cl),"/usr/bin/x-www-browser %s",home);
|
||||
snprintf(cl,sizeof(cl),"/usr/bin/x-www-browser %s",url);
|
||||
g_spawn_command_line_async(cl,NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void linphone_gtk_link_to_website(GtkWidget *item){
|
||||
const gchar *home=(const gchar*)g_object_get_data(G_OBJECT(item),"home");
|
||||
linphone_gtk_open_browser(home);
|
||||
}
|
||||
|
||||
static GtkWidget *create_icon_menu(){
|
||||
GtkWidget *menu=gtk_menu_new();
|
||||
GtkWidget *menu_item;
|
||||
|
|
@ -861,6 +865,7 @@ int main(int argc, char *argv[]){
|
|||
linphone_gtk_init_main_window();
|
||||
linphone_gtk_init_status_icon();
|
||||
linphone_gtk_show_main_window();
|
||||
linphone_gtk_check_for_new_version();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
linphone_gtk_destroy_log_window();
|
||||
|
|
|
|||
115
linphone/gtk-glade/update.c
Executable file
115
linphone/gtk-glade/update.c
Executable file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
linphone, gtk-glade interface.
|
||||
Copyright (C) 2008 Simon MORLAT (simon.morlat@linphone.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "linphone.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <wininet.h>
|
||||
|
||||
static int linphone_gtk_get_new_version(const char *version_url, char *version, size_t size){
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwDownloaded = 0;
|
||||
LPSTR pszOutBuffer;
|
||||
BOOL bResults = FALSE;
|
||||
HINTERNET hSession = NULL,
|
||||
hConnect = NULL;
|
||||
int ret=-1;
|
||||
|
||||
hSession=InternetOpen("Linphone",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
|
||||
|
||||
if (hSession==NULL) return -1;
|
||||
|
||||
hConnect=InternetOpenUrl(hSession,version_url,NULL,0,0,0);
|
||||
|
||||
if (hConnect==NULL) {
|
||||
InternetCloseHandle(hSession);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (InternetReadFile(hConnect,version,size,&dwDownloaded)){
|
||||
version[dwDownloaded]=0;
|
||||
ms_message("Got response: %s", version);
|
||||
ret=0;
|
||||
}
|
||||
|
||||
|
||||
// Close any open handles.
|
||||
if (hConnect) InternetCloseHandle(hConnect);
|
||||
if (hSession) InternetCloseHandle(hSession);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int linphone_gtk_get_new_version(char *version, size_t size){
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void new_version_response(GtkWidget *dialog, int response_id, gpointer download_site){
|
||||
if (response_id==GTK_RESPONSE_YES){
|
||||
linphone_gtk_open_browser((const char*)download_site);
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
||||
static void popup_new_version(const char *download_site){
|
||||
GtkWidget *dialog;
|
||||
/* draw a question box. link to dialog_click callback */
|
||||
dialog = gtk_message_dialog_new (
|
||||
NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_YES_NO,
|
||||
_("A more recent version is availalble from %s.\nWould you like to open a browser to download it ?"),
|
||||
download_site);
|
||||
g_signal_connect(G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (new_version_response),
|
||||
(gpointer)download_site);
|
||||
/* actually show the box */
|
||||
gtk_widget_show(dialog);
|
||||
}
|
||||
|
||||
static int version_compare(const char *v1, const char *v2){
|
||||
return strcmp(v1,v2);
|
||||
}
|
||||
|
||||
static void *check_for_new_version(void *d){
|
||||
const char *version_url=(const char *)d;
|
||||
char version[256];
|
||||
if (linphone_gtk_get_new_version(version_url,version,sizeof(version))==0){
|
||||
if (version_compare(version,LINPHONE_VERSION)>0){
|
||||
const char *download_site=linphone_gtk_get_ui_config("download_site",NULL);
|
||||
if (download_site) popup_new_version(download_site);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_check_for_new_version(void){
|
||||
ortp_thread_t thread;
|
||||
static gboolean done=FALSE;
|
||||
const char *version_url;
|
||||
if (done) return;
|
||||
done=TRUE;
|
||||
version_url=linphone_gtk_get_ui_config("update_url",NULL);
|
||||
if (version_url==NULL) return ;
|
||||
ortp_thread_create(&thread,NULL,check_for_new_version,(void*)version_url);
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ static bool_t win_display_init(MSDisplay *obj, MSPicture *fbuf){
|
|||
}else SetWindowLongPtr(wd->window,GWLP_USERDATA,(LONG_PTR)obj);
|
||||
}else{
|
||||
wd->window=create_window(wd->fb.w,wd->fb.h);
|
||||
obj->window_id=wd->window;
|
||||
obj->window_id=(long)wd->window;
|
||||
if (wd->window!=NULL) SetWindowLongPtr(wd->window,GWLP_USERDATA,(LONG_PTR)obj);
|
||||
else return FALSE;
|
||||
}
|
||||
|
|
@ -461,7 +461,7 @@ static void win_display_uninit(MSDisplay *obj){
|
|||
WinDisplay *wd=(WinDisplay*)obj->data;
|
||||
if (wd==NULL)
|
||||
return;
|
||||
if (wd->window && !obj->window_id) DestroyWindow(wd->window);
|
||||
if (wd->window && !obj->use_external_window) DestroyWindow(wd->window);
|
||||
if (wd->ddh) DrawDibClose(wd->ddh);
|
||||
if (wd->fb.planes[0]) ms_free(wd->fb.planes[0]);
|
||||
if (wd->rgb) ms_free(wd->rgb);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue