Exemplo n.º 1
0
extern "C" int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdShow)
{
   Shortcut_Init();
   TaLocale_LoadCorrespondingModule (hInst);

   osi_InitTraceOption();
   osi_LogEvent0("AFSCreds Main command line",pCmdLine);
   fs_utils_InitMountRoot();


   if (InitApp (pCmdLine))
      {
      MSG msg;
      while (GetMessage (&msg, NULL, 0, 0) > 0)
         {
         PumpMessage (&msg);
         }

      ExitApp();
      }

   Shortcut_Exit();
   return 0;
}
Exemplo n.º 2
0
BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow)
{
   TaLocale_LoadCorrespondingModule (hInst);

   memset (&g, 0x00, sizeof(g));
   g.hInst = hInst;
   g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN);

   HWND hPrevious;
   TCHAR szTitle[ cchRESOURCE ];
   GetString (szTitle, IDS_APP_TITLE);
   if ((hPrevious = FindWindow (TEXT("AFSAccountManagerClass"), szTitle)) != NULL)
      {
      SetFocus (hPrevious);
      SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0);
      return FALSE;
      }

   AfsAppLib_SetAppName(szTitle);
   AfsAppLib_SetPumpRoutine(PumpMessage);

   TASKQUEUE_PARAMS tqp;
   memset (&tqp, 0x00, sizeof(tqp));
   tqp.nThreadsMax = 10;
   tqp.fnCreateTaskPacket = CreateTaskPacket;
   tqp.fnPerformTask = PerformTask;
   tqp.fnFreeTaskPacket = FreeTaskPacket;
   AfsAppLib_InitTaskQueue (&tqp);

   Main_ConfigureHelp();

   // Determine how the app is supposed to look--that is, remember what it
   // looked like last time, and if there was no "last time", pick some
   // decent defaults.
   //
   if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED))
      {
      memset (&gr, 0x00, sizeof(gr));
      SetRectEmpty (&gr.rMain);
      gr.cminRefreshRate = 60; // 1 hour default refresh rate

      User_SetDefaultCreateParams (&gr.CreateUser);
      Group_SetDefaultCreateParams (&gr.CreateGroup);
      Machine_SetDefaultCreateParams (&gr.CreateMachine);
      Actions_SetDefaultView (&gr.viewAct);
      User_SetDefaultView (&gr.viewUsr, &gr.ivUsr);
      Group_SetDefaultView (&gr.viewGrp, &gr.ivGrp);
      Machine_SetDefaultView (&gr.viewMch, &gr.ivMch);
      Users_SetDefaultSearchParams (&gr.SearchUsers);
      }

   // Create a variation on WC_DIALOG, so we get appropriate icons on
   // our windows.
   //
   WNDCLASS wc;
   GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc);
   wc.hInstance = THIS_HINST;
   wc.hIcon = TaLocale_LoadIcon (IDI_MAIN);
   wc.lpszClassName = TEXT("AFSAccountManagerClass");
   wc.style |= CS_GLOBALCLASS;
   RegisterClass (&wc);

   // Okay, the big step: create the main window.  Note that it doesn't
   // get shown yet!
   //
   CMDLINEOP op = ParseCommandLine (pszCmdLine);
   if (op == opCLOSEAPP)
      return FALSE;

   // Okay, the big step: create the main window.
   // Note that it doesn't get shown yet!
   //
   g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc);
   if (g.hMain == NULL)
      return FALSE;

   if (op != opNOCELLDIALOG)
      {
      if (OpenCellDialog() != IDOK)
         return FALSE;
      }

   return TRUE;
}
Exemplo n.º 3
0
/*
 * EXPORTED FUNCTIONS _________________________________________________________
 *
 */
extern "C" LONG APIENTRY CPlApplet(HWND hwndCPl, UINT uMsg, LONG lParam1, LONG lParam2)
{
    int i;
    LPNEWCPLINFO lpNewCPlInfo;
	HICON hIcon;
	static char szAppName[64];
	static char szAppPath[MAX_PATH];


    i = (int)lParam1;

    switch (uMsg) {
        case CPL_INIT:      /* first message, sent once  */
            hinst = GetModuleHandle("afsserver.cpl");
            hinstResources = TaLocale_LoadCorrespondingModule (hinst);
			strcpy(szAppName, LoadResString(IDS_APP_NAME));
			sprintf(szAppPath, "%s%s", GetInstallDir(), APP_EXE_PATH);
			return (hinst != 0);

        case CPL_GETCOUNT:  /* second message, sent once */
            return 1;
            break;

        case CPL_NEWINQUIRE: /* third message, sent once per app */
            lpNewCPlInfo = (LPNEWCPLINFO) lParam2;

            lpNewCPlInfo->dwSize = (DWORD) sizeof(NEWCPLINFO);
            lpNewCPlInfo->dwFlags = 0;
            lpNewCPlInfo->dwHelpContext = 0;
            lpNewCPlInfo->lData = 0;
            hIcon = TaLocale_LoadIcon(IDI_AFSD);
			if (hIcon == 0)
				MessageBox(0, LoadResString(IDS_ERROR_LOADING_ICON), szAppName, MB_ICONEXCLAMATION);
			lpNewCPlInfo->hIcon = hIcon;
            lpNewCPlInfo->szHelpFile[0] = '\0';
			strcpy(lpNewCPlInfo->szName, szAppName);
			strcpy(lpNewCPlInfo->szInfo, LoadResString(IDS_CPA_TITLE));
            break;

        case CPL_SELECT:		/* applet icon selected */
            break;

        case CPL_DBLCLK:		/* applet icon double-clicked */
			if (WinExec(szAppPath, SW_SHOW) < 32)
				MessageBox(0, LoadResString(IDS_EXECUTION_ERROR), szAppName, MB_ICONSTOP);
            break;

        case CPL_STOP:      /* sent once per app. before CPL_EXIT */
            break;

        case CPL_EXIT:    /* sent once before FreeLibrary called */
            if (hinstResources)
                FreeLibrary (hinstResources);
            break;

        default:
            break;
    }

    return 0;
}
Exemplo n.º 4
0
BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow)
{
   TaLocale_LoadCorrespondingModule (hInst);

   memset (&g, 0x00, sizeof(g));
   g.hInst = hInst;
   g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN);

   HWND hPrevious;
   TCHAR szTitle[ cchRESOURCE ];
   GetString (szTitle, IDS_APP_TITLE);
   if ((hPrevious = FindWindow (TEXT("AFSManagerClass"), szTitle)) != NULL)
      {
      SetFocus (hPrevious);
      SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0);
      return FALSE;
      }

   AfsAppLib_SetAppName(szTitle);
   AfsAppLib_SetPumpRoutine(PumpMessage);

   TASKQUEUE_PARAMS tqp;
   memset (&tqp, 0x00, sizeof(tqp));
   tqp.nThreadsMax = 10;
   tqp.fnCreateTaskPacket = CreateTaskPacket;
   tqp.fnPerformTask = PerformTask;
   tqp.fnFreeTaskPacket = FreeTaskPacket;
   AfsAppLib_InitTaskQueue (&tqp);

   Main_ConfigureHelp();

   // Determine how the app is supposed to look--that is, remember what it
   // looked like last time, and if there was no "last time", pick some
   // decent defaults.
   //
   if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED))
      {
      memset (&gr, 0x00, sizeof(gr));
      SetRectEmpty (&gr.rMain);
      SetRectEmpty (&gr.rMainPreview);
      SetRectEmpty (&gr.rServerLast);
      SetRectEmpty (&gr.rViewLog);
      SetRectEmpty (&gr.rActions);

      gr.fPreview = TRUE;
      gr.fVert = TRUE;
      gr.fActions = FALSE;

      gr.tabLast = tabFILESETS;

      Server_SetDefaultView_Horz (&gr.diHorz.viewSvr);
      Server_SetDefaultView_Vert (&gr.diVert.viewSvr);
      Services_SetDefaultView (&gr.viewSvc);
      Aggregates_SetDefaultView (&gr.viewAgg);
      Filesets_SetDefaultView (&gr.viewSet);
      Replicas_SetDefaultView (&gr.viewRep);
      Action_SetDefaultView (&gr.viewAct);
      Server_Key_SetDefaultView (&gr.viewKey);

      gr.diHorz.cSplitter = -100;
      gr.diVert.cSplitter = -89;

      gr.cbQuotaUnits = cb1KB;

      gr.fOpenMonitors = TRUE;
      gr.fCloseUnmonitors = TRUE;
      gr.fServerLongNames = FALSE;
      gr.fDoubleClickOpens = 2;
      gr.fWarnBadCreds = TRUE;

      gr.ivSvr = ivSTATUS;
      gr.ivAgg = ivSTATUS;
      gr.ivSet = ivSTATUS;
      gr.ivSvc = ivSTATUS;
      }

   ULONG status;
   if (!AfsClass_Initialize (&status))
      {
      if (status == ADMCLIENTCANTINITAFSLOCATION)
         ImmediateErrorDialog (status, IDS_ERROR_CANT_INIT_AFSCLASS_INSTALL);
      else
         ImmediateErrorDialog (status, IDS_ERROR_CANT_INIT_AFSCLASS_UNKNOWN);
      return FALSE;
      }

   AfsClass_RequestLongServerNames (gr.fServerLongNames);
   AfsClass_SpecifyRefreshDomain (AFSCLASS_WANT_VOLUMES);

   // Create a notification object for the AFSClass library, so that it can
   // let us know when anything changes.  The notification handler we'll
   // install will take requests from the rest of the SVRMGR package and
   // forward notifications around to whichever windows are actually
   // interested.
   //
   CreateNotificationDispatch();

   // Create a few variations on WC_DIALOG, so we get appropriate icons on
   // our windows.
   //
   WNDCLASS wc;
   GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc);
   wc.hInstance = THIS_HINST;
   wc.hIcon = TaLocale_LoadIcon (IDI_MAIN);
   wc.lpszClassName = TEXT("AFSManagerClass");
   wc.style |= CS_GLOBALCLASS;
   RegisterClass (&wc);

   GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc);
   wc.hInstance = THIS_HINST;
   wc.hIcon = TaLocale_LoadIcon (IDI_SERVER);
   wc.lpszClassName = TEXT("ServerWindowClass");
   wc.style |= CS_GLOBALCLASS;
   RegisterClass (&wc);

   // Okay, the big step: create the main window (ie, the servers list).
   // Note that it doesn't get shown yet!
   //
   CMDLINEOP op = ParseCommandLine (pszCmdLine);
   if (op == opCLOSEAPP)
      return FALSE;

   if (op == opLOOKUPERRORCODE)
      {
      Help_FindError();
      return FALSE;
      }

   g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc);
   if (g.hMain == NULL)
      return FALSE;

   if (op != opNOCELLDIALOG)
      {
      if (OpenCellDialog() != IDOK)
         return FALSE;
      }

   return TRUE;
}
Exemplo n.º 5
0
extern "C" LONG APIENTRY CPlApplet(HWND hwndCPl, UINT uMsg, LONG lParam1, LONG lParam2)
{
    LPNEWCPLINFO lpNewCPlInfo;
    LPCPLINFO lpCPlInfo;
    SHELLEXECUTEINFO shellExecInfo;

    switch (uMsg) {
        case CPL_INIT:      /* first message, sent once  */
            hinst = GetModuleHandle("afs_cpa.cpl");
            hinstResources = TaLocale_LoadCorrespondingModule (hinst);
            CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
            return (hinst != 0);

        case CPL_GETCOUNT:  /* second message, sent once */
            return 1;

        case CPL_INQUIRE:  /* in case we receive this we should indicate that we like NEWINQUIRE better. */
            lpCPlInfo = (CPLINFO *) lParam2;
            lpCPlInfo->idIcon = ((IsClientInstalled() || !IsWindowsNT())? IDI_AFSD : IDI_CCENTER);
            lpCPlInfo->idName = CPL_DYNAMIC_RES;
            lpCPlInfo->idInfo = CPL_DYNAMIC_RES;
            lpCPlInfo->lData = 0;
            break;

        case CPL_NEWINQUIRE: /* third message, sent once per app */
            lpNewCPlInfo = (LPNEWCPLINFO) lParam2;

            lpNewCPlInfo->dwSize = (DWORD) sizeof(NEWCPLINFO);
            lpNewCPlInfo->dwFlags = 0;
            lpNewCPlInfo->dwHelpContext = 0;
            lpNewCPlInfo->lData = 0;
	    if (IsClientInstalled() || !IsWindowsNT())
	       lpNewCPlInfo->hIcon = TaLocale_LoadIcon(IDI_AFSD);
	    else
	       lpNewCPlInfo->hIcon = TaLocale_LoadIcon(IDI_CCENTER);
            lpNewCPlInfo->szHelpFile[0] = '\0';

            GetString (lpNewCPlInfo->szName, (!IsWindowsNT()) ? IDS_CPL_NAME_95 : (!IsClientInstalled()) ? IDS_CPL_NAME_CCENTER : IDS_CPL_NAME_NT);
            GetString (lpNewCPlInfo->szInfo, (!IsWindowsNT()) ? IDS_CPL_DESC_95 : (!IsClientInstalled()) ? IDS_CPL_DESC_CCENTER : IDS_CPL_DESC_NT);
            break;

    case CPL_DBLCLK:		/* applet icon double-clicked */
            memset(&shellExecInfo, 0, sizeof(shellExecInfo));
            shellExecInfo.cbSize = sizeof(shellExecInfo);
            shellExecInfo.nShow = SW_SHOWNORMAL;
            shellExecInfo.hwnd = hwndCPl;
            shellExecInfo.lpFile = "afs_config.exe";
	    if (!IsClientInstalled() && IsWindowsNT())
                shellExecInfo.lpParameters = "/c";

            ShellExecuteEx(&shellExecInfo);
            break;

    case CPL_EXIT:
            CoUninitialize();
            if (hinstResources)
                FreeLibrary (hinstResources);
            break;
    }

    return 0;
}