WarDaemonLib.cpp
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:4k
源码类别:

Ftp客户端

开发平台:

Visual C++

  1. // This is part of the WAR SOFTWARE SERIES initiated by Jarle Aase
  2. // Copyright 1996 by Jarle Aase. All rights reserved.
  3. // See the "War Software Series Licende Agreement" for details concerning 
  4. // use and distribution.
  5. // ---
  6. // This source code, executables and programs containing source code or
  7. // binaries or proprietetary technology from the War Software Series are
  8. // NOT alloed used, viewed or tested by any governmental agencies in
  9. // any countries. This includes the government, departments, police, 
  10. // military etc.
  11. // ---
  12. // This file is intended for use with Tab space = 2
  13. // Created and maintained in MSVC Developer Studio
  14. // ---
  15. // NAME : WarDaemonLib.cpp
  16. // PURPOSE : General Daemon dll
  17. // PROGRAM : 
  18. // DATE : Sept. 19 1996
  19. // AUTHOR : Jarle Aase
  20. // ---
  21. // REVISION HISTORY
  22. // 
  23. #include "stdafx.h"
  24. #include "WarDaemon.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. #include <afxdllx.h>
  31. static AFX_EXTENSION_MODULE WarDaemonLibDLL = { NULL, NULL };
  32. extern "C" int APIENTRY
  33. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  34. {
  35. if (dwReason == DLL_PROCESS_ATTACH)
  36. {
  37. TRACE0("WARDAEMONLIB.DLL Initializing!n");
  38. // Extension DLL one-time initialization
  39. AfxInitExtensionModule(WarDaemonLibDLL, hInstance);
  40. // Insert this DLL into the resource chain
  41. //new CDynLinkLibrary(WarDaemonLibDLL);
  42. }
  43. else if (dwReason == DLL_PROCESS_DETACH)
  44. {
  45. TRACE0("WARDAEMONLIB.DLL Terminating!n");
  46. }
  47. return 1;   // ok
  48. }
  49. // Exported DLL initialization is run in context of running application
  50. extern "C" void WINAPI InitWarDaemonLibDLL()
  51. {
  52. // create a new CDynLinkLibrary for this app
  53. new CDynLinkLibrary(WarDaemonLibDLL);
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CNotificationWnd implementation
  57. CWnd *CDaemonNotificationWnd::m_pWnd = NULL;
  58. CWinThread *CDaemonNotificationWnd::m_pThread = NULL;
  59. CDaemonNotificationWnd::CDaemonNotificationWnd()
  60. {
  61. m_pWnd = this;
  62. m_pThread = AfxGetThread();
  63. }
  64. CDaemonNotificationWnd::~CDaemonNotificationWnd()
  65. {
  66. m_pWnd = NULL;
  67. m_pThread = NULL;
  68. }
  69. LRESULT CDaemonNotificationWnd::OnDNS(WPARAM WParam, LPARAM LParam)
  70. {
  71. CDNSLookup::DNSlookupCallback(WParam, LParam);
  72. return TRUE;
  73. }
  74. LONG CDaemonNotificationWnd::OnTrayIconMessage(WPARAM WParam, LPARAM LParam)
  75. {
  76. if (CDaemonBase::m_pDaemonBase)
  77. CDaemonBase::m_pDaemonBase->OnTrayIconMessage(WParam, LParam);
  78. return FALSE;
  79. }
  80. void CDaemonNotificationWnd::OnStopandquit()
  81. {
  82. if (CDaemonBase::m_pDaemonBase)
  83. CDaemonBase:: m_pDaemonBase->Shutdown(TRUE, TRUE, FALSE);
  84. }
  85. void CDaemonNotificationWnd::OnGoOnline()
  86. {
  87. if (CDaemonBase::m_pDaemonBase)
  88. CDaemonBase:: m_pDaemonBase->GoOnline(TRUE);
  89. }
  90. void CDaemonNotificationWnd::OnGoOffline()
  91. {
  92. if (CDaemonBase::m_pDaemonBase)
  93. CDaemonBase:: m_pDaemonBase->GoOnline(FALSE);
  94. }
  95. void CDaemonNotificationWnd::OnRestart()
  96. {
  97. if (CDaemonBase::m_pDaemonBase)
  98. {
  99. extern DLL_WAR_DAEMON_ BOOL g_DoRestart;
  100. g_DoRestart = TRUE;
  101. CDaemonBase:: m_pDaemonBase->Shutdown(TRUE, TRUE, FALSE);
  102. }
  103. }
  104. void CDaemonNotificationWnd::OnStartManager()
  105. {
  106. if (CDaemonBase::m_pDaemonBase)
  107. CDaemonBase:: m_pDaemonBase->StartManager();
  108. }
  109. /////////////////////////////////////////////////////////////////////////////
  110. // Message table implementation
  111. BEGIN_MESSAGE_MAP(CDaemonNotificationWnd, CWnd)
  112. //{{AFX_MSG_MAP(CWnd)
  113. ON_MESSAGE(WMU_SNM,OnTrayIconMessage)
  114. ON_COMMAND(ID_MENU_STOPANDQUIT, OnStopandquit)
  115. ON_MESSAGE(WMU_TX_DNS, OnDNS)
  116. ON_COMMAND(ID_MENU_GOONLINE, OnGoOnline)
  117. ON_COMMAND(ID_MENU_GOOFFLINE, OnGoOffline)
  118. ON_COMMAND(ID_MENU_RESTART, OnRestart)
  119. ON_COMMAND(ID_MENU_OPENMANAGER, OnStartManager)
  120. //}}AFX_MSG_MAP
  121. END_MESSAGE_MAP()