Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
xpi.c File Reference
#include "extern.h"
#include "dialogs.h"
#include "extra.h"
#include "xpistub.h"
#include "xpi.h"
#include "xperr.h"
#include "logging.h"
#include "ifuncns.h"

Go to the source code of this file.

Classes

struct  ExtractFilesDlgInfo

Defines

#define BDIR_RIGHT   1
#define BDIR_LEFT   2

Typedefs

typedef HRESULT(_Optlink * XpiInit )(const char *, const char *aLogName, pfnXPIProgress)
typedef HRESULT(_Optlink * XpiInstall )(const char *, const char *, long)
typedef void(_Optlink * XpiExit )(void)

Functions

static void UpdateGaugeArchiveProgressBar (unsigned value)
HRESULT InitializeXPIStub ()
HRESULT DeInitializeXPIStub ()
void GetTotalArchivesToInstall (void)
char * GetErrorString (DWORD dwError, char *szErrorString, DWORD dwErrorStringSize)
HRESULT SmartUpdateJars ()
void cbXPIStart (const char *URL, const char *UIName)
void cbXPIProgress (const char *msg, PRInt32 val, PRInt32 max)
void cbXPIFinal (const char *URL, PRInt32 finalStatus)
static void CenterWindow (HWND hWndDlg)
MRESULT APIENTRY ProgressDlgProc (HWND hWndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
void InitProgressDlg ()

Variables

static XpiInit pfnXpiInit
static XpiInstall pfnXpiInstall
static XpiExit pfnXpiExit
static DWORD dwCurrentArchive
static DWORD dwTotalArchives
char szStrProcessingFile [MAX_BUF]
char szStrCopyingFile [MAX_BUF]
char szStrInstalling [MAX_BUF]
struct ExtractFilesDlgInfo dlgInfo

Class Documentation

struct ExtractFilesDlgInfo

Definition at line 74 of file xpi.c.

Collaboration diagram for ExtractFilesDlgInfo:
Class Members
HWND hWndDlg
int nArchiveBars
int nBars
int nFileBars
int nMaxArchiveBars
int nMaxBars
int nMaxFileBars

Define Documentation

#define BDIR_LEFT   2

Definition at line 50 of file xpi.c.

#define BDIR_RIGHT   1

Definition at line 49 of file xpi.c.


Typedef Documentation

typedef void(_Optlink * XpiExit)(void)

Definition at line 54 of file xpi.c.

typedef HRESULT(_Optlink * XpiInit)(const char *, const char *aLogName, pfnXPIProgress)

Definition at line 52 of file xpi.c.

typedef HRESULT(_Optlink * XpiInstall)(const char *, const char *, long)

Definition at line 53 of file xpi.c.


Function Documentation

void cbXPIFinal ( const char *  URL,
PRInt32  finalStatus 
)

Definition at line 366 of file xpi.c.

{
}
void cbXPIProgress ( const char *  msg,
PRInt32  val,
PRInt32  max 
)

Definition at line 353 of file xpi.c.

{
  char szBuf[MAX_BUF];

  if(sgProduct.ulMode != SILENT)
  {
    TruncateString(WinWindowFromID(dlgInfo.hWndDlg, IDC_STATUS3), msg, szBuf, sizeof(szBuf));
    WinSetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS3, szBuf);
  }

  ProcessWindowsMessages();
}

Here is the call graph for this function:

void cbXPIStart ( const char *  URL,
const char *  UIName 
)

Definition at line 349 of file xpi.c.

{
}
static void CenterWindow ( HWND  hWndDlg) [static]

Definition at line 378 of file xpi.c.

{
  SWP swpDlg;

  WinQueryWindowPos(hWndDlg, &swpDlg);
  WinSetWindowPos(hWndDlg,
                  0,
                  (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)/2)-(swpDlg.cx/2),
                  (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)/2)-(swpDlg.cy/2),
                  0,
                  0,
                  SWP_MOVE);
}

Here is the caller graph for this function:

Definition at line 138 of file xpi.c.

{
  pfnXpiInit    = NULL;
  pfnXpiInstall = NULL;
  pfnXpiExit    = NULL;

  if(hXPIStubInst)
    DosFreeModule(hXPIStubInst);

  chdir(szSetupDir);
  return(0);
}
char* GetErrorString ( DWORD  dwError,
char *  szErrorString,
DWORD  dwErrorStringSize 
)

Definition at line 169 of file xpi.c.

{
  int  i = 0;
  char szErrorNumber[MAX_BUF];

  memset(szErrorString, 0, dwErrorStringSize);
  _itoa(dwError, szErrorNumber, 10);

  /* map the error value to a string */
  while(TRUE)
  {
    if(*XpErrorList[i] == '\0')
      break;

    if(stricmp(szErrorNumber, XpErrorList[i]) == 0)
    {
      if(*XpErrorList[i + 1] != '\0')
        strcpy(szErrorString, XpErrorList[i + 1]);

      break;
    }

    ++i;
  }

  return(szErrorString);
}

Here is the call graph for this function:

Definition at line 151 of file xpi.c.

{
  DWORD     dwIndex0;
  siC       *siCObject = NULL;

  dwIndex0        = 0;
  dwTotalArchives = 0;
  siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);
  while(siCObject)
  {
    if((siCObject->dwAttributes & SIC_SELECTED) && !(siCObject->dwAttributes & SIC_LAUNCHAPP))
      ++dwTotalArchives;

    ++dwIndex0;
    siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);
  }
}

Here is the call graph for this function:

Definition at line 76 of file xpi.c.

{
  char szBuf[MAX_BUF];
  char szXPIStubFile[MAX_BUF];
  char szEDosQueryProcAddr[MAX_BUF];
  APIRET rc;

  hXPIStubInst = NULL;

  if(!GetPrivateProfileString("Messages", "ERROR_DOSQUERYPROCADDR", "", szEDosQueryProcAddr, sizeof(szEDosQueryProcAddr), szFileIniInstall))
    return(1);

  /* change current directory to where xpistub.dll */
  /* change current directory to where xpistub.dll */
  strcpy(szBuf, siCFXpcomFile.szDestination);
  AppendBackSlash(szBuf, sizeof(szBuf));
  strcat(szBuf, "bin");
  chdir(szBuf);

  /* Set LIBPATHSTRICT */
  DosSetExtLIBPATH("T", LIBPATHSTRICT);

  /* Add it to LIBPATH */
  DosSetExtLIBPATH(szBuf, BEGIN_LIBPATH);

  /* build full path to xpistub.dll */
  strcpy(szXPIStubFile, szBuf);
  AppendBackSlash(szXPIStubFile, sizeof(szXPIStubFile));
  strcat(szXPIStubFile, "xpistub.dll");

  if(FileExists(szXPIStubFile) == FALSE)
    return(2);

  /* load xpistub.dll */
  if (DosLoadModule(NULL, 0, szXPIStubFile, &hXPIStubInst) != NO_ERROR)
  {
    sprintf(szBuf, szEDllLoad, szXPIStubFile);
    PrintError(szBuf, ERROR_CODE_SHOW);
    return(1);
  }
  if(DosQueryProcAddr(hXPIStubInst, 0, "_XPI_Init", &pfnXpiInit) != NO_ERROR)
  {
    sprintf(szBuf, szEDosQueryProcAddr, "_XPI_Init");
    PrintError(szBuf, ERROR_CODE_SHOW);
    return(1);
  }
  if(DosQueryProcAddr(hXPIStubInst, 0, "_XPI_Install", &pfnXpiInstall) != NO_ERROR)
  {
    sprintf(szBuf, szEDosQueryProcAddr, "_XPI_Install");
    PrintError(szBuf, ERROR_CODE_SHOW);
    return(1);
  }
  if(DosQueryProcAddr(hXPIStubInst, 0, "_XPI_Exit", &pfnXpiExit) != NO_ERROR)
  {
    sprintf(szBuf, szEDosQueryProcAddr, "_XPI_Exit");
    PrintError(szBuf, ERROR_CODE_SHOW);
    return(1);
  }

  return(0);
}

Definition at line 427 of file xpi.c.

{
  if(sgProduct.ulMode != SILENT)
  {
    dlgInfo.hWndDlg = WinLoadDlg(HWND_DESKTOP, hWndMain, ProgressDlgProc, hSetupRscInst, DLG_EXTRACTING, NULL);
    WinShowWindow(dlgInfo.hWndDlg, TRUE);
  }
}
MRESULT APIENTRY ProgressDlgProc ( HWND  hWndDlg,
ULONG  msg,
MPARAM  mp1,
MPARAM  mp2 
)

Definition at line 394 of file xpi.c.

{
  switch (msg)
  {
    case WM_INITDLG:
      AdjustDialogSize(hWndDlg);
      WinSetPresParam(hWndDlg, PP_FONTNAMESIZE,
                      strlen(sgInstallGui.szDefinedFont)+1, sgInstallGui.szDefinedFont);
      WinSendMsg(WinWindowFromID(hWndDlg, IDC_GAUGE_ARCHIVE), SLM_SETSLIDERINFO,
                               MPFROM2SHORT(SMA_SHAFTDIMENSIONS, 0),
                               (MPARAM)20);
//      DisableSystemMenuItems(hWndDlg, TRUE);
      CenterWindow(hWndDlg);
      break;
   case WM_CLOSE:
   case WM_COMMAND:
      return (MRESULT)TRUE;
  }
  return WinDefDlgProc(hWndDlg, msg, mp1, mp2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 197 of file xpi.c.

{
  DWORD     dwIndex0;
  siC       *siCObject = NULL;
  HRESULT   hrResult;
  char      szBuf[MAX_BUF];
  char      szEXpiInstall[MAX_BUF];
  char      szArchive[MAX_BUF];
  char      szMsgSmartUpdateStart[MAX_BUF];
  char      szDlgExtractingTitle[MAX_BUF];

  if(!GetPrivateProfileString("Messages", "MSG_SMARTUPDATE_START", "", szMsgSmartUpdateStart, sizeof(szMsgSmartUpdateStart), szFileIniInstall))
    return(1);
  if(!GetPrivateProfileString("Messages", "DLG_EXTRACTING_TITLE", "", szDlgExtractingTitle, sizeof(szDlgExtractingTitle), szFileIniInstall))
    return(1);
  if(!GetPrivateProfileString("Messages", "STR_PROCESSINGFILE", "", szStrProcessingFile, sizeof(szStrProcessingFile), szFileIniInstall))
    exit(1);
  if(!GetPrivateProfileString("Messages", "STR_INSTALLING", "", szStrInstalling, sizeof(szStrInstalling), szFileIniInstall))
    exit(1);
  if(!GetPrivateProfileString("Messages", "STR_COPYINGFILE", "", szStrCopyingFile, sizeof(szStrCopyingFile), szFileIniInstall))
    exit(1);

  ShowMessage(szMsgSmartUpdateStart, TRUE);
  if(InitializeXPIStub() == WIZ_OK)
  {
    LogISXPInstall(W_START);
    strcpy(szBuf, sgProduct.szPath);
    if(*sgProduct.szSubPath != '\0')
    {
      AppendBackSlash(szBuf, sizeof(szBuf));
      strcat(szBuf, sgProduct.szSubPath);
    }
    hrResult = pfnXpiInit(szBuf, FILE_INSTALL_LOG, cbXPIProgress);

    /* Unset LIBPATHSTRICT */
    DosSetExtLIBPATH("F", LIBPATHSTRICT);

    ShowMessage(szMsgSmartUpdateStart, FALSE);
    InitProgressDlg();
    GetTotalArchivesToInstall();
    WinSetWindowText(dlgInfo.hWndDlg, szDlgExtractingTitle);

    dwIndex0          = 0;
    dwCurrentArchive  = 0;
    siCObject         = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);
    while(siCObject)
    {
      if(siCObject->dwAttributes & SIC_SELECTED)
        /* Since the archive is selected, we need to process the file ops here */
         ProcessFileOps(T_PRE_ARCHIVE, siCObject->szReferenceName);

      /* launch smartupdate engine for earch jar to be installed */
      if((siCObject->dwAttributes & SIC_SELECTED)   &&
        !(siCObject->dwAttributes & SIC_LAUNCHAPP) &&
        !(siCObject->dwAttributes & SIC_DOWNLOAD_ONLY))
      {
        strcpy(szArchive, sgProduct.szAlternateArchiveSearchPath);
        AppendBackSlash(szArchive, sizeof(szArchive));
        strcat(szArchive, siCObject->szArchiveName);
        if((*sgProduct.szAlternateArchiveSearchPath == '\0') || (!FileExists(szArchive)))
        {
          strcpy(szArchive, szSetupDir);
          AppendBackSlash(szArchive, sizeof(szArchive));
          strcat(szArchive, siCObject->szArchiveName);
          if(!FileExists(szArchive))
          {
            strcpy(szArchive, szTempDir);
            AppendBackSlash(szArchive, sizeof(szArchive));
            strcat(szArchive, siCObject->szArchiveName);
            if(!FileExists(szArchive))
            {
              char szEFileNotFound[MAX_BUF];

              if(GetPrivateProfileString("Messages", "ERROR_FILE_NOT_FOUND", "", szEFileNotFound, sizeof(szEFileNotFound), szFileIniInstall))
              {
                sprintf(szBuf, szEFileNotFound, szArchive);
                PrintError(szBuf, ERROR_CODE_HIDE);
              }
              return(1);
            }
          }
        }

        if(dwCurrentArchive == 0)
        {
          ++dwCurrentArchive;
          UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100));
        }

        sprintf(szBuf, szStrInstalling, siCObject->szDescriptionShort);
        WinSetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS0, szBuf);
        LogISXPInstallComponent(siCObject->szDescriptionShort);

        hrResult = pfnXpiInstall(szArchive, "", 0xFFFF);
        if(hrResult == E_REBOOT)
          bReboot = TRUE;
        else if((hrResult != WIZ_OK) &&
               !(siCObject->dwAttributes & SIC_IGNORE_XPINSTALL_ERROR))
        {
          LogMSXPInstallStatus(siCObject->szArchiveName, hrResult);
          LogISXPInstallComponentResult(hrResult);
          if(GetPrivateProfileString("Messages", "ERROR_XPI_INSTALL", "", szEXpiInstall, sizeof(szEXpiInstall), szFileIniInstall))
          {
            char szErrorString[MAX_BUF];

            GetErrorString(hrResult, szErrorString, sizeof(szErrorString));
            sprintf(szBuf, "%s - %s: %d %s", szEXpiInstall, siCObject->szDescriptionShort, hrResult, szErrorString);
            PrintError(szBuf, ERROR_CODE_HIDE);
          }

          /* break out of the siCObject while loop */
          break;
        }

        ++dwCurrentArchive;
        UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100));
        ProcessWindowsMessages();
        LogISXPInstallComponentResult(hrResult);

        if((hrResult != WIZ_OK) &&
          (siCObject->dwAttributes & SIC_IGNORE_XPINSTALL_ERROR))
          /* reset the result to WIZ_OK if there was an error and the
           * component's attributes contains SIC_IGNORE_XPINSTALL_ERROR.
           * This should be done after LogISXPInstallComponentResult()
           * because we still should log the error value. */
          hrResult = WIZ_OK;
      }

      if(siCObject->dwAttributes & SIC_SELECTED)
        /* Since the archive is selected, we need to do the file ops here */
         ProcessFileOps(T_POST_ARCHIVE, siCObject->szReferenceName);

      ++dwIndex0;
      siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);
    } /* while(siCObject) */

    LogMSXPInstallStatus(NULL, hrResult);
    pfnXpiExit();
    if(sgProduct.ulMode != SILENT)
      WinDestroyWindow(dlgInfo.hWndDlg);
  }
  else
  {
    ShowMessage(szMsgSmartUpdateStart, FALSE);
  }

  DeInitializeXPIStub();
  LogISXPInstall(W_END);

  return(hrResult);
}
static void UpdateGaugeArchiveProgressBar ( unsigned  value) [static]

Definition at line 418 of file xpi.c.

{
  if(sgProduct.ulMode != SILENT) {
    WinSendMsg(WinWindowFromID(dlgInfo.hWndDlg, IDC_GAUGE_ARCHIVE), SLM_SETSLIDERINFO,
                               MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE),
                               (MPARAM)(value-1));
  }
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 60 of file xpi.c.

Definition at line 61 of file xpi.c.

XpiExit pfnXpiExit [static]

Definition at line 58 of file xpi.c.

XpiInit pfnXpiInit [static]

Definition at line 56 of file xpi.c.

Definition at line 57 of file xpi.c.

Definition at line 63 of file xpi.c.

Definition at line 64 of file xpi.c.

Definition at line 62 of file xpi.c.