Commit Graph

58 Commits (f20062edd5e4d435ac966a1eed913e63c98df1b3)

Author SHA1 Message Date
Selva Nair d1756f068e Position tray tooltip above the taskbar
Use Shell_NotifyGetRect to find the icon location and place the
tip window a fixed distance above/below it.

It appears GUID_NULL used for above is not pulled in by shellapi.h.
Define locally when absent.

Also add TTF_RTLREADING for RTL languages. How to right justify
as well in this case is unclear.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2024-02-14 20:27:29 +05:30
Selva Nair 264d025bc6 Combine title and message in tray icon tip text
Also change scope of tip_msgi[] to local

Co-authored-by: Lev Stipakov <lstipakov@gmail.com>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
2024-02-14 20:27:29 +05:30
Selva Nair 0c9ae87e0f Use a custom tooltip window for the tray icon
Built-in tray notification icon has a tip text length limit of 128
characters which is often limited for showing the connected profile name,
connected since time and IP addresses. If the profile name is long the IP
numbers could get truncated.

Fix by using a custom tooltip window and display it when mouse hovers over
the icon. As the status bar need not be at the bottom of the screen (could be
at right, left or top as well), the location of the window is chosen based
on the mouse co-ordinates that trigger the hover event.

In case of errors while setting up the tooltip window, fall back to the current
behaviour.

If the message is too long to include time and IP, truncate the profile name
part of the message.

v2: Do not use wParam in NIN_POPUOPEN message as it does not seem to work
    on Windows 11. Instead use GetCursorPos() for mouse location.

Fixes issue #666

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2024-02-14 20:27:29 +05:30
Lev Stipakov 72a4bb84bf
Improve "OpenVPN GUI" tooltip handling (#649)
There is no point in localizing "OpenVPN GUI"
tray icon tooltip. Remove it from resources and
replace with PACKAGE_NAME define.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-08-31 11:13:13 -04:00
Frank Lichtenheld 2cb3c6e417 Reformat source code with uncrustify
Closes: #445

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-07-14 11:12:16 +02:00
Selva Nair 0bea5549f1 Remove private key password-change feature
- With this, dependence on OpenSSL is also gone. CI build
  tasks are updated accordingly.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2023-03-27 07:50:21 -07:00
Selva Nair f8a243fbe8 Remove tray icon during exit processing
During the wait for threads to exit,  we no longer sleep, but
continue pumping messages. Disable the tray icon during this
period to not allow user interaction with the main menu.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2023-02-26 19:59:38 -08:00
Lev Stipakov e923f2caa8 Fix broken menu functionality with single profile
To get connection for menu command, we use "dwMenuData" property
of a menu. With single connection profile we read "dwMenuData"
of a main menu, not a submenu. There has been a bug in code which hasn't
set "dwMenuData" for the main menu but it has worked until recently, since
this property stored index of connection array and index 0 has always
worked.

Since commit 94179911 ("Use a list instead of array for connections list")
we have switched to a linked list and store list pointer in dwMenuData.
However due to bug dwMenuData has always being 0, and logic which
fetches connections doesn't work:

        minfo.fMask = MIM_MENUDATA;
        GetMenuInfo((HMENU) lParam, &minfo);
        c  = (connection_t *) minfo.dwMenuData;
        if (!c)
            break; /* ignore invalid connection */

Fix by assigning main menu's dwMenuData to a head of connections list.

Fixes https://github.com/OpenVPN/openvpn-gui/issues/592

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-01-26 16:41:32 +01:00
Selva Nair 71c0a251bf Do not use assert as it can terminate LogonUI in PLAP use
- assert while on login screen is hard to get out of.

Only one of these occurrences is relevant for PLAP, but not using assert
at all looks a safer option.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2023-01-20 10:27:37 -08:00
Selva Nair 9417991168 Use a list instead of array for connections list
Currently we use an array of connection pointers which needs
to be reallocated when space runs out. But, that happens from
the main thread while the status thread may be referring to those
pointers. Its very hard to fence against possible invalid memory
access. Instead, use a list so that connection pointer never
changes once created.

The connection list is no longer recreated from scratch even when
no connections are active. This means configs added while GUI is
running will always appear at the bottom of the root group listing
until the GUI is restarted.

TODO: This behaviour could be improved by scanning through the groups to
graft new configs at the right branch in the config-group tree.

v2: removed unused references to SetMenuStatusById()

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2023-01-19 14:08:15 -08:00
Selva Nair 9d83f491d9 Always show persistent connections under a separate sub-menu
Since version 11.30, we scan config-auto folder and show them
in the menu of available connection profiles. To reduce user-confusion,
always group these configs under a submenu ("Persistent Connections")
even when nested config menu view is not in use.

ActivateConfigGroups() is now always called as Persistent and
System profile groups can now go from empty to non-empty
on rescan.

When nested config menu view is enabled, "persistent", "system"
and "user" configs are always shown in separate groups.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-12-12 14:45:57 -08:00
Selva Nair 7f794eec3d Add a button for detaching from the management interface
Useful for releasing the management interface if the user wants to
connect to it by other means.

Detached connections are set to state = detached (no disconnected)
and auto_connect disabled, so that they could be handled properly
during a re-attach.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Selva Nair 8f0dbbc8a3 Always check status of automatic service
- Remove service-only mode (start/stop service) which has not been in
  use since we moved to running the GUI as limited user.
  Also its not very useful as it does not allow any control of
  service-started daemons

- Keep CheckServiceStatus and always check the status of
automatic service.

The status of the service will be used to toggle supporting
control of persistent connections started by the service.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Selva Nair 428ee29246 Add support for marking connections as persistent
Persistent connections have openvpn.exe daemon started
external to the GUI (e.g., by the automatic service).
This patch adds support for attaching to the management
i/f of such daemons from the GUI and control the connection.

The GUI never stops or starts the openvpn.exe process in this
case. Instead, connect and disconnect buttons signal the
management interface of a running openvpn.exe process to start
the tunnel by attaching to mgmt i/f and sending hold-release if
needed  or stop it and wait in management-hold state
(see DisconnectDaemon()).

When the GUI process exits, persistent connections are left in their
current state using DetachOpenVPN().

No connections are marked as persistent as yet. That is done
in a following commit.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2022-08-08 10:11:25 -04:00
Lev Stipakov a9f176224f Fix crash when clicking on tray icon after importing the first profile
When clicking on tray icon, menu items are deleted and then recreated.
Deletion uses o.num_config:

    for (i = 0; i < o.num_configs; i++)
        DestroyMenu(hMenuConn[i]);

Commit 8e4183f9 ("Add '--command import' command line option")
added BuildFileList() call which modifies o.num_configs
but doesn't touch menus. When clicking on tray icon after import,
abovementioned code attemps to access invalid item in hMenuConn array
and crashes when this is the first imported profile and hMenuConn is NULL.
In other DestryMenu is called with invalid argument.

Fix by recreating popup menus instead of just rescan file list -
this will first delete menus with correct o.num_config value.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-11-12 10:07:17 -05:00
Selva Nair 56ee704501 Use C standrad compliant printf specifications
%S --> %hs in wide format strings, %ls otherwise
%s --> %ls in wide format strings, unchanged otherwise
%c --> %lc in wide format strings

Resource files together have about 970 lines affected and
were edited by looping through all with
sed -i 's/%S/%hs/g' $file
sed -i 's/%s/%ls/g' $file
All other files were manually changed (about 85 lines).

Recent versions of mingw-w64 implicitly turns on __USE_MINGW_ANSI_STDIO
if _GNU_SOURCE, _XOPEN_SOURCE etc are defined (which we do usei).

This breaks non-standard spec such as %S. Anyway, we have been
gradually getting rid of those.

MSVC builds should not be affected.

v2: multiple occurrences in same line was missed in v1 (/g missing in
sed expression). Fixed.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-11-03 16:20:17 -04:00
Selva Nair e80a39c825 Implement importing profile from a generic URL
ParseUrl extended to parse generic URLs and parse
the path. DownloadProfile() function re-factored
for reuse with generic URL.

Also:
- INTERNET_FLAG_RELOAD added to the request
  call to force reloading the data from server instead
  of using possibly cached data.
- Input box for URL extended in length to about
   50 characters wide.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-08-31 21:55:59 -04:00
Lev Stipakov d6a622a023 URL profile import: allow specifying owner window of message box
This will be used later when parent window
needs to be disabled when message box is displayed.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-08-23 12:07:18 -04:00
Lev Stipakov 9ded7996ab URL profile import: add profile import dialog
This is the first patch from series which implemets
importing profile from URL, currently implemented
by OpenVPN Access Server.

Move "Import from file" menu item under new "Import"
item. Add "Import from AS..." item under "Import", which
opens new profile import dialog.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-08-23 12:07:18 -04:00
Selva Nair e14287e93e Apply transparency mask to the connecting-state checkmark image
Use the image in the connecting state icon with background
color replaced by that of the menu for use as the checkmark.

MSDN docs on SetMenuItemBitmaps is unclear about the use of
color bitmaps for checkmarks, but this appears to display well.
(Tested on Windows 10 only).

The bitmap is recreated everytime the popup menus are made
although its sufficient to recreate it when system colours
change.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-06-02 00:48:41 -04:00
Selva Nair c47c3bf81a Remove MAX_CONFIGS limit using WM_MENUCOMMAND for menu messages
We currently use WM_COMMAND message which is delivered with the
ID of the menu item requiring a unique ID for every command
(connect, disconnect etc..) for each connection profile. Instead,
use WM_MENUCOMMAND so that the message delivers a handle to the
menu and the position index of the menu item.

Connection menu array is now dynamically allocated. Yet, there
is still a limitation on the number of configs as the config
index + mgmt_port_offset must be < 65536 to be usable as a port
number. The error message shown for "too many configs" is reworded.
(English language file only).

Note: The current way of selecting the management port based on the
index of the config file increases chances of port conflicts
when the number of configs is large. It could be useful to change
this logic but that is beyond the cope of this PR.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-03-05 22:16:08 -05:00
Selva Nair 70b07c82d9 Show a mark against profiles that are in connecting state
Currently we show a check mark on connected profiles with no
indication on profiles that may be in the connecting state.

Change this by adding a mark against connecting/reconnecting
profiles. The yellow connecting state icon is used to generate
this mark although a custom designed check mark may look better.

In case of nested configs, the parent menus are marked with a tick
mark and only the profile is marked with the connecting icon.

No change in behaviour for profiles that are connected or
disconnected.

Trac #1241

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2021-01-02 12:35:48 -05:00
Selva Nair bcdda39660 Open all active status windows on left-double-click
Currently we pop up the status window on double click only
if one connection is active though there is no strong reason to
limit this behaviour. In fact, when multiple connections are
stuck in the connecting state, its very useful to have a quick
way to examine their progress instead of having to drill down
the menu. Especially so when nested menu is in use.

A random variation of up to 100 pixel is added to the initial
position of the status window to avoid all windows falling on
top of each other.

To prevent an explosion of new windows in the very unlikely event
of numerous active connections, restrict the maximum windows
shown to 10.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2020-12-30 13:07:34 -05:00
Selva Nair 9ad57eb415 Add '--command rescan' to rescan config folders
Add an new command 'rescan' that may be sent to a running
instance of the GUI to force it rescan the config folders.

Use case: with an instance of the is GUI running, one can
manually copy a config file to the config folder and start
it using "openvpn-gui --command rescan" followed by
"openvpn-gui --command connect foo"

v2: The calls to rebuild config file list and recreate
menus is refactored into a function.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2020-01-12 16:32:51 -05:00
Selva Nair 7bfb950852 Bug fix config-group data structure
As config group is reallocated when full, do not store the pointer to the
parent group. Instead use the id of the group which is invariant across
reallocs. Similarly in connection array store the id of the group
instead of a pointer.

Also

- Do not call ActivateConfigGroups() -- when connections are active:
  in this case we want preserve config data structures during rescan.

Signed-off-by: Selva Nair <selva.nair@gmail.com>

fixup
2019-02-11 11:51:23 -05:00
Selva Nair 2d64cb5603 Provide support for a hierarchical config menu listing
- Shows all configs in a subdirectory grouped into a
  submenu entry. This hopefully provided a better UX when
  there are more than a few 10's of config files.

- Enabled only if number of configs is > 50 or if the
  option config_menu_view is set to 2.
  To force the current flat listing, set config_menu_view = 1.

TODO: Make config_menu_view user configurable.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2019-02-11 11:51:23 -05:00
Selva Nair b53c8a758e Fix display of assigned IPs when IPv4 address is absent
- In tray info do not skip the address when v4 ip is absent

- When combining two strings do not add the separator (comma)
  if either is empty.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-06-16 16:29:52 -04:00
Selva Nair dd8c4dfdab Show assigned ipv6 address in balloon and tray popup
Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-01-29 09:40:36 +02:00
Selva Nair 31896ce33b Add restart button to connection menus
- This works the same way as restart button in the status window
  but is more conveniently accessible from the tray menu.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2018-01-20 11:41:19 -05:00
Selva Nair 2f2ddbf3a8 Load icons at sizes given by DPI-dependent system metric
- Check system metric for large and small icon sizes and
  try to load the correct size instaed of scaling from one size.

Scaling will still happen if the required size is not available
in the icon resource. As we add more icon sizes they will
get automatically used as needed.

LoadImage scales up from next smallest size available. Revisit this
when LoadIconWithScaleDown (Vista+) becomes available in mingw.

Resolves Trac: #772 (icon scaling issue)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-12-08 16:01:58 -05:00
Selva Nair 1a5ce44a99 Handle dynamic challenge/response
- Add a base64 decode function using Windows CyptoAPI
- Move multibyte to widechar conversions to a function
- Add config name to caption of password dialogs to help user
  identify the request
- Add new dialog template for generic password/PIN requests
  and use it to handle dynamic challenge

Note 1: if dynamic challenge response verification fails, an auth-failed
message is returned by the server causing the GUI to clear any saved
password even if the user-auth dialog itself succeeeded.

Note 2: Dialog template ID_DLG_CHALLENGE_RESPONSE added to language
files may require translation.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-11-15 19:14:32 -05:00
Selva Nair 5a47986ccb Make options saved in registry editable by user
Option ediitng dialogs are in two tabs: General and Advanced.
Proxy related options are left in the proxy tab. Options
config_dir, config_ext, log_dir, script timeouts and
service-only flag are in the Advanced tab. All other more commonly
used flags and options are in the General tab.

- As options are editable, save values in registry only when they differ
  from the default values. This leaves the registry clean and makes changing
  options and their defaults during updates easier.

- Entries for config_dir and log_dir must be absolute paths.
  Environemental variables such as %PROFILEDIR% may be used
  to construct these.

- Empty config_dir, config_ext and log_dir entries are silently
  ignored (i.e., the current values are left unchanged).

- Store all numeric and boolean parameters in registry as DWORD instead of
  strings.

- On startup, the default parameters are loaded, then the registry is read
  and finally command-line parameters parsedi.

- Out of range script timeout values in registry truncated with a
  warning instead of fatal error. This allows the user to access the
  settings dialog and make corrections.

- Save proxy and language settings under the same
  HKCU\Software\OpenVPN-GUI key as other options instead of under Nilings.

- Save the current version of the GUI in regsitry so that updates
  can be detected and any needed registry cleanup done.

- If no version info is present in the registry any values in OpenVPN-GUI
  key in HKCU are deleted for a clean start as this is the first version
  to save registry values in HKCU. Language and proxy data if present
  under Nilings is migrated.

Note: new controls in the General tab and newly added Advanced tab dialog
are copied to all language files from the English version. These need to
be translated.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-08-06 11:46:15 -04:00
Selva Nair 1c748e382d Simplify some parameters and registry keys
- Replace allow_password by a runtime check that enables password
  change menu only when the user has write-access to the key file.
- Read exe_path and priority from HKLM and do not duplicate in HKCU.
- Always allow the user to view the config: edit will succeed if user
  has write access.
- Always include the proxy settings tab which is the default.
- Remove the unused power event handling and disconnect_on_suspend key.
- Remove password_attempts -- user can stop the password dilaog
  by clicking cancel.
- Remove allow_service: implicitly enabled if service_only is used.
- Deprecate removed options in cmd-line parser
- Update README.rst
- Close config file before exit in GetKeyFileName
- Close thread and dialog handles in passphrase.c

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-08-06 11:46:15 -04:00
Selva Nair 5880fdcd02 Save username and optionally passwords
- Username and, optionally, password as well as the private
  key passphrase are saved in config-specific registry keys
- All saved data are kept encrypted using DPAPI
- The passphrase dialog is skipped if a valid saved private
  key password is available. However, the user-auth dialog
  is always presented, prefilled with the saved username
  and password.

Note: A text string "Save password" is added to three dialogs
in all language resource files. Additional text with ids
IDS_MENU_CLEARPASS and IDS_NFO_DELETE_PASS are added to the
STRINGTABLE only in the English language resource file.
All these need translations.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-05-29 19:35:30 -04:00
Selva Nair 284a4e27e3 Rescan configs even when connections are active
Signed-off-by: Selva Nair <selva.nair@gmail.com>
2016-05-22 15:41:23 -04:00
Leonardo Basilio 46a1bc715c Adding "Import file" feature 2016-02-16 22:23:23 -02:00
Heiko Hund 47cff87477 make auth popups show when returning from suspend 2013-04-25 17:53:16 +02:00
Heiko Hund 2e53dbd254 localize connection time display in tray tooltip 2012-11-06 14:54:53 +01:00
Heiko Hund 82eb645a5e localize buttons in message boxes when possible 2012-07-20 17:44:48 +02:00
Heiko Hund f420d7dcbb use CRT's _countof instead of proprietary _tsizeof 2012-03-29 17:40:34 +02:00
Alon Bar-Lev c9eb68c77f use automake in build
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>

Edited to not use libtool and implicit automake rule to build resource object
2012-03-28 10:59:44 +00:00
Heiko Hund 66b77868b4 move "About" dialog to settings tab 2011-11-30 17:20:23 +01:00
Heiko Hund 4683e8f045 fix popup menu creation 2011-07-26 09:12:11 +02:00
Heiko Hund ed5dfc0bd5 fix IP address display in tooltip, closes #3176526 2011-02-11 11:03:57 +01:00
Heiko Hund a91198d010 fix connection status if only one config exists 2010-09-10 11:40:03 +02:00
Heiko Hund efc62c3d19 fix starting a connection with double click on icon 2010-09-10 11:40:02 +02:00
Heiko Hund 4bcebba60f use managment interface 2010-09-10 11:39:39 +02:00
Heiko Hund 0d04b8b981 produce dist as tarball
* make dist produces a tarball instead of a .zip now
 * removed local copy of shellapi.h
 * snapshot version is now the current date and time
 * snapshot version is now part of the .exe name
2010-04-23 14:18:36 +02:00
Heiko Hund f373ca17f7 tray code cleanup and fixes
* make tray icon reflect connection status again
 * prevent tray context menu popup on right click
 * display proxy settings tab only if enabled
2010-04-23 13:22:05 +02:00
Heiko Hund a6e6d88115 refactor option handling code 2010-04-09 06:18:58 +02:00