Windows: Added support for notifications
This commit is contained in:
parent
cd62c6cdf5
commit
b2cde0f7fb
|
@ -2,7 +2,7 @@ include $(top_srcdir)/win32/ltrc.inc
|
|||
|
||||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
|
||||
EXTRA_DIST = Makefile.mak
|
||||
EXTRA_DIST = Makefile.mak opensc.dll.manifest
|
||||
|
||||
lib_LTLIBRARIES = libopensc.la
|
||||
noinst_HEADERS = cards.h ctbcs.h internal.h esteid.h muscle.h muscle-filesystem.h \
|
||||
|
|
|
@ -55,8 +55,8 @@ opensc.dll: $(OBJECTS) $(LIBS)
|
|||
echo LIBRARY $* > $*.def
|
||||
echo EXPORTS >> $*.def
|
||||
type lib$*.exports >> $*.def
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:opensc.dll $(OBJECTS) $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) $(ZLIB_LIB) gdi32.lib advapi32.lib ws2_32.lib
|
||||
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:opensc.dll $(OBJECTS) $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) $(ZLIB_LIB) gdi32.lib Comctl32.lib Shell32.lib user32.lib advapi32.lib ws2_32.lib
|
||||
if EXIST opensc.dll.manifest mt -manifest opensc.dll.manifest -outputresource:opensc.dll;2
|
||||
|
||||
opensc_a.lib: $(OBJECTS) $(LIBS)
|
||||
lib $(LIBFLAGS) /out:opensc_a.lib $(OBJECTS) $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) $(ZLIB_LIB) user32.lib advapi32.lib ws2_32.lib
|
||||
lib $(LIBFLAGS) /out:opensc_a.lib $(OBJECTS) $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) $(ZLIB_LIB) gdi32.lib Comctl32.lib Shell32.lib user32.lib advapi32.lib ws2_32.lib
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
|
@ -47,7 +47,9 @@
|
|||
#include "libopensc/log.h"
|
||||
#include "libopensc/internal.h"
|
||||
#include "libopensc/aux-data.h"
|
||||
#include "ui/notify.h"
|
||||
#include "ui/strings.h"
|
||||
#include "ui/wchar_from_char_str.h"
|
||||
#include "pkcs15init/pkcs15-init.h"
|
||||
|
||||
#ifdef ENABLE_OPENSSL
|
||||
|
@ -2476,31 +2478,6 @@ static const char *md_get_ui_str(PCARD_DATA pCardData, enum ui_str id)
|
|||
return str;
|
||||
}
|
||||
|
||||
static WCHAR *wchar_from_char_str(const char *in)
|
||||
{
|
||||
WCHAR *out;
|
||||
int out_len;
|
||||
|
||||
if (!in)
|
||||
return NULL;
|
||||
|
||||
out_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, NULL, 0);
|
||||
if (0 >= out_len)
|
||||
return NULL;
|
||||
|
||||
out = LocalAlloc(0, (sizeof *out) * out_len);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
out_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, out, out_len);
|
||||
if (out_len == 0xFFFD || 0 >= out_len) {
|
||||
LocalFree(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK md_dialog_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LONG_PTR dwRefData)
|
||||
{
|
||||
LONG_PTR param;
|
||||
|
@ -6250,10 +6227,13 @@ BOOL APIENTRY DllMain( HINSTANCE hinstDLL,
|
|||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
g_inst = hinstDLL;
|
||||
sc_notify_instance = hinstDLL;
|
||||
sc_notify_init();
|
||||
InitializeCriticalSection(&md_static_data.hScard_lock);
|
||||
md_static_data.attach_check = MD_STATIC_PROCESS_ATTACHED;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
sc_notify_close();
|
||||
DeleteCriticalSection(&md_static_data.hScard_lock);
|
||||
md_static_data.attach_check = 0;
|
||||
break;
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
#include <winresrc.h>
|
||||
|
||||
#define IDC_STATIC -1
|
||||
/* defined twice: in versioninfo-minidriver.rc.in and in minidriver.c */
|
||||
#define IDI_SMARTCARD 102
|
||||
/* defined twice: in ressource file and in source code */
|
||||
#define IDI_SMARTCARD 102
|
||||
#define IDI_UNLOCKED 103
|
||||
#define IDI_LOCKED 104
|
||||
#define IDI_READER_EMPTY 105
|
||||
#define IDI_CARD_INSERTED 106
|
||||
|
||||
#ifndef __MINGW32__
|
||||
IDI_SMARTCARD ICON "..\\..\\win32\\DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "..\\..\\win32\\certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "..\\..\\win32\\certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "..\\..\\win32\\SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "..\\..\\win32\\SCardDlg.dll_14_143.ico"
|
||||
#else
|
||||
IDI_SMARTCARD ICON "../../win32/DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "../../win32/certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "../../win32/certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "../../win32/SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "../../win32/SCardDlg.dll_14_143.ico"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
|
@ -39,5 +57,3 @@ BEGIN
|
|||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
IDI_SMARTCARD ICON "..\\..\\win32\\DDORes.dll_14_2302.ico"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include $(top_srcdir)/win32/ltrc.inc
|
||||
|
||||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/versioninfo-pkcs11.rc $(srcdir)/versioninfo-pkcs11-spy.rc
|
||||
EXTRA_DIST = Makefile.mak versioninfo-pkcs11.rc.in versioninfo-pkcs11-spy.rc.in opensc-pkcs11.pc.in
|
||||
EXTRA_DIST = Makefile.mak versioninfo-pkcs11.rc.in versioninfo-pkcs11-spy.rc.in opensc-pkcs11.pc.in opensc-pkcs11.dll.manifest onepin-opensc-pkcs11.dll.manifest
|
||||
|
||||
lib_LTLIBRARIES = opensc-pkcs11.la pkcs11-spy.la onepin-opensc-pkcs11.la
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
|
@ -1,5 +1,27 @@
|
|||
#include <winresrc.h>
|
||||
|
||||
#define IDC_STATIC -1
|
||||
/* defined twice: in ressource file and in source code */
|
||||
#define IDI_SMARTCARD 102
|
||||
#define IDI_UNLOCKED 103
|
||||
#define IDI_LOCKED 104
|
||||
#define IDI_READER_EMPTY 105
|
||||
#define IDI_CARD_INSERTED 106
|
||||
|
||||
#ifndef __MINGW32__
|
||||
IDI_SMARTCARD ICON "..\\..\\win32\\DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "..\\..\\win32\\certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "..\\..\\win32\\certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "..\\..\\win32\\SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "..\\..\\win32\\SCardDlg.dll_14_143.ico"
|
||||
#else
|
||||
IDI_SMARTCARD ICON "../../win32/DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "../../win32/certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "../../win32/certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "../../win32/SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "../../win32/SCardDlg.dll_14_143.ico"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
PRODUCTVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
|
@ -35,4 +57,3 @@ BEGIN
|
|||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
#include <winresrc.h>
|
||||
|
||||
#define IDC_STATIC -1
|
||||
/* defined twice: in ressource file and in source code */
|
||||
#define IDI_SMARTCARD 102
|
||||
#define IDI_UNLOCKED 103
|
||||
#define IDI_LOCKED 104
|
||||
#define IDI_READER_EMPTY 105
|
||||
#define IDI_CARD_INSERTED 106
|
||||
|
||||
#ifndef __MINGW32__
|
||||
IDI_SMARTCARD ICON "..\\..\\win32\\DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "..\\..\\win32\\certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "..\\..\\win32\\certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "..\\..\\win32\\SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "..\\..\\win32\\SCardDlg.dll_14_143.ico"
|
||||
#else
|
||||
IDI_SMARTCARD ICON "../../win32/DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "../../win32/certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "../../win32/certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "../../win32/SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "../../win32/SCardDlg.dll_14_143.ico"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
PRODUCTVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
|
@ -35,4 +57,3 @@ BEGIN
|
|||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
EXTRA_DIST = Makefile.mak
|
||||
EXTRA_DIST = Makefile.mak smm-local.dll.manifest
|
||||
|
||||
AM_CFLAGS = $(OPTIONAL_OPENSSL_CFLAGS) $(OPTIONAL_READLINE_CFLAGS)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/common -I$(top_builddir)/src/include
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
|
@ -24,4 +24,4 @@ $(TARGETS): $(OBJECTS) $(LIBS)
|
|||
.c.exe:
|
||||
cl $(COPTS) /c $<
|
||||
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj $(OBJECTS) $(LIBS) $(OPENPACE_LIB) $(OPENSSL_LIB) gdi32.lib shell32.lib ws2_32.lib
|
||||
if EXIST $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
||||
mt -manifest exe.manifest -outputresource:$@;1
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
|
@ -1,5 +1,27 @@
|
|||
#include <winresrc.h>
|
||||
|
||||
#define IDC_STATIC -1
|
||||
/* defined twice: in ressource file and in source code */
|
||||
#define IDI_SMARTCARD 102
|
||||
#define IDI_UNLOCKED 103
|
||||
#define IDI_LOCKED 104
|
||||
#define IDI_READER_EMPTY 105
|
||||
#define IDI_CARD_INSERTED 106
|
||||
|
||||
#ifndef __MINGW32__
|
||||
IDI_SMARTCARD ICON "..\\..\\win32\\DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "..\\..\\win32\\certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "..\\..\\win32\\certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "..\\..\\win32\\SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "..\\..\\win32\\SCardDlg.dll_14_143.ico"
|
||||
#else
|
||||
IDI_SMARTCARD ICON "../../win32/DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "../../win32/certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "../../win32/certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "../../win32/SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "../../win32/SCardDlg.dll_14_143.ico"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
PRODUCTVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
|
|
|
@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
|||
EXTRA_DIST = Makefile.mak
|
||||
|
||||
noinst_LTLIBRARIES = libstrings.la libnotify.la
|
||||
noinst_HEADERS = strings.h notify.h
|
||||
noinst_HEADERS = strings.h notify.h wchar_from_char_str.h
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
AM_CFLAGS = $(OPTIONAL_OPENSSL_CFLAGS) $(OPTIONAL_NOTIFY_CFLAGS)
|
||||
|
|
215
src/ui/notify.c
215
src/ui/notify.c
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "notify.h"
|
||||
|
||||
#if defined(ENABLE_NOTIFY) && (defined(__APPLE__) || defined(GDBUS))
|
||||
#if defined(ENABLE_NOTIFY) && (defined(__APPLE__) || (defined(GDBUS) && !defined(_WIN32)))
|
||||
|
||||
#include "libopensc/log.h"
|
||||
#include <signal.h>
|
||||
|
@ -63,7 +63,216 @@ void sc_notify_close(void)
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_NOTIFY) && defined(__APPLE__)
|
||||
#if defined(ENABLE_NOTIFY) && defined(_WIN32)
|
||||
|
||||
#include "wchar_from_char_str.h"
|
||||
#include <shellapi.h>
|
||||
|
||||
static const GUID myGUID = {0x23977b55, 0x10e0, 0x4041, {0xb8,
|
||||
0x62, 0xb1, 0x95, 0x41, 0x96, 0x36, 0x69}};
|
||||
HINSTANCE sc_notify_instance = NULL;
|
||||
HWND hwndNotification = NULL;
|
||||
#define IDI_SMARTCARD 102
|
||||
#define IDI_UNLOCKED 103
|
||||
#define IDI_LOCKED 104
|
||||
#define IDI_READER_EMPTY 105
|
||||
#define IDI_CARD_INSERTED 106
|
||||
UINT const WMAPP_NOTIFYCALLBACK = WM_APP + 1;
|
||||
BOOL RestoreTooltip(void);
|
||||
|
||||
// we need commctrl v6 for LoadIconMetric()
|
||||
#include <commctrl.h>
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if ((message == WM_DESTROY)
|
||||
|| (message == WMAPP_NOTIFYCALLBACK
|
||||
&& (LOWORD(lParam) == NIN_BALLOONTIMEOUT
|
||||
|| LOWORD(lParam) == NIN_BALLOONUSERCLICK))) {
|
||||
#if 0
|
||||
DeleteNotificationIcon();
|
||||
#else
|
||||
RestoreTooltip();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
static const char* class_name = "DUMMY_CLASS";
|
||||
static const char* window_name = "DUMMY_WINDOW";
|
||||
|
||||
static BOOL create_invisible_window(void)
|
||||
{
|
||||
if (!hwndNotification) {
|
||||
//Register Window class
|
||||
WNDCLASSEX wx = {0};
|
||||
wx.cbSize = sizeof(WNDCLASSEX);
|
||||
wx.lpfnWndProc = WndProc; // function which will handle messages
|
||||
wx.hInstance = sc_notify_instance;
|
||||
wx.lpszClassName = class_name;
|
||||
if (!RegisterClassEx(&wx)) {
|
||||
return FALSE;
|
||||
}
|
||||
/* create window */
|
||||
hwndNotification = CreateWindowEx(0, class_name, window_name,
|
||||
0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL );
|
||||
}
|
||||
|
||||
if (hwndNotification) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL delete_invisible_window(void)
|
||||
{
|
||||
BOOL r;
|
||||
r = DestroyWindow(hwndNotification);
|
||||
r &= UnregisterClass(class_name, sc_notify_instance);
|
||||
|
||||
hwndNotification = NULL;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static BOOL AddNotificationIcon(void)
|
||||
{
|
||||
NOTIFYICONDATA nid = {sizeof(nid)};
|
||||
TCHAR path[MAX_PATH]={0};
|
||||
BOOL r;
|
||||
|
||||
if (!create_invisible_window()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nid.hWnd = hwndNotification;
|
||||
// add the icon, setting the icon, tooltip, and callback message.
|
||||
// the icon will be identified with the GUID
|
||||
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_SHOWTIP | NIF_GUID;
|
||||
nid.guidItem = myGUID;
|
||||
nid.uCallbackMessage = WMAPP_NOTIFYCALLBACK;
|
||||
LoadIconMetric(sc_notify_instance, MAKEINTRESOURCEW(IDI_SMARTCARD), LIM_SMALL, &nid.hIcon);
|
||||
if (GetModuleFileName(NULL, path, ARRAYSIZE(path))) {
|
||||
strcpy_s(nid.szTip, ARRAYSIZE(nid.szTip), path);
|
||||
} else {
|
||||
strcpy(nid.szTip, PACKAGE_NAME);
|
||||
}
|
||||
|
||||
r = Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
|
||||
nid.uVersion = NOTIFYICON_VERSION_4;
|
||||
r &= Shell_NotifyIcon(NIM_SETVERSION, &nid);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static BOOL DeleteNotificationIcon(void)
|
||||
{
|
||||
BOOL r;
|
||||
NOTIFYICONDATA nid = {sizeof(nid)};
|
||||
|
||||
nid.uFlags = NIF_GUID;
|
||||
nid.guidItem = myGUID;
|
||||
|
||||
r = Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
r &= delete_invisible_window();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static BOOL RestoreTooltip()
|
||||
{
|
||||
// After the balloon is dismissed, restore the tooltip.
|
||||
NOTIFYICONDATA nid = {sizeof(nid)};
|
||||
|
||||
nid.uFlags = NIF_SHOWTIP | NIF_GUID;
|
||||
nid.guidItem = myGUID;
|
||||
|
||||
return Shell_NotifyIcon(NIM_MODIFY, &nid);
|
||||
}
|
||||
|
||||
static void notify_shell(struct sc_context *ctx,
|
||||
const char *title, const char *text, WORD icon)
|
||||
{
|
||||
NOTIFYICONDATA nid = {sizeof(nid)};
|
||||
|
||||
nid.uFlags = NIF_GUID;
|
||||
nid.guidItem = myGUID;
|
||||
|
||||
if (title) {
|
||||
strcpy_s(nid.szInfoTitle, ARRAYSIZE(nid.szInfoTitle), title);
|
||||
}
|
||||
if (text) {
|
||||
nid.uFlags |= NIF_INFO;
|
||||
strcpy_s(nid.szInfo, ARRAYSIZE(nid.szInfo), text);
|
||||
}
|
||||
if (icon) {
|
||||
nid.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
|
||||
LoadIconMetric(sc_notify_instance, MAKEINTRESOURCEW(icon), LIM_LARGE, &nid.hBalloonIcon);
|
||||
}
|
||||
|
||||
Shell_NotifyIcon(NIM_MODIFY, &nid);
|
||||
}
|
||||
|
||||
void sc_notify_init(void)
|
||||
{
|
||||
if (!sc_notify_instance) {
|
||||
/* returns the HINSTANCE of the exe. If the code executes in a DLL,
|
||||
* sc_notify_instance_notify should be pre-initialized */
|
||||
sc_notify_instance = GetModuleHandle(NULL);
|
||||
}
|
||||
AddNotificationIcon();
|
||||
}
|
||||
|
||||
void sc_notify_close(void)
|
||||
{
|
||||
DeleteNotificationIcon();
|
||||
}
|
||||
|
||||
void sc_notify(const char *title, const char *text)
|
||||
{
|
||||
notify_shell(NULL, title, text, 0);
|
||||
}
|
||||
|
||||
void sc_notify_id(struct sc_context *ctx, struct sc_atr *atr,
|
||||
struct sc_pkcs15_card *p15card, enum ui_str id)
|
||||
{
|
||||
const char *title, *text, *group;
|
||||
WORD icon;
|
||||
title = ui_get_str(ctx, atr, p15card, id);
|
||||
text = ui_get_str(ctx, atr, p15card, id+1);
|
||||
|
||||
if (p15card && p15card->card && p15card->card->reader) {
|
||||
group = p15card->card->reader->name;
|
||||
} else {
|
||||
group = ctx ? ctx->app_name : NULL;
|
||||
}
|
||||
|
||||
switch (id) {
|
||||
case NOTIFY_CARD_INSERTED:
|
||||
icon = IDI_CARD_INSERTED;
|
||||
break;
|
||||
case NOTIFY_CARD_REMOVED:
|
||||
icon = IDI_READER_EMPTY;
|
||||
break;
|
||||
case NOTIFY_PIN_GOOD:
|
||||
icon = IDI_UNLOCKED;
|
||||
break;
|
||||
case NOTIFY_PIN_BAD:
|
||||
icon = IDI_LOCKED;
|
||||
break;
|
||||
default:
|
||||
icon = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
notify_shell(ctx, title, text, icon);
|
||||
}
|
||||
|
||||
#elif defined(ENABLE_NOTIFY) && defined(__APPLE__)
|
||||
|
||||
static void notify_proxy(struct sc_context *ctx,
|
||||
const char *title, const char* subtitle,
|
||||
|
@ -169,7 +378,7 @@ void sc_notify_id(struct sc_context *ctx, struct sc_atr *atr,
|
|||
notify_proxy(ctx, title, NULL, text, icon, NULL, group);
|
||||
}
|
||||
|
||||
#elif defined(ENABLE_NOTIFY) && defined(GDBUS)
|
||||
#elif defined(ENABLE_NOTIFY) && defined(GDBUS) && !defined(_WIN32)
|
||||
|
||||
#include <inttypes.h>
|
||||
/* save the notification's id for replacement with a new one */
|
||||
|
|
|
@ -33,6 +33,14 @@ void sc_notify(const char *title, const char *text);
|
|||
void sc_notify_id(struct sc_context *ctx, struct sc_atr *atr,
|
||||
struct sc_pkcs15_card *p15card, enum ui_str id);
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
/* If the code executes in a DLL, `sc_notify_instance_notify` should be
|
||||
* initialized before calling `sc_notify_init()`. If not initialized, we're
|
||||
* using the HINSTANCE of the EXE */
|
||||
extern HINSTANCE sc_notify_instance;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* wchar_from_char_str.h: Conversion from string to wide string
|
||||
*
|
||||
* Copyright (C) 2017 Frank Morgner <frankmorgner@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
static WCHAR *wchar_from_char_str(const char *in)
|
||||
{
|
||||
WCHAR *out;
|
||||
int out_len;
|
||||
|
||||
if (!in)
|
||||
return NULL;
|
||||
|
||||
out_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, NULL, 0);
|
||||
if (0 >= out_len)
|
||||
return NULL;
|
||||
|
||||
out = LocalAlloc(0, (sizeof *out) * out_len);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
out_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, out, out_len);
|
||||
if (out_len == 0xFFFD || 0 >= out_len) {
|
||||
LocalFree(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
|
@ -125,10 +125,10 @@ ALL_INCLUDES = /I$(TOPDIR)\win32 /I$(TOPDIR)\src $(OPENPACE_INCL_DIR) $(OPENSSL_
|
|||
!IF "$(DEBUG_DEF)" == "/DDEBUG"
|
||||
LINKDEBUGFLAGS = /NODEFAULTLIB:LIBCMT /DEBUG
|
||||
CODE_OPTIMIZATION =
|
||||
COPTS = /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MTd /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\"" /DDEBUG /Zi /Od
|
||||
COPTS = /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MTd /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\"" /DDEBUG /Zi /Od
|
||||
!ELSE
|
||||
LINKDEBUGFLAGS = /NODEFAULTLIB:LIBCMTD
|
||||
COPTS = /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MT /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
|
||||
COPTS = /GS /W3 /D_CRT_SECURE_NO_DEPRECATE /MT /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
|
||||
!ENDIF
|
||||
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -1,5 +1,27 @@
|
|||
#include <winresrc.h>
|
||||
|
||||
#define IDC_STATIC -1
|
||||
/* defined twice: in ressource file and in source code */
|
||||
#define IDI_SMARTCARD 102
|
||||
#define IDI_UNLOCKED 103
|
||||
#define IDI_LOCKED 104
|
||||
#define IDI_READER_EMPTY 105
|
||||
#define IDI_CARD_INSERTED 106
|
||||
|
||||
#ifndef __MINGW32__
|
||||
IDI_SMARTCARD ICON "..\\..\\win32\\DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "..\\..\\win32\\certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "..\\..\\win32\\certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "..\\..\\win32\\SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "..\\..\\win32\\SCardDlg.dll_14_143.ico"
|
||||
#else
|
||||
IDI_SMARTCARD ICON "../../win32/DDORes.dll_14_2302.ico"
|
||||
IDI_UNLOCKED ICON "../../win32/certmgr.dll_14_6170.ico"
|
||||
IDI_LOCKED ICON "../../win32/certmgr.dll_14_452.ico"
|
||||
IDI_READER_EMPTY ICON "../../win32/SCardDlg.dll_14_142.ico"
|
||||
IDI_CARD_INSERTED ICON "../../win32/SCardDlg.dll_14_143.ico"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
PRODUCTVERSION @OPENSC_VERSION_MAJOR@,@OPENSC_VERSION_MINOR@,@OPENSC_VERSION_FIX@,@OPENSC_VERSION_REVISION@
|
||||
|
@ -35,4 +57,3 @@ BEGIN
|
|||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@
|
|||
#define DEFAULT_PCSC_PROVIDER "@DEFAULT_PCSC_PROVIDER@"
|
||||
#endif
|
||||
|
||||
#define ENABLE_NOTIFY
|
||||
|
||||
#define SC_PKCS15_PROFILE_DIRECTORY "C:\\Program Files\\OpenSC Project\\OpenSC\\profiles"
|
||||
|
||||
#define PATH_MAX FILENAME_MAX
|
||||
|
|
Loading…
Reference in New Issue