1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3
* The contents of this file are subject to the Netscape Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/NPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is Mozilla Communicator client code,
14
* released March 31, 1998.
16
* The Initial Developer of the Original Code is Netscape Communications
17
* Corporation. Portions created by Netscape are
18
* Copyright (C) 1998 Netscape Communications Corporation. All
22
* Samir Gehani <sgehani@netscape.com>
25
#include "nsComponent.h"
28
nsComponent::nsComponent() :
45
for (i = 0; i < MAX_URLS; i++)
47
for (i = 0; i < MAX_COMPONENTS; i++)
51
nsComponent::~nsComponent()
55
XI_IF_FREE(mDescShort);
56
XI_IF_FREE(mDescLong);
58
for (i = 0; i < MAX_URLS; i++)
60
for (i = 0; i < MAX_COMPONENTS; i++)
61
XI_IF_FREE(mDependees[i]);
65
nsComponent::Duplicate()
67
nsComponent *zdup = new nsComponent();
76
nsComponent::SetDescShort(char *aDescShort)
81
mDescShort = aDescShort;
87
nsComponent::GetDescShort()
96
nsComponent::SetDescLong(char *aDescLong)
101
mDescLong = aDescLong;
107
nsComponent::GetDescLong()
116
nsComponent::SetArchive(char *aArchive)
127
nsComponent::GetArchive()
136
nsComponent::SetInstallSize(int aInstallSize)
138
mInstallSize = aInstallSize;
144
nsComponent::GetInstallSize()
146
if (mInstallSize >= 0)
153
nsComponent::SetArchiveSize(int aArchiveSize)
155
mArchiveSize = aArchiveSize;
161
nsComponent::GetArchiveSize()
163
if (mArchiveSize >= 0)
170
nsComponent::GetCurrentSize()
172
// assumes cwd is the same as the installer binary location
174
char path[MAXPATHLEN];
180
sprintf(path, "./xpi/%s", mArchive);
181
if (0 != stat(path, &stbuf))
184
return (stbuf.st_size/1024); // return size in KB
188
nsComponent::SetURL(char *aURL, int aIndex)
193
return E_URL_ALREADY;
201
nsComponent::GetURL(int aIndex)
203
if (aIndex < 0 || aIndex >= MAX_URLS)
210
nsComponent::AddDependee(char *aDependee)
215
mDependees[mNextDependeeIdx] = aDependee;
216
mDependees[++mNextDependeeIdx] = NULL;
222
nsComponent::ResolveDependees(int aBeingSelected, nsComponentList *aComps)
225
nsComponent *currComp = NULL;
231
// loop over all dependees
232
for (i = 0; i < mNextDependeeIdx; i++)
237
currComp = aComps->GetCompByShortDesc(mDependees[i]);
242
currComp->DepAddRef();
244
currComp->DepRelease();
251
nsComponent::SetSelected()
253
mAttributes |= nsComponent::SELECTED;
259
nsComponent::SetUnselected()
262
mAttributes &= ~nsComponent::SELECTED;
269
nsComponent::IsSelected()
271
if (mAttributes & nsComponent::SELECTED)
278
nsComponent::SetInvisible()
280
mAttributes |= nsComponent::INVISIBLE;
286
nsComponent::SetVisible()
289
mAttributes &= ~nsComponent::INVISIBLE;
295
nsComponent::IsInvisible()
297
if (mAttributes & nsComponent::INVISIBLE)
304
nsComponent::SetLaunchApp()
306
mAttributes |= nsComponent::LAUNCHAPP;
312
nsComponent::SetDontLaunchApp()
315
mAttributes &= ~nsComponent::LAUNCHAPP;
321
nsComponent::IsLaunchApp()
323
if (mAttributes & nsComponent::LAUNCHAPP)
330
nsComponent::SetDownloadOnly()
332
mAttributes |= nsComponent::DOWNLOAD_ONLY;
338
nsComponent::IsDownloadOnly()
340
if (mAttributes & nsComponent::DOWNLOAD_ONLY)
347
nsComponent::SetNext(nsComponent *aComponent)
358
nsComponent::InitNext()
366
nsComponent::GetNext()
375
nsComponent::SetIndex(int aIndex)
377
if (aIndex < 0 || aIndex > MAX_COMPONENTS)
378
return E_OUT_OF_BOUNDS;
386
nsComponent::GetIndex()
388
if (mIndex < 0 || mIndex > MAX_COMPONENTS)
389
return E_OUT_OF_BOUNDS;
395
nsComponent::AddRef()
403
nsComponent::Release()
417
nsComponent::InitRefCount()
425
nsComponent::DepAddRef()
427
if (mDepRefCount == 0)
436
nsComponent::DepRelease()
440
if (mDepRefCount < 0)
443
if (mDepRefCount == 0)
450
nsComponent::DepGetRefCount()
456
nsComponent::SetResumePos(int aResPos)
464
nsComponent::GetResumePos()
473
nsComponent::SetDownloaded( int which )
481
nsComponent::IsDownloaded()