soc.2009.vulture: ea07c7cb: Some error messages, and a routine for d...
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Thu May 28 18:30:52 EDT 2009
-----------------------------------------------------------------
Revision: ea07c7cbe172cb4ef521f29e2f0c0385492df182
Ancestor: 1fdd144676a5c3cffb21d341f90555eaffd33528
Author: gdick at soc.pidgin.im
Date: 2009-05-28T16:03:59
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/ea07c7cbe172cb4ef521f29e2f0c0385492df182
Added files:
vulture/resource.h vulture/vulture-res.rc
Modified files:
vulture/Makefile.mingw vulture/blist.c vulture/purplemain.c
vulture/vulture.c
ChangeLog:
Some error messages, and a routine for displaying them.
-------------- next part --------------
============================================================
--- vulture/resource.h 65e7f36ab4e1a2ec0043ec83a05cf7bdc72edc08
+++ vulture/resource.h 65e7f36ab4e1a2ec0043ec83a05cf7bdc72edc08
@@ -0,0 +1,6 @@
+#ifndef IDC_STATIC
+#define IDC_STATIC (-1)
+#endif
+
+#define IDS_ERROR_BLIST 40000
+#define IDS_ERROR_PURPLEINIT 40001
============================================================
--- vulture/vulture-res.rc ec1f630c519111c7c066049bf110f516f5564512
+++ vulture/vulture-res.rc ec1f630c519111c7c066049bf110f516f5564512
@@ -0,0 +1,20 @@
+// Generated by ResEdit 1.4.4.19
+// Copyright (C) 2006-2008
+// http://www.resedit.net
+
+#include "resource.h"
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+
+
+//
+// String Table resources
+//
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+STRINGTABLE
+
+{
+ IDS_ERROR_BLIST "Couldn't initialise buddy list."
+ IDS_ERROR_PURPLEINIT "Couldn't initialise libpurple."
+}
============================================================
--- vulture/Makefile.mingw 2488db57325c16b139df5b6e27f0d1bec5577caf
+++ vulture/Makefile.mingw 1ca5c8e23eecb683748d4de62f3ef90e620033fa
@@ -58,7 +58,7 @@ VULTURE_C_SRC = \
purpleevloop.c \
cmdline.c
-# VULTURE_RC_SRC = win32/pidgin_dll_rc.rc
+VULTURE_RC_SRC = vulture-res.rc
VULTURE_OBJECTS = $(VULTURE_C_SRC:%.c=%.o) $(VULTURE_RC_SRC:%.rc=%.o)
##
@@ -85,11 +85,6 @@ install: install_shallow all
install: install_shallow all
-vulture.rc: vulture.rc.in $(PIDGIN_TREE_TOP)/VERSION
- sed -e 's/@PIDGIN_VERSION@/$(PIDGIN_VERSION)/g' \
- -e 's/@ORIGINAL_FILENAME@/$(EXE_NAME)/' \
- $@.in > $@
-
$(VULTURE_TARGET).exe: $(PURPLE_DLL).a $(VULTURE_OBJECTS)
$(CC) $(LDFLAGS) $(VULTURE_OBJECTS) $(LIB_PATHS) $(VULTURE_LIBS) -o $(VULTURE_TARGET).exe
============================================================
--- vulture/blist.c c833f6ebe0d523cc2c982d8ee4733b0b1aa830d8
+++ vulture/blist.c 70d00810fc372048e7bef93d66bdcc469ebb2fa7
@@ -103,7 +103,7 @@ static LRESULT CALLBACK BuddyListProc(HW
switch(uiMsg)
{
case WM_DESTROY:
- PostQuitMessage(0);
+ PostQuitMessage(VEC_SUCCESS);
return 0;
}
============================================================
--- vulture/purplemain.c 1ec28ecbef8584c2f4769554b9ad6ad0228e1e42
+++ vulture/purplemain.c 3f251d8fa3361023d35476207699c733a4758d01
@@ -98,8 +98,6 @@ static UINT CALLBACK PurpleThread(void *
GSource *lpgsourceSync = VultureCreateSyncQueueSource();
GSource *lpgsourceAsync = VultureCreateAsyncQueueSource();
- int iRet = 0;
-
UNREFERENCED_PARAMETER(lpvData);
g_lpgmainloop = g_main_loop_new(NULL, TRUE);
@@ -120,7 +118,7 @@ static UINT CALLBACK PurpleThread(void *
g_source_unref(lpgsourceAsync);
g_source_unref(lpgsourceSync);
- return iRet;
+ return 0;
}
============================================================
--- vulture/vulture.c e06afa6d7612008397238e49370b87fe04126658
+++ vulture/vulture.c d96f4fadf76c395f46e5bdccc13cb2aed439d2cb
@@ -24,6 +24,7 @@
#include <windows.h>
#include "vulture.h"
+#include "resource.h"
#include "blist.h"
#include "purplemain.h"
#include "purplequeue.h"
@@ -31,6 +32,8 @@ HINSTANCE g_hInstance;
HINSTANCE g_hInstance;
+HANDLE g_hProcHeap;
+
const TCHAR cg_szAppName[] = TEXT("Vulture");
@@ -50,18 +53,21 @@ int WINAPI WinMain(HINSTANCE hinst, HINS
HANDLE hthreadPurple;
g_hInstance = hinst;
+ g_hProcHeap = GetProcessHeap();
VultureParseCommandLine();
if(VultureCreateBuddyList(iCmdShow) != 0)
{
- return 1;
+ MessageBoxFromStringTable(NULL, IDS_ERROR_BLIST, MB_ICONERROR);
+ return VEC_ERROR_BLIST;
}
VultureInitLibpurple(&hthreadPurple);
if(hthreadPurple == (HANDLE)-1L)
{
- return 2;
+ MessageBoxFromStringTable(NULL, IDS_ERROR_PURPLEINIT, MB_ICONERROR);
+ return VEC_ERROR_PURPLEINIT;
}
while(GetMessage(&msg, NULL, 0, 0))
@@ -83,3 +89,51 @@ int WINAPI WinMain(HINSTANCE hinst, HINS
return msg.wParam;
}
+
+
+#define MBFST_INIT_BUFSIZE 128
+
+/**
+ * Displays a message box using a string from the table.
+ *
+ * @param hwnd Parent window.
+ * @param wResourceString ID of string.
+ * @param uiType As for MessageBox.
+ *
+ * @return As for MessageBox.
+ */
+int MessageBoxFromStringTable(HWND hwnd, WORD wResourceString, UINT uiType)
+{
+ MSGBOXPARAMS mbp;
+ DWORD cchBuffer = MBFST_INIT_BUFSIZE;
+ LPTSTR szBuffer = ProcHeapAlloc(cchBuffer * sizeof(TCHAR));
+ int iRet;
+
+ /* Load the string. We don't just pass the ID to MessageBoxIndirect, since
+ * it has an (undocumented?!) limit on the length of the string.
+ */
+ while((DWORD)LoadString(g_hInstance, wResourceString, szBuffer, cchBuffer) >= cchBuffer - 1)
+ {
+ ProcHeapFree(szBuffer);
+ cchBuffer <<= 1;
+ szBuffer = ProcHeapAlloc(cchBuffer * sizeof(TCHAR));
+ }
+
+
+ mbp.cbSize = sizeof(mbp);
+ mbp.dwContextHelpId = 0;
+ mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
+ mbp.dwStyle = uiType;
+ mbp.hInstance = g_hInstance;
+ mbp.hwndOwner = hwnd;
+ mbp.lpfnMsgBoxCallback = NULL;
+ mbp.lpszCaption = cg_szAppName;
+ mbp.lpszIcon = NULL;
+ mbp.lpszText = szBuffer;
+
+ iRet = MessageBoxIndirect(&mbp);
+
+ ProcHeapFree(szBuffer);
+
+ return iRet;
+}
More information about the Commits
mailing list