Dialer plugin
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2185 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
f9e4da2fea
commit
d9577c0ffe
5 changed files with 311 additions and 0 deletions
81
Contrib/Dialer/Dialer.txt
Normal file
81
Contrib/Dialer/Dialer.txt
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
DIALER PLUGIN
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Written by Amir Szekely aka KiCHiK
|
||||||
|
Readme by Joost Verburg
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
-----
|
||||||
|
|
||||||
|
The DialerDLL plugin for NSIS provides five functions related to internet connections.
|
||||||
|
|
||||||
|
Example of usage:
|
||||||
|
|
||||||
|
ClearErrors ;Clear the error flag
|
||||||
|
Dialer::FunctionName ;Call Dialer function
|
||||||
|
IfErrors "" +3 ;Check for errors
|
||||||
|
MessageBox "Function not available"
|
||||||
|
Quit
|
||||||
|
Pop $R0 ;Get the return value from the stack
|
||||||
|
MessageBox MB_OK $R0 ;Display the return value
|
||||||
|
|
||||||
|
FUNCTIONS
|
||||||
|
---------
|
||||||
|
|
||||||
|
If a function is not available on the system, the error flag will be set.
|
||||||
|
|
||||||
|
* AttemptConnect
|
||||||
|
|
||||||
|
Attempts to make a connection to the Internet if the system is not connected.
|
||||||
|
|
||||||
|
online - already connected / connection successful
|
||||||
|
offline - connection failed
|
||||||
|
|
||||||
|
Requires Internet Explorer 3 or later
|
||||||
|
|
||||||
|
* AutodialOnline
|
||||||
|
|
||||||
|
Causes the modem to automatically dial the default Internet connection if the system
|
||||||
|
is not connected to the internet. If the system is not set up to automatically
|
||||||
|
connect, it will prompt the user.
|
||||||
|
|
||||||
|
Return values:
|
||||||
|
|
||||||
|
online - already connected / connection successful
|
||||||
|
offline - connection failed
|
||||||
|
|
||||||
|
Requires Internet Explorer 4 or later
|
||||||
|
|
||||||
|
* AutodialUnattended
|
||||||
|
|
||||||
|
Causes the modem to automatically dial the default Internet connection if the system
|
||||||
|
is not connected to the internet. The user will not be prompted.
|
||||||
|
|
||||||
|
Return values:
|
||||||
|
|
||||||
|
online - already connected / connection successful
|
||||||
|
offline - connection failed
|
||||||
|
|
||||||
|
Requires Internet Explorer 4 or later
|
||||||
|
|
||||||
|
* AutodialHangup
|
||||||
|
|
||||||
|
Disconnects an automatic dial-up connection.
|
||||||
|
|
||||||
|
Return values:
|
||||||
|
|
||||||
|
success - disconnection successful
|
||||||
|
failure - disconnection failed
|
||||||
|
|
||||||
|
Requires Internet Explorer 4 or later
|
||||||
|
|
||||||
|
* GetConnectedState
|
||||||
|
|
||||||
|
Checks whether the system is connected to the internet.
|
||||||
|
|
||||||
|
Return values:
|
||||||
|
|
||||||
|
online - system is online
|
||||||
|
offline - system is offline
|
||||||
|
|
||||||
|
Requires Internet Explorer 4 or later
|
93
Contrib/Dialer/dialer.c
Normal file
93
Contrib/Dialer/dialer.c
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <WinInet.h>
|
||||||
|
|
||||||
|
typedef struct _stack_t {
|
||||||
|
struct _stack_t *next;
|
||||||
|
char text[1]; // this should be the length of string_size
|
||||||
|
} stack_t;
|
||||||
|
|
||||||
|
int popstring(char *str); // 0 on success, 1 on empty stack
|
||||||
|
void pushstring(char *str);
|
||||||
|
|
||||||
|
HWND g_hwndParent;
|
||||||
|
int g_stringsize;
|
||||||
|
stack_t **g_stacktop;
|
||||||
|
char *g_variables;
|
||||||
|
|
||||||
|
#define NSISFunction(funcname) void __declspec(dllexport) funcname(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
||||||
|
#define NSISGetVars g_hwndParent=hwndParent;g_stringsize=string_size;g_stacktop=stacktop;g_variables=variables
|
||||||
|
|
||||||
|
/****************\
|
||||||
|
* LOOK HERE *
|
||||||
|
\****************/
|
||||||
|
|
||||||
|
NSISFunction(AutodialOnline) {
|
||||||
|
NSISGetVars;
|
||||||
|
if (InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0))
|
||||||
|
pushstring("online");
|
||||||
|
else
|
||||||
|
pushstring("offline");
|
||||||
|
}
|
||||||
|
|
||||||
|
NSISFunction(AutodialUnattended) {
|
||||||
|
NSISGetVars;
|
||||||
|
if (InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED , 0))
|
||||||
|
pushstring("online");
|
||||||
|
else
|
||||||
|
pushstring("offline");
|
||||||
|
}
|
||||||
|
|
||||||
|
NSISFunction(AttemptConnect) {
|
||||||
|
NSISGetVars;
|
||||||
|
if (InternetAttemptConnect(0) == ERROR_SUCCESS)
|
||||||
|
pushstring("online");
|
||||||
|
else
|
||||||
|
pushstring("offline");
|
||||||
|
}
|
||||||
|
|
||||||
|
NSISFunction(GetConnectedState) {
|
||||||
|
DWORD dwState;
|
||||||
|
NSISGetVars;
|
||||||
|
|
||||||
|
if (InternetGetConnectedState(&dwState, 0))
|
||||||
|
pushstring("online");
|
||||||
|
else
|
||||||
|
pushstring("offline");
|
||||||
|
}
|
||||||
|
|
||||||
|
NSISFunction(AutodialHangup) {
|
||||||
|
NSISGetVars;
|
||||||
|
if (InternetAutodialHangup(0))
|
||||||
|
pushstring("success");
|
||||||
|
else
|
||||||
|
pushstring("failure");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************\
|
||||||
|
* STOP LOOKING *
|
||||||
|
\****************/
|
||||||
|
|
||||||
|
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int popstring(char *str) {
|
||||||
|
stack_t *th;
|
||||||
|
if (!g_stacktop || !*g_stacktop) return 1;
|
||||||
|
th=(*g_stacktop);
|
||||||
|
lstrcpy(str,th->text);
|
||||||
|
*g_stacktop = th->next;
|
||||||
|
GlobalFree((HGLOBAL)th);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pushstring(char *str) {
|
||||||
|
stack_t *th;
|
||||||
|
if (!g_stacktop) return;
|
||||||
|
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
|
||||||
|
lstrcpyn(th->text,str,g_stringsize);
|
||||||
|
th->next=*g_stacktop;
|
||||||
|
*g_stacktop=th;
|
||||||
|
}
|
108
Contrib/Dialer/dialer.dsp
Normal file
108
Contrib/Dialer/dialer.dsp
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# Microsoft Developer Studio Project File - Name="dialer" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||||
|
|
||||||
|
CFG=dialer - Win32 Debug
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "dialer.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "dialer.mak" CFG="dialer - Win32 Debug"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "dialer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||||
|
!MESSAGE "dialer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP AllowPerConfigDependencies 0
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
MTL=midl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "dialer - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "dialer_EXPORTS" /YX /FD /c
|
||||||
|
# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "dialer_EXPORTS" /YX /FD /c
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wininet.lib /nologo /entry:"_DllMainCRTStartup" /dll /machine:I386 /nodefaultlib /out:"..\..\Plugins\Dialer.dll" /opt:nowin98
|
||||||
|
# SUBTRACT LINK32 /pdb:none
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "dialer - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "dialer_EXPORTS" /YX /FD /GZ /c
|
||||||
|
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "dialer_EXPORTS" /YX /FD /GZ /c
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "dialer - Win32 Release"
|
||||||
|
# Name "dialer - Win32 Debug"
|
||||||
|
# Begin Group "Source Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\dialer.c
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Resource Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
|
# End Group
|
||||||
|
# End Target
|
||||||
|
# End Project
|
29
Contrib/Dialer/dialer.dsw
Normal file
29
Contrib/Dialer/dialer.dsw
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||||
|
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "dialer"=.\dialer.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Global:
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<3>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
BIN
Plugins/Dialer.dll
Normal file
BIN
Plugins/Dialer.dll
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue