示例#1
0
void ChangeTrayIcon (int nim)
{
   static BOOL fAdded = FALSE;
   static BOOL fDeleted = FALSE;
   if ((nim == NIM_MODIFY) && (!fAdded))
      nim = NIM_ADD;
   if ((nim == NIM_MODIFY) && (fDeleted))
      return;

   if ((nim != NIM_DELETE) || (IsWindow (g.hMain)))
      {
      static HICON ICON_CREDS_YES = TaLocale_LoadIcon (IDI_CREDS_YES);
      static HICON ICON_CREDS_NO  = TaLocale_LoadIcon (IDI_CREDS_NO);

      size_t iExpired = Main_FindExpiredCreds();

      NOTIFYICONDATA nid;
      memset (&nid, 0x00, sizeof(NOTIFYICONDATA));
      nid.cbSize = sizeof(NOTIFYICONDATA);
      nid.hWnd = g.hMain;
      nid.uID = 0;
      nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
      nid.uCallbackMessage = WM_TRAYICON;
      lock_ObtainMutex(&g.credsLock);
      nid.hIcon = ((g.cCreds != 0) && (iExpired == (size_t)-1)) ? ICON_CREDS_YES : ICON_CREDS_NO;
      lock_ReleaseMutex(&g.credsLock);
      GetString (nid.szTip, (g.fIsWinNT) ? IDS_TOOLTIP : IDS_TOOLTIP_95);
      Shell_NotifyIcon (nim, &nid);
      }

   if (nim == NIM_ADD)
      fAdded = TRUE;
   if (nim == NIM_DELETE)
      fDeleted = TRUE;
}
示例#2
0
void Main_OnRemindTimer (void)
{
   Main_RepopulateTabs (TRUE);

   // See if anything is close to expiring; if so, display a warning
   // dialog. Make sure we never display a warning more than once.
   //
   size_t iExpired;
   if ((iExpired = Main_FindExpiredCreds()) != -1) {
       if (InterlockedIncrement (&g.fShowingMessage) != 1) {
           InterlockedDecrement (&g.fShowingMessage);
       } else { 
           char * rootcell = NULL;
           char   password[PROBE_PASSWORD_LEN+1];
           struct afsconf_cell cellconfig;
           BOOL   serverReachable = FALSE;
           DWORD  code;

           rootcell = (char *)GlobalAlloc(GPTR,MAXCELLCHARS+1);
           if (!rootcell) 
               goto cleanup;

           code = KFW_AFS_get_cellconfig(g.aCreds[ iExpired ].szCell, 
                                         (afsconf_cell*)&cellconfig, rootcell);
           if (code) 
               goto cleanup;

           if (KFW_is_available()) {
               // If we can't use the FSProbe interface we can attempt to forge
               // a kinit and if we can back an invalid user error we know the
               // kdc is at least reachable
               serverReachable = KFW_probe_kdc(&cellconfig);
           } else {
               int i;

               for ( i=0 ; i<PROBE_PASSWORD_LEN ; i++ )
                   password[i] = 'x';

               code = ObtainNewCredentials(rootcell, PROBE_USERNAME, password, TRUE);
               switch ( code ) {
               case INTK_BADPW:
               case KERB_ERR_PRINCIPAL_UNKNOWN:
               case KERB_ERR_SERVICE_EXP:
               case RD_AP_TIME:
                   serverReachable = TRUE;
                   break;
               default:
                   serverReachable = FALSE;
               }
           }
         cleanup:
           if (rootcell)
               GlobalFree(rootcell);

           if (serverReachable)
               ShowObtainCreds (TRUE, g.aCreds[ iExpired ].szCell);
           else
               InterlockedDecrement (&g.fShowingMessage);
       }
   }
}