Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / client_creds / trayicon.cpp
blob105992db0e9d2c3e001a86c35a32399eda0e59a3
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
18 #include "afscreds.h"
23 * ROUTINES ___________________________________________________________________
27 void ChangeTrayIcon (int nim)
29 static BOOL fAdded = FALSE;
30 static BOOL fDeleted = FALSE;
31 if ((nim == NIM_MODIFY) && (!fAdded))
32 nim = NIM_ADD;
33 if ((nim == NIM_MODIFY) && (fDeleted))
34 return;
36 if ((nim != NIM_DELETE) || (IsWindow (g.hMain)))
38 static HICON ICON_CREDS_YES = TaLocale_LoadIcon (IDI_CREDS_YES);
39 static HICON ICON_CREDS_NO = TaLocale_LoadIcon (IDI_CREDS_NO);
41 size_t iExpired = Main_FindExpiredCreds();
43 NOTIFYICONDATA nid;
44 memset (&nid, 0x00, sizeof(NOTIFYICONDATA));
45 nid.cbSize = sizeof(NOTIFYICONDATA);
46 nid.hWnd = g.hMain;
47 nid.uID = 0;
48 nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
49 nid.uCallbackMessage = WM_TRAYICON;
50 lock_ObtainMutex(&g.credsLock);
51 nid.hIcon = ((g.cCreds != 0) && (iExpired == (size_t)-1)) ? ICON_CREDS_YES : ICON_CREDS_NO;
52 lock_ReleaseMutex(&g.credsLock);
53 GetString (nid.szTip, (g.fIsWinNT) ? IDS_TOOLTIP : IDS_TOOLTIP_95);
54 Shell_NotifyIcon (nim, &nid);
57 if (nim == NIM_ADD)
58 fAdded = TRUE;
59 if (nim == NIM_DELETE)
60 fDeleted = TRUE;