| 108 | } |
| 109 | |
| 110 | static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 111 | { |
| 112 | static UINT s_uTaskbarRestart; |
| 113 | |
| 114 | switch (uMsg) |
| 115 | { |
| 116 | case WM_CREATE: |
| 117 | { |
| 118 | s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); |
| 119 | AddTrayIcon (hWnd, true); |
| 120 | break; |
| 121 | } |
| 122 | case WM_CLOSE: |
| 123 | { |
| 124 | RemoveTrayIcon (hWnd); |
| 125 | KillTimer (hWnd, FRAME_UPDATE_TIMER); |
| 126 | KillTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER); |
| 127 | KillTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER); |
| 128 | PostQuitMessage (0); |
| 129 | break; |
| 130 | } |
| 131 | case WM_COMMAND: |
| 132 | { |
| 133 | switch (LOWORD(wParam)) |
| 134 | { |
| 135 | case ID_ABOUT: |
| 136 | { |
| 137 | std::stringstream text; |
| 138 | text << "Version: " << I2PD_VERSION << " " << CODENAME; |
| 139 | MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); |
| 140 | return 0; |
| 141 | } |
| 142 | case ID_EXIT: |
| 143 | { |
| 144 | PostMessage (hWnd, WM_CLOSE, 0, 0); |
| 145 | return 0; |
| 146 | } |
| 147 | case ID_ACCEPT_TRANSIT: |
| 148 | { |
| 149 | i2p::context.SetAcceptsTunnels (true); |
| 150 | std::stringstream text; |
| 151 | text << "I2Pd now accept transit tunnels"; |
| 152 | MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); |
| 153 | return 0; |
| 154 | } |
| 155 | case ID_DECLINE_TRANSIT: |
| 156 | { |
| 157 | i2p::context.SetAcceptsTunnels (false); |
| 158 | std::stringstream text; |
| 159 | text << "I2Pd now decline new transit tunnels"; |
| 160 | MessageBox( hWnd, TEXT(text.str ().c_str ()), TEXT("i2pd"), MB_ICONINFORMATION | MB_OK ); |
| 161 | return 0; |
| 162 | } |
| 163 | case ID_GRACEFUL_SHUTDOWN: |
| 164 | { |
| 165 | i2p::context.SetAcceptsTunnels (false); |
| 166 | SetTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER, 10*60*1000, nullptr); // 10 minutes |
| 167 | SetTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER, 1000, nullptr); // check tunnels every second |
nothing calls this directly
no test coverage detected