update checker reworked
This commit is contained in:
parent
9138d7e281
commit
cc6e18411c
@ -1,36 +0,0 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <wininet.h>
|
|
||||||
|
|
||||||
char* check_version ()
|
|
||||||
{
|
|
||||||
HINTERNET hINet, hFile;
|
|
||||||
hINet = InternetOpen("XChat-WDK Update Checker", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
|
|
||||||
|
|
||||||
if (!hINet)
|
|
||||||
{
|
|
||||||
return "unavailable";
|
|
||||||
}
|
|
||||||
|
|
||||||
hFile = InternetOpenUrl (hINet, "http://xchat-wdk.googlecode.com/hg/version.txt", NULL, 0, 0, 0);
|
|
||||||
|
|
||||||
if (hFile)
|
|
||||||
{
|
|
||||||
static char buffer[1024];
|
|
||||||
DWORD dwRead;
|
|
||||||
while (InternetReadFile(hFile, buffer, 1023, &dwRead))
|
|
||||||
{
|
|
||||||
if (dwRead == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
buffer[dwRead] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
InternetCloseHandle (hFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
InternetCloseHandle (hINet);
|
|
||||||
|
|
||||||
return "unavailable";
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
char* check_version ();
|
|
143
src/fe-gtk/update.c
Normal file
143
src/fe-gtk/update.c
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/* X-Chat
|
||||||
|
* Copyright (C) 1998 Peter Zelezny.
|
||||||
|
*
|
||||||
|
* 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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "fe-gtk.h"
|
||||||
|
|
||||||
|
#include <gtk/gtkmain.h>
|
||||||
|
#include <gtk/gtkcontainer.h>
|
||||||
|
#include <gtk/gtkdialog.h>
|
||||||
|
#include <gtk/gtkvbox.h>
|
||||||
|
#include <gtk/gtkhbox.h>
|
||||||
|
#include <gtk/gtkimage.h>
|
||||||
|
#include <gtk/gtklabel.h>
|
||||||
|
#include <gtk/gtkbutton.h>
|
||||||
|
#include <gtk/gtkstock.h>
|
||||||
|
#include <gtk/gtkwindow.h>
|
||||||
|
|
||||||
|
#include "../common/xchat.h"
|
||||||
|
#include "../common/util.h"
|
||||||
|
#include "../common/portable.h"
|
||||||
|
#include "check-version.h"
|
||||||
|
#include "palette.h"
|
||||||
|
#include "pixmaps.h"
|
||||||
|
#include "gtkutil.h"
|
||||||
|
#include "update.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wininet.h>
|
||||||
|
|
||||||
|
char* check_version ()
|
||||||
|
{
|
||||||
|
HINTERNET hINet, hFile;
|
||||||
|
hINet = InternetOpen("XChat-WDK Update Checker", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
|
||||||
|
|
||||||
|
if (!hINet)
|
||||||
|
{
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
hFile = InternetOpenUrl (hINet, "http://xchat-wdk.googlecode.com/hg/version.txt", NULL, 0, 0, 0);
|
||||||
|
|
||||||
|
if (hFile)
|
||||||
|
{
|
||||||
|
static char buffer[1024];
|
||||||
|
DWORD dwRead;
|
||||||
|
while (InternetReadFile(hFile, buffer, 1023, &dwRead))
|
||||||
|
{
|
||||||
|
if (dwRead == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer[dwRead] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
|
||||||
|
InternetCloseHandle (hFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
InternetCloseHandle (hINet);
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *about = 0;
|
||||||
|
|
||||||
|
static int
|
||||||
|
about_close (void)
|
||||||
|
{
|
||||||
|
about = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
menu_update (GtkWidget * wid, gpointer sess)
|
||||||
|
{
|
||||||
|
GtkWidget *vbox, *label, *hbox;
|
||||||
|
char buf[512];
|
||||||
|
const char *locale = NULL;
|
||||||
|
extern GtkWindow *parent_window; /* maingui.c */
|
||||||
|
|
||||||
|
if (about)
|
||||||
|
{
|
||||||
|
gtk_window_present (GTK_WINDOW (about));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
about = gtk_dialog_new ();
|
||||||
|
gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER);
|
||||||
|
gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
|
||||||
|
gtk_window_set_title (GTK_WINDOW (about), _("Update Checker"));
|
||||||
|
if (parent_window)
|
||||||
|
gtk_window_set_transient_for (GTK_WINDOW (about), parent_window);
|
||||||
|
g_signal_connect (G_OBJECT (about), "destroy",
|
||||||
|
G_CALLBACK (about_close), 0);
|
||||||
|
|
||||||
|
vbox = GTK_DIALOG (about)->vbox;
|
||||||
|
|
||||||
|
wid = gtk_image_new_from_pixbuf (pix_xchat);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), wid);
|
||||||
|
|
||||||
|
label = gtk_label_new (NULL);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||||
|
g_get_charset (&locale);
|
||||||
|
(snprintf) (buf, sizeof (buf),
|
||||||
|
"<b>Your Version</b>: "PACKAGE_VERSION"\n"
|
||||||
|
"<b>Latest Version</b>: %s%s",
|
||||||
|
check_version ()
|
||||||
|
/*((strcmp (check_version (), PACKAGE_VERSION) != 0) && (strcmp (check_version (), "Unknown") != 0)) ? "\n\nDownload the new version from\n\n<b>http://code.google.com/p/xchat-wdk/</b>" : ""*/
|
||||||
|
);
|
||||||
|
gtk_label_set_markup (GTK_LABEL (label), buf);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new (0, 2);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||||
|
|
||||||
|
wid = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
|
||||||
|
GTK_WIDGET_SET_FLAGS (GTK_WIDGET (wid), GTK_CAN_DEFAULT);
|
||||||
|
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area), wid, 0, 0, 0);
|
||||||
|
gtk_widget_grab_default (wid);
|
||||||
|
g_signal_connect (G_OBJECT (wid), "clicked",
|
||||||
|
G_CALLBACK (gtkutil_destroy), about);
|
||||||
|
|
||||||
|
gtk_widget_show_all (about);
|
||||||
|
}
|
1
src/fe-gtk/update.h
Normal file
1
src/fe-gtk/update.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
void menu_update (GtkWidget * wid, gpointer sess);
|
@ -89,7 +89,6 @@ ascii.obj \
|
|||||||
banlist.obj \
|
banlist.obj \
|
||||||
chanlist.obj \
|
chanlist.obj \
|
||||||
chanview.obj \
|
chanview.obj \
|
||||||
check-version.obj \
|
|
||||||
custom-list.obj \
|
custom-list.obj \
|
||||||
dccgui.obj \
|
dccgui.obj \
|
||||||
editlist.obj \
|
editlist.obj \
|
||||||
@ -111,6 +110,7 @@ servlistgui.obj \
|
|||||||
setup.obj \
|
setup.obj \
|
||||||
#sexy-spell-entry.obj \
|
#sexy-spell-entry.obj \
|
||||||
textgui.obj \
|
textgui.obj \
|
||||||
|
update.obj \
|
||||||
urlgrab.obj \
|
urlgrab.obj \
|
||||||
userlistgui.obj \
|
userlistgui.obj \
|
||||||
xtext.obj
|
xtext.obj
|
||||||
|
@ -655,17 +655,17 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/xchat.h xchat-wdk/src/co
|
|||||||
#define X_OK 1
|
#define X_OK 1
|
||||||
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/about.c xchat-wdk/src/fe-gtk/about.c
|
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/about.c xchat-wdk/src/fe-gtk/about.c
|
||||||
--- xchat-wdk.orig/src/fe-gtk/about.c 2010-05-16 09:43:49 +0200
|
--- xchat-wdk.orig/src/fe-gtk/about.c 2010-05-16 09:43:49 +0200
|
||||||
+++ xchat-wdk/src/fe-gtk/about.c 2010-08-30 10:30:12 +0200
|
+++ xchat-wdk/src/fe-gtk/about.c 2010-08-30 12:09:20 +0200
|
||||||
@@ -39,6 +39,8 @@
|
@@ -39,6 +39,8 @@
|
||||||
|
|
||||||
#include "../common/xchat.h"
|
#include "../common/xchat.h"
|
||||||
#include "../common/util.h"
|
#include "../common/util.h"
|
||||||
+#include "../common/portable.h"
|
+#include "../common/portable.h"
|
||||||
+#include "check-version.h"
|
+//#include "check-version.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "pixmaps.h"
|
#include "pixmaps.h"
|
||||||
#include "gtkutil.h"
|
#include "gtkutil.h"
|
||||||
@@ -114,35 +116,40 @@
|
@@ -114,35 +116,38 @@
|
||||||
g_get_charset (&locale);
|
g_get_charset (&locale);
|
||||||
(snprintf) (buf, sizeof (buf),
|
(snprintf) (buf, sizeof (buf),
|
||||||
"<span size=\"x-large\"><b>"DISPLAY_NAME" "PACKAGE_VERSION"</b></span>\n\n"
|
"<span size=\"x-large\"><b>"DISPLAY_NAME" "PACKAGE_VERSION"</b></span>\n\n"
|
||||||
@ -674,7 +674,6 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/about.c xchat-wdk/src/fe
|
|||||||
- /* leave this message to avoid time wasting bug reports! */
|
- /* leave this message to avoid time wasting bug reports! */
|
||||||
- "This version is unofficial and comes with no support.\n\n"
|
- "This version is unofficial and comes with no support.\n\n"
|
||||||
-#endif
|
-#endif
|
||||||
+ "<b>Latest Version</b>: %s\n"
|
|
||||||
+ "<b>XChat Base</b>: 2.8.8\n\n"
|
+ "<b>XChat Base</b>: 2.8.8\n\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
"<b>Charset</b>: %s "
|
"<b>Charset</b>: %s "
|
||||||
@ -684,7 +683,6 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/about.c xchat-wdk/src/fe
|
|||||||
+ "<b>Portable Mode</b>: %s\n\n"
|
+ "<b>Portable Mode</b>: %s\n\n"
|
||||||
+ "<small>This version is unofficial and comes with no support.\n"
|
+ "<small>This version is unofficial and comes with no support.\n"
|
||||||
+ "\302\251 1998-2010 Peter \305\275elezn\303\275 <zed@xchat.org></small>",
|
+ "\302\251 1998-2010 Peter \305\275elezn\303\275 <zed@xchat.org></small>",
|
||||||
+ check_version(),
|
|
||||||
+ get_cpu_str (),
|
+ get_cpu_str (),
|
||||||
+ locale,
|
+ locale,
|
||||||
+ gtk_major_version,
|
+ gtk_major_version,
|
||||||
@ -948,7 +946,7 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/maingui.c xchat-wdk/src/
|
|||||||
}
|
}
|
||||||
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/menu.c xchat-wdk/src/fe-gtk/menu.c
|
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/menu.c xchat-wdk/src/fe-gtk/menu.c
|
||||||
--- xchat-wdk.orig/src/fe-gtk/menu.c 2010-05-16 06:24:24 +0200
|
--- xchat-wdk.orig/src/fe-gtk/menu.c 2010-05-16 06:24:24 +0200
|
||||||
+++ xchat-wdk/src/fe-gtk/menu.c 2010-08-26 15:53:53 +0200
|
+++ xchat-wdk/src/fe-gtk/menu.c 2010-08-30 11:52:13 +0200
|
||||||
@@ -20,7 +20,6 @@
|
@@ -20,7 +20,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -957,6 +955,24 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/menu.c xchat-wdk/src/fe-
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@@ -68,6 +67,7 @@
|
||||||
|
#include "plugingui.h"
|
||||||
|
#include "search.h"
|
||||||
|
#include "textgui.h"
|
||||||
|
+#include "update.h"
|
||||||
|
#include "urlgrab.h"
|
||||||
|
#include "userlistgui.h"
|
||||||
|
#include "menu.h"
|
||||||
|
@@ -1652,9 +1652,7 @@
|
||||||
|
|
||||||
|
{N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 69 */
|
||||||
|
{N_("_Contents"), menu_docs, GTK_STOCK_HELP, M_MENUSTOCK, 0, 0, 1, GDK_F1},
|
||||||
|
-#if 0
|
||||||
|
{N_("Check for updates"), menu_update, 0, M_MENUITEM, 0, 1},
|
||||||
|
-#endif
|
||||||
|
{N_("_About"), menu_about, GTK_STOCK_ABOUT, M_MENUSTOCK, 0, 0, 1},
|
||||||
|
|
||||||
|
{0, 0, 0, M_END, 0, 0, 0},
|
||||||
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/palette.c xchat-wdk/src/fe-gtk/palette.c
|
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/palette.c xchat-wdk/src/fe-gtk/palette.c
|
||||||
--- xchat-wdk.orig/src/fe-gtk/palette.c 2010-05-16 05:20:22 +0200
|
--- xchat-wdk.orig/src/fe-gtk/palette.c 2010-05-16 05:20:22 +0200
|
||||||
+++ xchat-wdk/src/fe-gtk/palette.c 2010-08-26 15:53:53 +0200
|
+++ xchat-wdk/src/fe-gtk/palette.c 2010-08-26 15:53:53 +0200
|
||||||
|
Loading…
Reference in New Issue
Block a user