Bug 186036 - Allow PPEmbed to build under Mach-O. NOT YET PART OF BUILD. r=pinkerton/sr=bryner/a=asa

This commit is contained in:
ccarlen%netscape.com 2003-02-12 15:35:40 +00:00
Родитель eb5e03e14e
Коммит 42a871ad4e
32 изменённых файлов: 12219 добавлений и 7340 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -202,14 +202,25 @@ NS_METHOD CAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFil
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
OSErr err;
#if defined(XP_MACOSX)
FSRef fsRef;
err = ::FSFindFolder(kUserDomain, kDomainLibraryFolderType, kCreateFolder, &fsRef);
if (err) return NS_ERROR_FAILURE;
NS_NewLocalFile(nsString(), PR_TRUE, getter_AddRefs(localDir));
if (!localDir) return NS_ERROR_FAILURE;
nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
rv = localDirMac->InitWithFSRef(&fsRef);
if (NS_FAILED(rv)) return rv;
#else
long response;
err = ::Gestalt(gestaltSystemVersion, &response);
const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
#endif
rv = localDir->AppendRelativeNativePath(nsDependentCString(mProductDirName));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -22,7 +22,6 @@
#include "CBrowserApp.h"
#include <LGrowZone.h>
#include <PP_Messages.h>
#include <PP_Resources.h>
#include <UDrawingState.h>
@ -70,14 +69,17 @@
#include "nsIFileChannel.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "macstdlibextras.h"
#include "SIOUX.h"
#include "nsNetUtil.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindow.h"
#include "nsIDownload.h"
#include "nsCRT.h"
#if defined(__MWERKS__) && !defined(__MACH__)
#include "macstdlibextras.h"
#include "SIOUX.h"
#endif
#include <TextServices.h>
#ifdef USE_PROFILES
@ -99,30 +101,34 @@ int main()
SetDebugThrow_(PP_PowerPlant::debugAction_Alert); // Set Debugging options
SetDebugSignal_(PP_PowerPlant::debugAction_Alert);
#ifdef POWERPLANT_IS_FRAMEWORK
// A framework's Resource Mgr resources must be opened explicitly.
CFBundleRef powerplantBundle = ::CFBundleGetBundleWithIdentifier(
CFSTR("org.mozilla.PowerPlant"));
SInt16 powerPlantResRefNum = -1;
if (powerplantBundle) {
powerPlantResRefNum = ::CFBundleOpenBundleResourceMap(powerplantBundle);
::CFRelease(powerplantBundle);
}
#endif
PP_PowerPlant::InitializeHeap(3); // Initialize Memory Manager
// Parameter is number of Master Pointer
// blocks to allocate
#if __PowerPlant__ >= 0x02100000
PP_PowerPlant::UQDGlobals::InitializeToolbox();
#else
PP_PowerPlant::UQDGlobals::InitializeToolbox(&qd);
#endif
#if DEBUG
#if defined(__MWERKS__) && !TARGET_CARBON
::InitializeSIOUX(false);
#endif
#if !TARGET_CARBON
#if !TARGET_CARBON
new PP_PowerPlant::LGrowZone(20000); // Install a GrowZone function to catch low memory situations.
::InitTSMAwareApplication();
#endif
new PP_PowerPlant::LGrowZone(20000); // Install a GrowZone function to catch low memory situations.
{
CBrowserApp theApp; // create instance of your application
theApp.Run();
}
@ -277,8 +283,7 @@ CBrowserApp::StartUp()
nsCOMPtr<nsProfileDirServiceProvider> locProvider;
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
if (!locProvider)
return NS_ERROR_FAILURE;
ThrowIfNil_(locProvider);
// Directory service holds an strong reference to any
// provider that is registered with it. Let it hold the
@ -601,7 +606,7 @@ pascal OSStatus CBrowserApp::AppEventHandler(EventHandlerCallRef aHandlerChain,
typeHICommand, NULL, sizeof(HICommand),
NULL, &command) != noErr)
return result;
switch (::GetEventKind(event))
{
case kEventCommandProcess:
@ -609,10 +614,12 @@ pascal OSStatus CBrowserApp::AppEventHandler(EventHandlerCallRef aHandlerChain,
switch (command.commandID)
{
case kHICommandPreferences:
{
CBrowserApp *theApp = reinterpret_cast<CBrowserApp*>(userData);
theApp->ObeyCommand(PP_PowerPlant::cmd_Preferences, nsnull);
result = noErr;
break;
}
default:
break;
}

Просмотреть файл

@ -79,7 +79,7 @@ const PRInt32 kGrowIconSize = 15;
CBrowserChrome::CBrowserChrome(CBrowserShell *aShell,
UInt32 aChromeFlags,
Boolean aIsMainContent) :
mBrowserWindow(nsnull), mBrowserShell(aShell),
mBrowserShell(aShell), mBrowserWindow(nsnull),
mChromeFlags(aChromeFlags), mIsMainContent(aIsMainContent),
mSizeToContent(false),
mInModalLoop(false), mWindowVisible(false),
@ -409,7 +409,7 @@ NS_IMETHODIMP CBrowserChrome::GetSiteWindow(void * *aSiteWindow)
NS_ENSURE_ARG(aSiteWindow);
NS_ENSURE_STATE(mBrowserWindow);
*aSiteWindow = mBrowserWindow->Compat_GetMacWindow();
*aSiteWindow = mBrowserWindow->GetMacWindow();
return NS_OK;
}
@ -498,8 +498,6 @@ void CBrowserChrome::ListenToMessage(MessageT inMessage, void* ioParam)
{
case msg_OnNetStopChange:
{
const MsgNetStartInfo *info = reinterpret_cast<MsgNetStartInfo*>(ioParam);
mInitialLoadComplete = true;
// See if we need to size it and show it

Просмотреть файл

@ -257,9 +257,9 @@ NS_IMETHODIMP CBrowserShellProgressListener::OnSecurityChange(nsIWebProgress *aW
//*****************************************************************************
CBrowserShell::CBrowserShell() :
LDropArea(GetMacWindow()),
mChromeFlags(nsIWebBrowserChrome::CHROME_DEFAULT), mIsMainContent(true),
mContextMenuFlags(nsIContextMenuListener2::CONTEXT_NONE),
LDropArea(GetMacWindow())
mContextMenuFlags(nsIContextMenuListener2::CONTEXT_NONE)
{
nsresult rv = CommonConstruct();
if (rv != NS_OK)
@ -356,7 +356,7 @@ NS_IMETHODIMP CBrowserShell::EnsureTopLevelWidget(nsIWidget **aWidget)
nsresult rv;
nsIWidget *widget = nsnull;
err = ::GetWindowProperty(Compat_GetMacWindow(), 'PPMZ', 'WIDG', sizeof(nsIWidget*), nsnull, (void*)&widget);
err = ::GetWindowProperty(GetMacWindow(), 'PPMZ', 'WIDG', sizeof(nsIWidget*), nsnull, (void*)&widget);
if (err == noErr && widget) {
*aWidget = widget;
NS_ADDREF(*aWidget);
@ -377,11 +377,11 @@ NS_IMETHODIMP CBrowserShell::EnsureTopLevelWidget(nsIWidget **aWidget)
Rect grayRect;
::GetRegionBounds(grayRgn, &grayRect);
nsRect r(0, 0, grayRect.right - grayRect.left, grayRect.bottom - grayRect.top);
rv = newWidget->Create(Compat_GetMacWindow(), r, nsnull, nsnull, nsnull, nsnull, nsnull);
rv = newWidget->Create(GetMacWindow(), r, nsnull, nsnull, nsnull, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
widget = newWidget;
err = ::SetWindowProperty(Compat_GetMacWindow(), 'PPMZ', 'WIDG', sizeof(nsIWidget*), (void*)&widget);
err = ::SetWindowProperty(GetMacWindow(), 'PPMZ', 'WIDG', sizeof(nsIWidget*), (void*)&widget);
if (err == noErr) {
*aWidget = newWidget;
NS_ADDREF(*aWidget);
@ -939,7 +939,7 @@ NS_METHOD CBrowserShell::SetWebBrowser(nsIWebBrowser* aBrowser)
FocusDraw();
/*
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(Compat_GetMacWindow()));
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(GetMacWindow()));
NS_ENSURE_TRUE(ourWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIWidget> aWidget;
@ -1678,7 +1678,9 @@ OSStatus CBrowserShell::HandleUpdateActiveInputArea(
&err);
if (noErr != err)
return err;
return NS_FAILED(res) ? eventNotHandledErr : noErr;
if (NS_FAILED(res))
return eventNotHandledErr;
return noErr;
}
OSStatus CBrowserShell::HandleUnicodeForKeyEvent(
@ -1698,8 +1700,10 @@ OSStatus CBrowserShell::HandleUnicodeForKeyEvent(
(void*)keyboardEvent,
&err);
if (noErr != err)
return err;
return NS_FAILED(res) ? eventNotHandledErr : noErr;
return err;
if (NS_FAILED(res))
return eventNotHandledErr;
return noErr;
}
OSStatus CBrowserShell::HandleOffsetToPos(
@ -1714,9 +1718,12 @@ OSStatus CBrowserShell::HandleOffsetToPos(
OSStatus err = noErr;
nsresult res = tieSink->HandleOffsetToPos( offset, pointX, pointY, &err);
if (noErr != err)
return err;
return NS_FAILED(res) ? eventNotHandledErr : noErr;
return err;
if (NS_FAILED(res))
return eventNotHandledErr;
return noErr;
}
OSStatus CBrowserShell::HandlePosToOffset(
@ -1735,8 +1742,10 @@ OSStatus CBrowserShell::HandlePosToOffset(
nsresult res = tieSink->HandlePosToOffset( currentPointX, currentPointY,
offset, regionClass, &err);
if (noErr != err)
return err;
return NS_FAILED(res) ? eventNotHandledErr : noErr;
return err;
if (NS_FAILED(res))
return eventNotHandledErr;
return noErr;
}
OSStatus CBrowserShell::HandleGetSelectedText(nsAString& selectedText)
@ -1748,8 +1757,11 @@ OSStatus CBrowserShell::HandleGetSelectedText(nsAString& selectedText)
OSStatus err = noErr;
nsresult res = tieSink->HandleGetSelectedText( selectedText, &err);
if (noErr != err)
return err;
return NS_FAILED(res) ? eventNotHandledErr : noErr;
return err;
if (NS_FAILED(res))
return eventNotHandledErr;
return noErr;
}

Просмотреть файл

@ -182,7 +182,7 @@ void CBrowserWindow::ShowSelf()
nsIWidget *widget = nsnull;
OSStatus err = ::GetWindowProperty(Compat_GetMacWindow(), 'PPMZ', 'WIDG', sizeof(nsIWidget*), nsnull, (void*)&widget);
OSStatus err = ::GetWindowProperty(GetMacWindow(), 'PPMZ', 'WIDG', sizeof(nsIWidget*), nsnull, (void*)&widget);
if (err == noErr && widget)
widget->Show(PR_TRUE);
}
@ -199,8 +199,6 @@ void CBrowserWindow::ListenToMessage(MessageT inMessage,
{
case msg_OnNetStartChange:
{
const MsgNetStartInfo *info = reinterpret_cast<MsgNetStartInfo*>(ioParam);
if (mProgressBar) {
mProgressBar->Show();
mProgressBar->SetIndeterminateFlag(true, true);
@ -216,8 +214,6 @@ void CBrowserWindow::ListenToMessage(MessageT inMessage,
case msg_OnNetStopChange:
{
const MsgNetStopInfo *info = reinterpret_cast<MsgNetStopInfo*>(ioParam);
if (mThrobber)
mThrobber->Stop();

Просмотреть файл

@ -299,13 +299,14 @@ nsresult CHeaderSniffer::PerformSave(nsIURI* inOriginalURI, const ESaveFormat in
{
Str255 defaultName;
char tempBuf1[256], tempBuf2[64];
bool result;
CPlatformUCSConversion::GetInstance()->UCSToPlatform(defaultFileName, defaultName);
::CopyPascalStringToC(defaultName, tempBuf1);
#ifndef XP_MACOSX
char tempBuf1[256], tempBuf2[64];
::CopyPascalStringToC(defaultName, tempBuf1);
::CopyCStringToPascal(NS_TruncNodeName(tempBuf1, tempBuf2), defaultName);
#endif
if (isHTML) {
ESaveFormat saveFormat = SaveFormatFromPrefValue(filterIndex);
UNavServicesDialogs::LCustomFileDesignator customDesignator;

Просмотреть файл

@ -22,6 +22,9 @@
#include "CIconServicesIcon.h"
#include "UResourceMgr.h"
#include "UMemoryMgr.h"
#include <Processes.h>
//*****************************************************************************
@ -29,7 +32,7 @@
//*****************************************************************************
OSType CIconServicesIcon::mgAppCreator;
FSSpec CIconServicesIcon::mgAppFileSpec;
FSSpec CIconServicesIcon::mgIconFileSpec;
CIconServicesIcon::CIconServicesIcon(const SPaneInfo& inPaneInfo,
MessageT inValueMessage,
@ -63,6 +66,9 @@ CIconServicesIcon::~CIconServicesIcon()
void CIconServicesIcon::DrawSelf()
{
if (!mIconRef)
return;
Rect iconRect;
CalcLocalFrameRect(iconRect);
AdjustIconRect(iconRect);
@ -112,6 +118,9 @@ SInt16 CIconServicesIcon::FindHotSpot(Point inPoint) const
Boolean CIconServicesIcon::PointInHotSpot(Point inPoint,
SInt16 inHotSpot) const
{
if (!mIconRef)
return false;
Rect iconRect;
CalcLocalFrameRect(iconRect);
AdjustIconRect(iconRect);
@ -158,11 +167,34 @@ void CIconServicesIcon::Init()
ProcessInfoRec info;
info.processInfoLength = sizeof(info);
info.processName = nil;
info.processAppSpec = &mgAppFileSpec;
info.processAppSpec = nil;
err = ::GetProcessInformation(&psn, &info);
ThrowIfError_(err);
mgAppCreator = info.processSignature;
// RegisterIconRefFromResource() needs to be given an FSSpec of
// the file containing the 'icns' resource of the icon being
// registered. The following will track down the file no matter
// how our application is packaged.
StResLoad resLoadState(false);
StResource resHandle('icns', mIconResID); // throws if N/A
SInt16 resRefNum = ::HomeResFile(resHandle);
if (resRefNum != -1)
{
FCBPBRec pb;
pb.ioNamePtr = mgIconFileSpec.name;
pb.ioVRefNum = 0;
pb.ioRefNum = resRefNum;
pb.ioFCBIndx = 0;
err = PBGetFCBInfoSync(&pb);
if (err == noErr)
{
mgIconFileSpec.vRefNum = pb.ioFCBVRefNum;
mgIconFileSpec.parID = pb.ioFCBParID;
}
}
gInitialized = true;
}
GetIconRef();
@ -182,17 +214,11 @@ void CIconServicesIcon::AdjustIconRect(Rect& ioRect) const
void CIconServicesIcon::GetIconRef()
{
OSErr err;
IconRef iconRef;
// We would like to first see if the icon is already registered
// But, for some reason, the following call always returns noErr and the wrong icon.
// err = ::GetIconRef(mgAppFileSpec.vRefNum, mgAppCreator, mIconType, &iconRef);
// err = ::GetIconRef(mgIconFileSpec.vRefNum, mgAppCreator, mIconType, &iconRef);
// if (err != noErr)
err = ::RegisterIconRefFromResource(mgAppCreator, mIconType, &mgAppFileSpec, mIconResID, &iconRef);
ThrowIfError_(err);
mIconRef = iconRef;
::RegisterIconRefFromResource(mgAppCreator, mIconType, &mgIconFileSpec, mIconResID, &mIconRef);
}
void CIconServicesIcon::ReleaseIconRef()

Просмотреть файл

@ -70,7 +70,7 @@ protected:
bool mbIsPressed;
static OSType mgAppCreator;
static FSSpec mgAppFileSpec;
static FSSpec mgIconFileSpec;
};
#endif // __CIconServicesIcon_h__

Просмотреть файл

@ -333,7 +333,10 @@ void CProfileManager::DoLogout()
if (item == iCancel)
return;
rv = profileService->ShutDownCurrentProfile(item == iPersist ? nsIProfile::SHUTDOWN_PERSIST : nsIProfile::SHUTDOWN_CLEANSE);
if (item == iPersist)
rv = profileService->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
else
rv = profileService->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_CLEANSE);
if (NS_SUCCEEDED(rv)) {
// Just put this up modally until they pick a new profile
DoManageProfilesDialog();

Просмотреть файл

@ -90,7 +90,7 @@ void CThrobber::HideSelf()
void CThrobber::DrawSelf()
{
if (mMovieController)
::MCDraw(mMovieController, Compat_GetMacWindow());
::MCDraw(mMovieController, GetMacWindow());
}

Просмотреть файл

@ -23,9 +23,11 @@
#include "EmbedEventHandling.h"
#include "CTextInputEventHandler.h"
#include "nsRepeater.h"
#include "prthread.h"
#if defined(__MWERKS__) && defined(DEBUG) && !TARGET_CARBON
#include "SIOUX.h"
#endif
#include "nsIWidget.h"
#include "nsIEventSink.h"
@ -121,7 +123,7 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
} else if (inMessage == msg_Event) {
inMacEvent = static_cast<EventRecord*>(ioParam);
#ifdef DEBUG
#if defined(__MWERKS__) && defined(DEBUG) && !TARGET_CARBON
// 2. See if the event is for the console window.
// Limit what types of events we send to it.
if ((inMacEvent->what == mouseDown ||
@ -237,32 +239,9 @@ CEmbedIdler::~CEmbedIdler()
void CEmbedIdler::SpendTime(const EventRecord& inMacEvent)
{
Repeater::DoIdlers(inMacEvent);
::PR_Sleep(PR_INTERVAL_NO_WAIT);
}
//*****************************************************************************
// CEmbedRepeater
//
//
//*****************************************************************************
CEmbedRepeater::CEmbedRepeater()
{
}
CEmbedRepeater::~CEmbedRepeater()
{
}
void CEmbedRepeater::SpendTime(const EventRecord& inMacEvent)
{
Repeater::DoRepeaters(inMacEvent);
}
//*****************************************************************************
// Initialization Function - Call at application startup.
//*****************************************************************************
@ -276,10 +255,6 @@ void InitializeEmbedEventHandling(LApplication* theApplication)
CEmbedIdler *embedIdler = new CEmbedIdler;
ThrowIfNil_(embedIdler);
embedIdler->StartIdling();
CEmbedRepeater *embedRepeater = new CEmbedRepeater;
ThrowIfNil_(embedRepeater);
embedRepeater->StartRepeating();
#if TARGET_CARBON
InitializeTextInputEventHandling();

Просмотреть файл

@ -28,8 +28,6 @@
#include "PPHeadersDebug_pch"
#include "CarbonCompatibility.h"
// Config flags common to all builds
#include "PPEmbedConfig.h"

Просмотреть файл

@ -245,8 +245,6 @@ NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent, const PRUnichar *d
{
NS_ENSURE_ARG_POINTER(buttonPressed);
nsresult resultErr = NS_OK;
StDialogHandler theHandler(dlog_ConfirmEx, CBrowserChrome::GetLWindowForDOMWindow(parent));
LWindow *theDialog = theHandler.GetDialog();
nsCAutoString cStr;

Просмотреть файл

@ -224,7 +224,7 @@ NS_IMETHODIMP CDownload::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
if (aMaxTotalProgress == -1)
mPercentComplete = -1;
else
mPercentComplete = ((float)aCurTotalProgress / (float)aMaxTotalProgress) * 100.0;
mPercentComplete = (PRInt32)(((float)aCurTotalProgress / (float)aMaxTotalProgress) * 100.0 + 0.5);
MsgOnDLProgressChangeInfo info(this, aCurTotalProgress, aMaxTotalProgress);
BroadcastMessage(msg_OnDLProgressChange, &info);

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsIDownload.h"
#include "nsIWebProgressListener.h"
#include "nsIHelperAppLauncherDialog.h"
#include "nsIExternalHelperAppService.h"
#include "nsIURI.h"
#include "nsILocalFile.h"

Просмотреть файл

@ -1,615 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "UDownloadDisplay.h"
#include "ApplIDs.h"
#include "CIconServicesIcon.h"
// Gecko
#include "nsString.h"
#include "nsILocalFileMac.h"
// Std
#include <algorithm>
using namespace std;
// PowerPlant
#include <LStaticText.h>
#include <LProgressBar.h>
//*****************************************************************************
// CMultiDownloadProgress
//*****************************************************************************
#pragma mark [CMultiDownloadProgress]
bool CMultiDownloadProgress::sRegisteredViewClasses = false;
CMultiDownloadProgress::CMultiDownloadProgress() :
mWindow(nil)
{
if (!sRegisteredViewClasses) {
RegisterClass_(CMultiDownloadProgressWindow);
RegisterClass_(CDownloadProgressView);
RegisterClass_(CIconServicesIcon);
sRegisteredViewClasses = true;
}
}
CMultiDownloadProgress::~CMultiDownloadProgress()
{
}
void CMultiDownloadProgress::AddDownloadItem(CDownload *aDownloadItem)
{
if (!mWindow) {
mWindow = static_cast<CMultiDownloadProgressWindow*>
(LWindow::CreateWindow(wind_DownloadProgress, this));
ThrowIfNil_(mWindow);
// Add this as a listener to the window so we can know when it's destroyed.
mWindow->AddListener(this);
}
// Create the view...
LView::SetDefaultView(mWindow);
LCommander::SetDefaultCommander(mWindow);
LAttachable::SetDefaultAttachable(nil);
CDownloadProgressView *itemView = static_cast<CDownloadProgressView*>
(UReanimator::ReadObjects(ResType_PPob, view_DownloadProgressItem));
ThrowIfNil_(itemView);
// and add it to the window.
mWindow->AddDownloadView(itemView);
itemView->SetDownload(aDownloadItem);
}
// This happens in response to the window being closed. Check for active
// downloads and confirm stopping them if there are any. Returning false
// will prevent the window from being closed.
Boolean CMultiDownloadProgress::AllowSubRemoval(LCommander* inSub)
{
return (!mWindow || (inSub == mWindow && mWindow->ConfirmClose()));
}
// This happens in response to the app being quit. Check for active
// downloads and confirm stopping them if there are any. Returning
// false will prevent the app from quitting.
Boolean CMultiDownloadProgress::AttemptQuitSelf(SInt32 inSaveOption)
{
return (!mWindow || mWindow->ConfirmClose());
}
void CMultiDownloadProgress::ListenToMessage(MessageT inMessage,
void* ioParam)
{
if (inMessage == msg_BroadcasterDied &&
(CMultiDownloadProgressWindow*)((LBroadcaster*)ioParam) == mWindow)
mWindow = nil;
}
//*****************************************************************************
// CMultiDownloadProgressWindow
//*****************************************************************************
#pragma mark -
#pragma mark [CMultiDownloadProgressWindow]
CMultiDownloadProgressWindow::CMultiDownloadProgressWindow() :
mDownloadViewCount(0)
{
StartBroadcasting();
}
CMultiDownloadProgressWindow::CMultiDownloadProgressWindow(LStream* inStream) :
LWindow(inStream),
mDownloadViewCount(0)
{
StartBroadcasting();
}
CMultiDownloadProgressWindow::~CMultiDownloadProgressWindow()
{
}
void CMultiDownloadProgressWindow::AddDownloadView(CDownloadProgressView *aView)
{
const SInt16 kSeparatorHeight = 3;
SDimension16 currSize;
GetFrameSize(currSize);
SDimension16 viewSize;
aView->GetFrameSize(viewSize);
ResizeWindowTo(currSize.width, (viewSize.height * (mDownloadViewCount + 1)) - kSeparatorHeight);
aView->PlaceInSuperFrameAt(0, viewSize.height * mDownloadViewCount++, false);
aView->FinishCreate();
}
void CMultiDownloadProgressWindow::RemoveDownloadView(CDownloadProgressView *aView)
{
// We can't remove the last view, leaving an empty window frame
if (mDownloadViewCount <= 1)
return;
SDimension16 removedPaneSize;
aView->GetFrameSize(removedPaneSize);
SPoint32 removedPaneLoc;
aView->GetFrameLocation(removedPaneLoc);
delete aView;
RemoveSubPane(aView);
mDownloadViewCount--;
TArrayIterator<LPane*> iterator(GetSubPanes());
LPane *subPane;
while (iterator.Next(subPane)) {
SPoint32 subPaneLoc;
subPane->GetFrameLocation(subPaneLoc);
if (subPaneLoc.v >= removedPaneLoc.v + removedPaneSize.height) {
subPane->MoveBy(0, -removedPaneSize.height, true);
}
}
ResizeWindowBy(0, -removedPaneSize.height);
}
Boolean CMultiDownloadProgressWindow::ConfirmClose()
{
Boolean canClose = true;
SInt32 numActiveDownloads = 0;
TArrayIterator<LPane*> iterator(GetSubPanes());
LPane *subPane;
while (iterator.Next(subPane)) {
CDownloadProgressView *downloadView = dynamic_cast<CDownloadProgressView*>(subPane);
if (downloadView && downloadView->IsActive())
numActiveDownloads++;
}
if (numActiveDownloads != 0) {
short itemHit;
AlertStdAlertParamRec pb;
pb.movable = false;
pb.helpButton = false;
pb.filterProc = nil;
pb.defaultText = (StringPtr) kAlertDefaultOKText;
pb.cancelText = (StringPtr) kAlertDefaultCancelText;
pb.otherText = nil;
pb.defaultButton = kStdOkItemIndex;
pb.cancelButton = kStdCancelItemIndex;
pb.position = kWindowAlertPositionParentWindowScreen;
LStr255 msgString(STRx_StdAlertStrings, str_ConfirmCloseDownloads);
LStr255 explainString(STRx_StdAlertStrings, str_ConfirmCloseDownloadsExp);
::StandardAlert(kAlertStopAlert, msgString, explainString, &pb, &itemHit);
if (itemHit != kAlertStdAlertOKButton)
canClose = false;
}
return canClose;
}
//*****************************************************************************
// CDownloadProgressView
//*****************************************************************************
#pragma mark -
#pragma mark [CDownloadProgressView]
enum {
paneID_ProgressBar = 'Prog',
paneID_CancelButton = 'Cncl',
paneID_OpenButton = 'Open',
paneID_RevealButton = 'Rvel',
paneID_CloseButton = 'Clos',
paneID_StatusText = 'Stat',
paneID_StatusLabel = 'StLa',
paneID_TimeRemText = 'Time',
paneID_TimeRemLabel = 'TiLa',
paneID_SrcURIText = 'SURI',
paneID_SrcURILabel = 'SULa',
paneID_DestFileText = 'Dest',
paneID_DestFileLabel = 'DFLa'
};
CDownloadProgressView::CDownloadProgressView() :
mDownloadActive(false)
{
}
CDownloadProgressView::CDownloadProgressView(LStream* inStream) :
LView(inStream),
mDownloadActive(false)
{
}
CDownloadProgressView::~CDownloadProgressView()
{
if (mDownloadActive)
CancelDownload();
mDownload = nsnull;
}
void CDownloadProgressView::FinishCreateSelf()
{
mProgressBar = dynamic_cast<LProgressBar*>(FindPaneByID(paneID_ProgressBar));
mCancelButton = dynamic_cast<LControl*>(FindPaneByID(paneID_CancelButton));
mOpenButton = dynamic_cast<LControl*>(FindPaneByID(paneID_OpenButton));
mRevealButton = dynamic_cast<LControl*>(FindPaneByID(paneID_RevealButton));
mCloseButton = dynamic_cast<LControl*>(FindPaneByID(paneID_CloseButton));
mStatusText = dynamic_cast<LStaticText*>(FindPaneByID(paneID_StatusText));
mTimeRemainingText = dynamic_cast<LStaticText*>(FindPaneByID(paneID_TimeRemText));
mSrcURIText = dynamic_cast<LStaticText*>(FindPaneByID(paneID_SrcURIText));
mDestFileText = dynamic_cast<LStaticText*>(FindPaneByID(paneID_DestFileText));
// The control value is set in terms of percent
if (mProgressBar)
mProgressBar->SetMaxValue(100);
ControlFontStyleRec styleRec;
if (CreateStyleRecFromThemeFont(kThemeSmallSystemFont, styleRec) == noErr) {
if (mStatusText)
mStatusText->SetFontStyle(styleRec);
if (mTimeRemainingText)
mTimeRemainingText->SetFontStyle(styleRec);
if (mSrcURIText)
mSrcURIText->SetFontStyle(styleRec);
if (mDestFileText)
mDestFileText->SetFontStyle(styleRec);
}
if (CreateStyleRecFromThemeFont(kThemeSmallEmphasizedSystemFont, styleRec) == noErr) {
ResIDT labelIDs [] = { paneID_StatusLabel,
paneID_TimeRemLabel,
paneID_SrcURILabel,
paneID_DestFileLabel };
for (int i = 0; i < sizeof(labelIDs) / sizeof(labelIDs[0]); i++) {
LStaticText *staticText = dynamic_cast<LStaticText*>(FindPaneByID(labelIDs[i]));
if (staticText)
staticText->SetFontStyle(styleRec);
}
}
UReanimator::LinkListenerToControls(this, this, view_DownloadProgressItem);
StartListening();
}
Boolean CDownloadProgressView::ObeyCommand(CommandT inCommand,
void *ioParam)
{
#pragma unused(ioParam)
Boolean cmdHandled = false;
nsCOMPtr<nsILocalFile> targetFile;
switch (inCommand)
{
case paneID_CancelButton:
{
CancelDownload();
cmdHandled = true;
}
break;
case paneID_OpenButton:
{
mDownload->GetTarget(getter_AddRefs(targetFile));
if (targetFile)
targetFile->Launch();
}
break;
case paneID_RevealButton:
{
mDownload->GetTarget(getter_AddRefs(targetFile));
if (targetFile)
targetFile->Reveal();
}
break;
case paneID_CloseButton:
{
LView *view = this, *superView;
while ((superView = view->GetSuperView()) != nil)
view = superView;
CMultiDownloadProgressWindow *multiWindow = dynamic_cast<CMultiDownloadProgressWindow*>(view);
if (multiWindow)
multiWindow->RemoveDownloadView(this);
}
break;
}
return cmdHandled;
}
void CDownloadProgressView::ListenToMessage(MessageT inMessage,
void* ioParam)
{
switch (inMessage) {
case CDownload::msg_OnDLStart:
{
mDownloadActive = true;
if (mCancelButton)
mCancelButton->Enable();
}
break;
case CDownload::msg_OnDLComplete:
{
mDownloadActive = false;
if (mCancelButton)
mCancelButton->Disable();
if (mCloseButton)
mCloseButton->Enable();
CDownload *download = reinterpret_cast<CDownload*>(ioParam);
nsresult downloadStatus;
download->GetStatus(downloadStatus);
// When saving documents as plain text, we might not get any
// progress change notifications in which to set the progress bar.
// Now that the download is done, put the bar in a reasonable state.
if (mProgressBar) {
mProgressBar->SetIndeterminateFlag(false, false);
if (NS_SUCCEEDED(downloadStatus))
mProgressBar->SetValue(mProgressBar->GetMaxValue());
else
mProgressBar->SetValue(0);
}
if (NS_SUCCEEDED(downloadStatus)) {
if (mOpenButton)
mOpenButton->Enable();
}
if (mRevealButton)
mRevealButton->Enable();
if (mTimeRemainingText)
mTimeRemainingText->SetText(LStr255("\p"));
}
break;
case CDownload::msg_OnDLProgressChange:
{
CDownload::MsgOnDLProgressChangeInfo *info =
static_cast<CDownload::MsgOnDLProgressChangeInfo*>(ioParam);
if (mProgressBar) {
PRInt32 percentComplete;
info->mBroadcaster->GetPercentComplete(&percentComplete);
if (percentComplete != -1 && mProgressBar->IsIndeterminate())
mProgressBar->SetIndeterminateFlag(false, false);
else if (percentComplete == -1 && !mProgressBar->IsIndeterminate())
mProgressBar->SetIndeterminateFlag(true, true);
if (!mProgressBar->IsIndeterminate()) {
PRInt32 controlVal = min(100, max(0, percentComplete));
mProgressBar->SetValue(controlVal);
}
}
// Set the progress bar as often as we're called. Smooth movement is nice.
// Limit the frequency at which the textual status is updated though.
if (info->mCurProgress == info->mMaxProgress ||
::TickCount() - mLastStatusUpdateTicks >= kStatusUpdateIntervalTicks) {
UpdateStatus(info);
mLastStatusUpdateTicks = ::TickCount();
}
}
break;
default:
ProcessCommand(inMessage, ioParam);
break;
}
}
void CDownloadProgressView::SetDownload(CDownload *aDownload)
{
mDownload = aDownload;
if (!mDownload)
return;
mDownloadActive = true;
mLastStatusUpdateTicks = ::TickCount();
aDownload->AddListener(this);
nsresult rv;
nsCAutoString tempStr;
if (mSrcURIText) {
nsCOMPtr<nsIURI> srcURI;
aDownload->GetSource(getter_AddRefs(srcURI));
if (srcURI) {
rv = srcURI->GetSpec(tempStr);
if (NS_SUCCEEDED(rv))
mSrcURIText->SetText(const_cast<Ptr>(PromiseFlatCString(tempStr).get()), tempStr.Length());
}
}
if (mDestFileText) {
nsCOMPtr<nsILocalFile> destFile;
aDownload->GetTarget(getter_AddRefs(destFile));
if (destFile) {
rv = destFile->GetNativePath(tempStr);
if (NS_SUCCEEDED(rv))
mDestFileText->SetText(const_cast<Ptr>(PromiseFlatCString(tempStr).get()), tempStr.Length());
}
}
// At this point, make sure our window is showing.
LWindow::FetchWindowObject(GetMacWindow())->Show();
}
void CDownloadProgressView::CancelDownload()
{
CDownload *download = dynamic_cast<CDownload*>(mDownload.get());
download->Cancel();
}
Boolean CDownloadProgressView::IsActive()
{
return mDownloadActive;
}
void CDownloadProgressView::UpdateStatus(CDownload::MsgOnDLProgressChangeInfo *info)
{
PRInt64 startTime;
mDownload->GetStartTime(&startTime);
PRInt32 elapsedSecs = (PR_Now() - startTime) / PR_USEC_PER_SEC;
float bytesPerSec = info->mCurProgress / elapsedSecs;
UInt8 startPos;
LStr255 valueStr;
if (mStatusText) {
// "@1 of @2 (at @3/sec)"
LStr255 formatStr(STRx_DownloadStatus, str_ProgressFormat);
// Insert each item into the string individually in order to
// allow certain elements to be omitted from the format.
if ((startPos = formatStr.Find("\p@1")) != 0)
formatStr.Replace(startPos, 2, FormatBytes(info->mCurProgress, valueStr));
if ((startPos = formatStr.Find("\p@2")) != 0)
formatStr.Replace(startPos, 2, FormatBytes(info->mMaxProgress, valueStr));
if ((startPos = formatStr.Find("\p@3")) != 0)
formatStr.Replace(startPos, 2, FormatBytes(bytesPerSec, valueStr));
mStatusText->SetText(formatStr);
}
if (mTimeRemainingText) {
PRInt32 secsRemaining = rint(float(info->mMaxProgress - info->mCurProgress) / bytesPerSec);
mTimeRemainingText->SetText(FormatFuzzyTime(secsRemaining, valueStr));
}
}
LStr255& CDownloadProgressView::FormatBytes(float inBytes, LStr255& ioString)
{
const float kOneThousand24 = 1024.0;
char buf[256];
if (inBytes < 0) {
return (ioString = "???");
}
if (inBytes < kOneThousand24) {
sprintf(buf, "%.1f Bytes", inBytes);
return (ioString = buf);
}
inBytes /= kOneThousand24;
if (inBytes < 1024) {
sprintf(buf, "%.1f KB", inBytes);
return (ioString = buf);
}
inBytes /= kOneThousand24;
if (inBytes < 1024) {
sprintf(buf, "%.1f MB", inBytes);
return (ioString = buf);
}
inBytes /= kOneThousand24;
sprintf(buf, "%.2f GB", inBytes);
return (ioString = buf);
}
LStr255& CDownloadProgressView::FormatFuzzyTime(PRInt32 inSecs, LStr255& ioString)
{
char valueBuf[32];
if (inSecs < 90) {
if (inSecs < 7)
ioString.Assign(STRx_DownloadStatus, str_About5Seconds);
else if (inSecs < 13)
ioString.Assign(STRx_DownloadStatus, str_About10Seconds);
else if (inSecs < 60)
ioString.Assign(STRx_DownloadStatus, str_LessThan1Minute);
else
ioString.Assign(STRx_DownloadStatus, str_About1Minute);
return ioString;
}
inSecs = (inSecs + 30) / 60; // Round up so we don't say "About 1 minutes"
if (inSecs < 60) {
sprintf(valueBuf, "%d", inSecs);
ioString.Assign(STRx_DownloadStatus, str_AboutNMinutes);
ioString.Replace(ioString.Find("\p@1"), 2, LStr255(valueBuf));
return ioString;
}
inSecs /= 60;
if (inSecs == 1)
ioString.Assign(STRx_DownloadStatus, str_About1Hour);
else {
sprintf(valueBuf, "%d", inSecs);
ioString.Assign(STRx_DownloadStatus, str_AboutNHours);
ioString.Replace(ioString.Find("\p@1"), 2, LStr255(valueBuf));
}
return ioString;
}
OSErr CDownloadProgressView::CreateStyleRecFromThemeFont(ThemeFontID inThemeID,
ControlFontStyleRec& outStyle)
{
Str255 themeFontName;
SInt16 themeFontSize;
Style themeStyle;
SInt16 themeFontNum;
OSErr err = ::GetThemeFont(kThemeSmallSystemFont,
smSystemScript,
themeFontName,
&themeFontSize,
&themeStyle);
if (err != noErr)
return err;
outStyle.flags = kControlUseFontMask +
kControlUseFaceMask +
kControlUseSizeMask;
::GetFNum(themeFontName, &themeFontNum);
outStyle.font = themeFontNum;
outStyle.size = themeFontSize;
outStyle.style = themeStyle;
return noErr;
}

Просмотреть файл

@ -21,19 +21,32 @@
*/
#include "UMacUnicode.h"
#include <TextCommon.h>
#include <Script.h>
#include "nsString.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
static TextEncoding getSystemEncoding()
{
OSStatus err;
TextEncoding theEncoding;
err = ::UpgradeScriptInfoToTextEncoding(smSystemScript, kTextLanguageDontCare,
kTextRegionDontCare, NULL, &theEncoding);
if (err != noErr)
theEncoding = kTextEncodingMacRoman;
return theEncoding;
}
CPlatformUCSConversion *CPlatformUCSConversion::mgInstance = nsnull;
UnicodeToTextInfo CPlatformUCSConversion::sEncoderInfo = nsnull;
TextToUnicodeInfo CPlatformUCSConversion::sDecoderInfo = nsnull;
CPlatformUCSConversion::CPlatformUCSConversion() :
mCharsetSel(kPlatformCharsetSel_FileName)
CPlatformUCSConversion::CPlatformUCSConversion()
{
mEncoder = nsnull;
mDecoder = nsnull;
}
@ -47,123 +60,78 @@ CPlatformUCSConversion::GetInstance()
}
NS_IMETHODIMP
CPlatformUCSConversion::SetCharsetSelector(nsPlatformCharsetSel aSel)
{
if (mCharsetSel != aSel) {
mCharsetSel = aSel;
mPlatformCharset.Truncate(0);
mEncoder = nsnull;
mDecoder = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
CPlatformUCSConversion::PreparePlatformCharset()
{
nsresult res = NS_OK;
if (mPlatformCharset.Length() == 0)
{
nsCOMPtr<nsIPlatformCharset> pcharset =
do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
if (!(NS_SUCCEEDED(res) && pcharset)) {
NS_WARNING("cannot get platform charset");
}
if(NS_SUCCEEDED(res) && pcharset) {
res = pcharset->GetCharset(mCharsetSel, mPlatformCharset);
}
}
return res;
}
NS_IMETHODIMP
CPlatformUCSConversion::PrepareEncoder()
{
nsresult res = NS_OK;
if(! mEncoder)
{
res = PreparePlatformCharset();
if(NS_SUCCEEDED(res)) {
nsCOMPtr<nsICharsetConverterManager> ucmgr =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
NS_ASSERTION((NS_SUCCEEDED(res) && ucmgr),
"cannot get charset converter manager ");
if(NS_SUCCEEDED(res) && ucmgr)
res = ucmgr->GetUnicodeEncoder( &mPlatformCharset, getter_AddRefs(mEncoder));
NS_ASSERTION((NS_SUCCEEDED(res) && mEncoder),
"cannot find the unicode encoder");
}
}
return res;
nsresult rv = NS_OK;
if (!sEncoderInfo) {
OSStatus err;
err = ::CreateUnicodeToTextInfoByEncoding(getSystemEncoding(), &sEncoderInfo);
if (err)
rv = NS_ERROR_FAILURE;
}
return rv;
}
NS_IMETHODIMP
CPlatformUCSConversion::PrepareDecoder()
{
nsresult res = NS_OK;
if(! mDecoder)
{
res = PreparePlatformCharset();
if(NS_SUCCEEDED(res)) {
nsCOMPtr<nsICharsetConverterManager> ucmgr =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
NS_ASSERTION((NS_SUCCEEDED(res) && ucmgr),
"cannot get charset converter manager ");
if(NS_SUCCEEDED(res) && ucmgr)
res = ucmgr->GetUnicodeDecoder( &mPlatformCharset, getter_AddRefs(mDecoder));
NS_ASSERTION((NS_SUCCEEDED(res) && mDecoder),
"cannot find the unicode decoder");
}
}
return res;
nsresult rv = NS_OK;
if (!sDecoderInfo) {
OSStatus err;
err = ::CreateTextToUnicodeInfoByEncoding(getSystemEncoding(), &sDecoderInfo);
if (err)
rv = NS_ERROR_FAILURE;
}
return rv;
}
NS_IMETHODIMP
CPlatformUCSConversion::UCSToPlatform(const nsAString& aIn, nsACString& aOut)
{
nsresult res;
nsresult rv = PrepareEncoder();
if (NS_FAILED(rv)) return rv;
OSStatus err = noErr;
char stackBuffer[512];
aOut.Truncate(0);
res = PrepareEncoder();
if(NS_SUCCEEDED(res))
{
nsReadingIterator<PRUnichar> done_reading;
aIn.EndReading(done_reading);
nsReadingIterator<PRUnichar> done_reading;
aIn.EndReading(done_reading);
// for each chunk of |aIn|...
PRUint32 fragmentLength = 0;
nsReadingIterator<PRUnichar> iter;
for (aIn.BeginReading(iter); iter != done_reading && NS_SUCCEEDED(res); iter.advance(PRInt32(fragmentLength)))
{
fragmentLength = PRUint32(iter.size_forward());
PRInt32 inLength = fragmentLength;
PRInt32 outLength;
res = mEncoder->GetMaxLength(iter.get(), fragmentLength, &outLength);
if (NS_SUCCEEDED(res))
{
char *outBuf = (char*)nsMemory::Alloc(outLength);
if (outBuf)
{
res = mEncoder->Convert(iter.get(), &inLength, outBuf, &outLength);
if (NS_SUCCEEDED(res))
aOut.Append(outBuf, outLength);
nsMemory::Free(outBuf);
}
else
res = NS_ERROR_OUT_OF_MEMORY;
// for each chunk of |aIn|...
PRUint32 fragmentLength = 0;
nsReadingIterator<PRUnichar> iter;
for (aIn.BeginReading(iter); iter != done_reading && err == noErr; iter.advance(PRInt32(fragmentLength)))
{
fragmentLength = PRUint32(iter.size_forward());
UInt32 bytesLeft = fragmentLength * sizeof(UniChar);
nsReadingIterator<PRUnichar> sub_iter(iter);
do {
UInt32 bytesRead = 0, bytesWritten = 0;
err = ::ConvertFromUnicodeToText(sEncoderInfo,
bytesLeft,
(const UniChar*)sub_iter.get(),
kUnicodeUseFallbacksMask | kUnicodeLooseMappingsMask,
0, nsnull, nsnull, nsnull,
sizeof(stackBuffer),
&bytesRead,
&bytesWritten,
stackBuffer);
if (err == kTECUsedFallbacksStatus)
err = noErr;
else if (err == kTECOutputBufferFullStatus) {
bytesLeft -= bytesRead;
sub_iter.advance(bytesRead / sizeof(UniChar));
}
aOut.Append(stackBuffer, bytesWritten);
}
}
return res;
while (err == kTECOutputBufferFullStatus);
}
return (err == noErr) ? NS_OK : NS_ERROR_FAILURE;
}
@ -189,41 +157,47 @@ CPlatformUCSConversion::UCSToPlatform(const nsAString& aIn, Str255& aOut)
NS_IMETHODIMP
CPlatformUCSConversion::PlatformToUCS(const nsACString& aIn, nsAString& aOut)
{
nsresult res;
nsresult rv = PrepareDecoder();
if (NS_FAILED(rv)) return rv;
OSStatus err = noErr;
UniChar stackBuffer[512];
aOut.Truncate(0);
res = PrepareDecoder();
if (NS_SUCCEEDED(res))
nsReadingIterator<char> done_reading;
aIn.EndReading(done_reading);
// for each chunk of |aIn|...
PRUint32 fragmentLength = 0;
nsReadingIterator<char> iter;
for (aIn.BeginReading(iter); iter != done_reading && err == noErr; iter.advance(PRInt32(fragmentLength)))
{
nsReadingIterator<char> done_reading;
aIn.EndReading(done_reading);
// for each chunk of |aIn|...
PRUint32 fragmentLength = 0;
nsReadingIterator<char> iter;
for (aIn.BeginReading(iter); iter != done_reading && NS_SUCCEEDED(res); iter.advance(PRInt32(fragmentLength)))
{
fragmentLength = PRUint32(iter.size_forward());
PRInt32 inLength = fragmentLength;
PRInt32 outLength;
res = mDecoder->GetMaxLength(iter.get(), inLength, &outLength);
if (NS_SUCCEEDED(res))
{
PRUnichar *outBuf = (PRUnichar*)nsMemory::Alloc(outLength * sizeof(PRUnichar));
if (outBuf)
{
res = mDecoder->Convert(iter.get(), &inLength, outBuf, &outLength);
if(NS_SUCCEEDED(res))
aOut.Append(outBuf, outLength);
nsMemory::Free(outBuf);
}
else
res = NS_ERROR_OUT_OF_MEMORY;
fragmentLength = PRUint32(iter.size_forward());
UInt32 bytesLeft = fragmentLength;
nsReadingIterator<char> sub_iter(iter);
do {
UInt32 bytesRead = 0, bytesWritten = 0;
err = ::ConvertFromTextToUnicode(sDecoderInfo,
bytesLeft,
sub_iter.get(),
kUnicodeUseFallbacksMask | kUnicodeLooseMappingsMask,
0, nsnull, nsnull, nsnull,
sizeof(stackBuffer),
&bytesRead,
&bytesWritten,
stackBuffer);
if (err == kTECUsedFallbacksStatus)
err = noErr;
else if (err == kTECOutputBufferFullStatus) {
bytesLeft -= bytesRead;
sub_iter.advance(bytesRead);
}
aOut.Append((PRUnichar *)stackBuffer, bytesWritten / sizeof(PRUnichar));
}
}
return res;
while (err == kTECOutputBufferFullStatus);
}
return (err == noErr) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP

Просмотреть файл

@ -23,12 +23,10 @@
#ifndef __UMacUnicode__
#define __UMacUnicode__
#include "nsIPlatformCharset.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include <UnicodeConverter.h>
class CPlatformUCSConversion {
public:
@ -36,9 +34,7 @@ public:
virtual ~CPlatformUCSConversion(){};
static CPlatformUCSConversion* GetInstance();
NS_IMETHOD SetCharsetSelector(nsPlatformCharsetSel aSel);
NS_IMETHOD UCSToPlatform(const nsAString& aIn, nsACString& aOut);
NS_IMETHOD UCSToPlatform(const nsAString& aIn, Str255& aOut);
@ -47,15 +43,11 @@ public:
private:
static CPlatformUCSConversion *mgInstance;
static UnicodeToTextInfo sEncoderInfo;
static TextToUnicodeInfo sDecoderInfo;
NS_IMETHOD PreparePlatformCharset();
NS_IMETHOD PrepareEncoder();
NS_IMETHOD PrepareDecoder();
nsPlatformCharsetSel mCharsetSel;
nsAutoString mPlatformCharset;
nsCOMPtr<nsIUnicodeEncoder> mEncoder;
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
nsresult PrepareEncoder();
nsresult PrepareDecoder();
};
#endif // __UMacUnicode__

Просмотреть файл

@ -0,0 +1,65 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Conrad Carlen <ccarlen@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifdef MOZ_DEBUG
BUILDSTYLE = Development
else
BUILDSTYLE = Deployment
endif
include $(topsrcdir)/config/rules.mk
ABS_topsrcdir := $(shell cd $(topsrcdir); pwd)
ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
export::
rsync -a --exclude .DS_Store --exclude "CVS/" $(srcdir)/PowerPlant.pbproj .
ln -fs $(srcdir)/pch
ln -fs $(srcdir)/resources
endif
libs::
pbxbuild -buildstyle $(BUILDSTYLE) build
clean clobber::
rm -rf build

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,150 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// PowerPlant Config
#define PP_Target_Carbon 1
#define PP_Suppress_Notes_221 1
#define PP_MenuUtils_Option PP_MenuUtils_AppearanceOnly
#define PP_Uses_Aqua_MenuBar 1
// Carbon Headers
#include <Carbon/Carbon.h>
// PowerPlant Headers
#include <LAction.h>
#include <LUndoer.h>
#include <UTETextAction.h>
#include <UTEViewTextAction.h>
#include <LModelDirector.h>
#include <LModelObject.h>
#include <LModelProperty.h>
#include <UAppleEventsMgr.h>
#include <UExtractFromAEDesc.h>
#include <LArray.h>
#include <LArrayIterator.h>
#include <LComparator.h>
#include <LRunArray.h>
#include <LVariableArray.h>
#include <TArray.h>
#include <TArrayIterator.h>
#include <LApplication.h>
#include <LCommander.h>
#include <LDocApplication.h>
#include <LDocument.h>
#include <LSingleDoc.h>
#include <LAttachable.h>
#include <LAttachment.h>
#include <LBroadcaster.h>
#include <LDragAndDrop.h>
#include <LDragTask.h>
#include <LEventDispatcher.h>
#include <LListener.h>
#include <LPeriodical.h>
#include <LSharable.h>
#include <LDataStream.h>
#include <LFile.h>
#include <LFileStream.h>
#include <LHandleStream.h>
#include <LStream.h>
#include <LButton.h>
#include <LCaption.h>
#include <LCicnButton.h>
#include <LControl.h>
#include <LDialogBox.h>
#include <LEditField.h>
#include <LFocusBox.h>
#include <LGrafPortView.h>
#include <LListBox.h>
#include <LOffscreenView.h>
#include <LPane.h>
#include <LPicture.h>
#include <LPlaceHolder.h>
#include <LPrintout.h>
#include <LRadioGroupView.h>
#include <LScroller.h>
#include <LStdControl.h>
#include <LTabGroupView.h>
#include <LTableView.h>
#include <LTextEditView.h>
#include <LView.h>
#include <LWindow.h>
#include <UGWorld.h>
#include <UQuickTime.h>
#include <PP_Constants.h>
#include <PP_KeyCodes.h>
#include <PP_Macros.h>
#include <PP_Messages.h>
#include <PP_Prefix.h>
#include <PP_Resources.h>
#include <PP_Types.h>
#include <LClipboard.h>
#include <LFileTypeList.h>
#include <LMenu.h>
#include <LMenuBar.h>
#include <LRadioGroup.h>
#include <LString.h>
#include <LTabGroup.h>
#include <UDesktop.h>
#include <UAttachments.h>
#include <UCursor.h>
#include <UDebugging.h>
#include <UDrawingState.h>
#include <UDrawingUtils.h>
#include <UEnvironment.h>
#include <UException.h>
#include <UKeyFilters.h>
#include <UMemoryMgr.h>
#include <UModalDialogs.h>
#include <UPrinting.h>
#include <UReanimator.h>
#include <URegions.h>
#include <URegistrar.h>
#include <UScrap.h>
#include <UScreenPort.h>
#include <UTextEdit.h>
#include <UTextTraits.h>
#include <UWindows.h>

Двоичные данные
lib/mac/PowerPlant/resources/English.lproj/InfoPlist.strings Normal file

Двоичный файл не отображается.