Removing files that were cvs-copied as part of bug 237745. I apologize for not doing this sooner.

This commit is contained in:
bsmedberg%covad.net 2004-12-03 14:31:22 +00:00
Родитель 8ae2763ceb
Коммит 1886e88ad8
20 изменённых файлов: 0 добавлений и 3191 удалений

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

@ -1,576 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#define MOZILLA_FIVE
/*--------------------------------------------------------------------------*/
/* ---- Resource and Command Code Base IDs ---- */
/* In Communicator 4.x, this was cmd/macfe/include/resae.h */
/* See also xpfe/bootstrap/nsAppleEvents.r for the res definitions */
/*--------------------------------------------------------------------------*/
// ---- Base Values for Apple Event Command sets
//----------------------------------------------------------------------------------------
#define kSpyGlass_CmdBase 5000 // Base value for SpyGlass commands
#define kURLSuite_CmdBase 5100 // Base value for URL commands
// ---- aedt Resource IDs used to associate Commands with Event Suite and ID pairs
//----------------------------------------------------------------------------------------
enum {
kRequired_aedtResID = 128, // Resource ID for Required suite's aedt resource
kCore_aedtResID, // Resource ID for Core suite's aedt resource
kMisc_aedtResID, // Resource ID for Misc suite's aedt resource
kPowerPlant_aedtResID, // Resource ID for PowerPlant suite's aedt resource
kURLSuite_aedtResID, // Resource ID for URL suite's aedt resource
kSpyGlass_aedtResID // Resource ID for SpyGlass suite's aedt resource
};
/*--------------------------------------------------------------------------*/
/* ---- Event Command Codes ---- */
/*--------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
The Apple Events Template resource 'aedt' (found in Types.r)
is used to associate an Event Class and Event ID with a
unique integer value. These integer values are private to the
application processing the events.
restriction: PowerPlant uses integer valuse below 4000
----------------------------------------------------------------------------*/
// ---- World Wide Web / Spyglass Suite
//----------------------------------------------------------------------------------------
enum {
AE_OpenURL = kSpyGlass_CmdBase // OpenURL WWW! OURL
#ifndef MOZILLA_FIVE
, AE_RegisterViewer // RegisterViewer WWW! RGVW
, AE_UnregisterViewer // UnregisterViewer WWW! UNRV
, AE_ShowFile // ShowFile WWW! SHWF
, AE_ParseAnchor // ParseAnchor WWW! PRSA
, AE_RegisterURLEcho // Register URL echo WWW! RGUE
, AE_UnregisterURLEcho // Unregister URL echo WWW! UNRU
, AE_SpyActivate // Activate WWW! ACTV
, AE_SpyListWindows // ListWindows WWW! LSTW
, AE_GetWindowInfo // GetWindowInfo WWW! WNFO
, AE_RegisterWinClose // RegisterWindowClose WWW! RGWC
, AE_UnregisterWinClose // UnregisterWindowClose WWW! UNRC
, AE_RegisterProtocol // RegisterProtocol WWW! RGPR
, AE_UnregisterProtocol // UnregisterProtocol WWW! UNRP
, AE_CancelProgress // Cancel download WWW! CNCL
, AE_FindURL // Find the URL for the file WWW! FURL
#endif // MOZILLA_FIVE
};
// ---- Netscape Experimental Suite and Macintosh URL suite
//----------------------------------------------------------------------------------------
enum {
#ifdef MOZILLA_FIVE
AE_GetURL = kURLSuite_CmdBase // GetURL GURL GURL
, AE_DoJavascript // Do Javascript MOSS jscr
#else
AE_GetWD = kURLSuite_CmdBase // Get working directory of app MOSS WURL
, AE_OpenBookmark // Open bookmarks MOSS book
, AE_ReadHelpFile // Read help file MOSS help
, AE_Go // Go MOSS gogo
, AE_OpenProfileManager // Launch app with user profile mgr MOSS prfl
, AE_GetURL // GetURL GURL GURL
, AE_OpenAddressBook // Open Address Book MOSS addr
, AE_OpenComponent // Open a component MOSS cpnt
, AE_GetActiveProfile // Get the name of the active profile MOSS upro
, AE_HandleCommand // Handle a command ae MOSS ncmd
, AE_GetProfileImportData // Handle a request from import module MOSS Impt
, AE_OpenGuestMode // Open in guest (roaming) kiosk mode MOSS gues
#endif // MOZILLA_FIVE
};
// ---- The so called Option Suite. Never implemented, left here for historical purposes
//----------------------------------------------------------------------------------------
#define AE_GetOption 4016 // GetOption
#define AE_SetOption 4017 // SetOption
#define AE_ListOptions 4018 // ListOptions
// ---- These are supposed to be "Events We Send" but I don't see these constants used
//----------------------------------------------------------------------------------------
#define AE_ViewDocFile 4019 // ViewDocFile
#define AE_BeginProgress 4020 // Begin progress
#define AE_SetProgressRange 4021 // Set progress range
#define AE_MakingProgress 4022 // Making progress
#define AE_EndProgress 4023 // End progress
#define AE_QueryViewer 4024 // Query viewer
#define AE_URLEcho 4026 // URL echo
#define AE_WindowClose 4027 // WindowClose
/*----------------------------------------------------------------------------
List of Suites, Event IDs, and (I guess) parameters for events.
This information is public and needed by any application wanting
to send Apple Events to our application.
----------------------------------------------------------------------------*/
/*********************************************************************************
* Netscape suite
* Event: Go
* Arguments: keyDirectObject (objectSpecifier for a window
* direction (stil in flux, currently back, forward, home, and again)
* should really be a history object
*********************************************************************************/
// Event codes
#define AE_www_suite 'MOSS'
#define AE_www_doJavaScript 'jscr' // Execute a javascript string
#ifndef MOZILLA_FIVE
#define AE_www_workingURL 'wurl' // Get working URL
#define AE_www_go 'gogo' // keyDirectObject HWIN, direction 'dire'
// direction can be kAENext, kAEPrevious, AE_www_go_again, AE_www_go_home
#define AE_www_go_direction 'dire' // directions
#define AE_www_go_again 'agai' // keyDirectObject HWIN
#define AE_www_go_home 'home' // keyDirectObject HWIN
#define AE_www_super_reload 'srld' // keyDirectObject HWIN
#define AE_www_openBookmark 'book' // Open Bookmark file
#define AE_www_openAddressBook 'addr' // Open Address Book
#define AE_www_ReadHelpFile 'help' // keyDirectObject is the file
#define AE_www_ReadHelpFileID 'idid' // Help file id. If none, use "DEFAULT"
#define AE_www_ReadHelpFileSearchText 'sear' // Search text, no default
#define AE_www_ProfileManager 'prfl' //obsolete
#define AE_www_GuestMode 'gues' // Open in guest (roaming only) mode for kiosks
//Component stuff
#define AE_www_openComponent 'cpnt'
#define AE_www_comp_navigator 'navg'
#define AE_www_comp_inbox 'inbx'
#define AE_www_comp_collabra 'colb'
#define AE_www_comp_composer 'cpsr'
#define AE_www_comp_conference 'conf'
#define AE_www_comp_calendar 'cald'
#define AE_www_comp_ibmHostOnDemand 'ibmh'
#define AE_www_comp_netcaster 'netc'
//Handle a command
#define AE_www_handleCommand 'hcmd'
//Get active profile
#define AE_www_getActiveProfile 'upro'
// Handle request from an external import module for relevant data
#define AE_www_getImportData 'Impt'
#endif // MOZILLA_FIVE
// Objects
#define AE_www_typeWindow 'HWIN'
// window properties
#define AE_www_typeWindowURL 'curl' // Property: current URL
#define AE_www_typeWindowID 'wiid' // unique ID
#define AE_www_typeWindowBusy 'busy' // Are we busy
// application properties
#define AE_www_typeApplicationAlert 'ALAP'
#define AE_www_typeKioskMode 'KOSK' // Kiosk mode
/*********************************************************************************
* URL suite
* Standard Mac "GetURL suite, as defined by John Norstad and others
* Look around ftp://ftp.acns.nwu.edu/pub/newswatcher/ for official spec
* Event: GetURL
* Arguments: keyDirectObject (typeText, the url
* to (destination) (typeFSS optional file to save to)
* from (refererer) (typeText, the referer)
* with (window) (typeObjectSpec, the window)
*********************************************************************************/
#define AE_url_suite 'GURL'
// Event codes
#define AE_url_getURL 'GURL' // keyDirectObject typeChar URL,
// AE_www_typeWindow window window to load the url in
#define AE_url_getURLdestination 'dest'
#define AE_url_getURLrefererer 'refe'
#define AE_url_getURLname 'name' // window name
/*********************************************************************************
* "Spyglass" suite
* http://www.spyglass.com:4040/newtechnology/integration/iapi.htm
*
* Accepted events:
* Event: OpenURL
* Arguments:
* S: keyDirectObject typeChar the url
* S: typeFSS into
* S: typeLongInteger windowID (unique window ID for applescript)
* typeLongInteger flags -- unused
* S: typeWildCard post data -- you can post a form
* S: typeChar MIME type -- for post. Defaults to application/x-www-form-urlencoded
* S: typePSN Progress app
* Reply: windowID
*
* Event: RegisterViewer
* Arguments:
* keyDirectObject typeApplSignature
* typeChar MIME type
* Reply: bool success
*
* Event: UnRegisterViewer
* keyDirectObject typeApplSignature
* typeChar MIME type
* Reply: none
*
* Event: RegisterURLEcho
* keyDirectObject typeApplSignature (optional). Otherwise, sender is used
* Reply: typeBoolean on success, errAECoercionFail if already registered
*
* Event: UnregisterURLEcho
* keyDirectObject typeApplSignature (optional). Otherwise, sender is used
*
* SENDING:
* Event: ViewDocFile
* Arguments:
* keyDirectObject typeAlias file spec
* typeChar url
* typeChar mime type
* typeLongInteger window id
* Reply: none
*
* Event: BeginProgress
* Arguments:
* keyDirectObject typeLongInteger windowID
* typeChar message
* Reply: typeLongInteger transactionID
*
* Event: SetProgressRange
* Arguments:
* keyDirectObject typeLongInteger transactionID
* typeLongInteger max value. -1 if the value is unknown
* Reply: none
*
* Event: MakingProgress
* Arguments:
* keyDirectObject typeLongInteger transactionID
* typeText message
* typeLongInteger current value of the transaction
* Reply: typeBoolean cancel
*
* Event: EndProgress
* Arguments:
* keyDirectObject typeLongInteger transactionID
* Reply: none
*
* Event: QueryViewer
* Arguments:
* keyDirectObject typeChar url
* typeChar MIME type
* Reply: typeFSS fileSpec
*
* Event: ShowFile
* Arguments:
* keyDirectObject typeAlias -- the file
*
*********************************************************************************/
#define AE_spy_receive_suite 'WWW!'
#define AE_spy_send_suite 'WWW?'
// ===================== RECEIVING ==========================
// ================== Miscelaneous events
// ****************** OpenURL
#define AE_spy_openURL 'OURL' // typeChar OpenURL
#define AE_spy_openURL_flag 'FLGS' // typeLongInteger flags
#define AE_spy_openURL_wind 'WIND' // typeLongInteger windowID
#if 0 // Not supported in Mozilla
#define AE_spy_openURL_into 'INTO' // typeFSS into
#define AE_spy_openURL_post 'POST' // typeWildCard post data
#define AE_spy_openURL_mime 'MIME' // typeChar MIME type
#define AE_spy_openURL_prog 'PROG' // typePSN Progress app
// ****************** ShowFile
#define AE_spy_showFile 'SHWF' // typeAlias file spec
#define AE_spy_showFile_mime 'MIME' // typeChar MIME type
#define AE_spy_showFile_win 'WIND' // WindowID
#define AE_spy_showFile_url 'URL ' // URL
// ****************** ParseAnchor
#define AE_spy_parse 'PRSA' // typeChar main URL
#define AE_spy_parse_rel 'RELA' // typeChar relative URL
// ****************** Progress (receiving)
#define AE_spy_CancelProgress 'CNCL' // typeLongInteger transactionID
#define AE_spy_CancelProgress_win 'WIND' // typeLongInteger windowID
// ****************** FindURL
#define AE_spy_findURL 'FURL' // typeFSS file spec. Returns the URL of the file
// =================== Windows
// ****************** Activate
#define AE_spy_activate 'ACTV' // typeLong window ID
#define AE_spy_activate_flags 'FLGS' // typeLong unused flags
// ****************** ListWindows
#define AE_spy_listwindows 'LSTW' // no arguments
// ****************** GetWindowInfo
#define AE_spy_getwindowinfo 'WNFO' // typeLong window
//
// ================== Registration events
//
// ****************** RegisterURLEcho
#define AE_spy_registerURLecho 'RGUE' // typeApplSignature application
// ****************** UnregisterURLEcho
#define AE_spy_unregisterURLecho 'UNRU' // typeApplSignature application
// ****************** RegisterViewer
#define AE_spy_registerViewer 'RGVW' // typeSign Application
#define AE_spy_registerViewer_mime 'MIME' // typeChar Mime type
#define AE_spy_registerViewer_flag 'MTHD' // typeLongInteger Flags
#define AE_spy_registerViewer_ftyp 'FTYP' // file type
// ****************** UnregisterViewer
#define AE_spy_unregisterViewer 'UNRV' // typeApplSignature application
#define AE_spy_unregisterViewer_mime 'MIME' // MIME type
// ****************** Register protocol
#define AE_spy_register_protocol 'RGPR' // typeApplSignature application
#define AE_spy_register_protocol_pro 'PROT' // typeChar protocol
// ****************** Unregister protocol
#define AE_spy_unregister_protocol 'UNRP' // typeApplSignature application
#define AE_spy_register_protocol_pro 'PROT' // typeChar protocol
// ****************** RegisterWindowClose
#define AE_spy_registerWinClose 'RGWC' // typeApplSignature application
#define AE_spy_registerWinClose_win 'WIND'// typeLong window
// ****************** UnregisterWindowClose
#define AE_spy_unregisterWinClose 'UNRC' // typeApplSignature application
#define AE_spy_unregisterWinClose_win 'WIND'// typeLong window
// ****************** SetOption
#define AE_spy_setOption 'SOPT' // typeChar option name
#define AE_spy_setOption_value 'OPTV' // type depends upon the option
// ****************** GetOption
#define AE_spy_getOption 'GOPT' // typeChar option name
// ****************** ListOptions
#define AE_spy_listOptions 'LOPT' // no arguments
//
// ===================== SENDING ============================
//
// ViewDocFile
#define AE_spy_viewDocFile 'VDOC' // typeAlias fileSpec
#define AE_spy_viewDocFile_url 'URL ' // typeChar url
#define AE_spy_viewDocFile_mime 'MIME' // typeChar mimeType
#define AE_spy_viewDocFile_wind 'WIND' // typeLongInteger Window ID
// BeginProgress
#define AE_spy_beginProgress 'PRBG' // typeLongInteger windowID
#define AE_spy_beginProgress_msg 'PMSG' // typeChar message
// SetProgressRange
#define AE_spy_setProgressRange 'PRSR' // typeLongInteger transactionID
#define AE_spy_setProgressRange_max 'MAXV' // typeLongInteger max
// MakingProgress
#define AE_spy_makingProgress 'PRMK' // typeLongInteger transactionID
#define AE_spy_makingProgress_msg 'PMSG' // typeChar message
#define AE_spy_makingProgress_curr 'CURR' // typeLongInteger current data size
// EndProgress
#define AE_spy_endProgress 'PREN' // typeLongInteger transactionID
// QueryViewer
#define AE_spy_queryViewer 'QVWR' // typeChar url
#define AE_spy_queryViewer_mime 'MIME' // typeChar MIME type
// URLEcho
#define AE_spy_URLecho 'URLE' // typeChar url
#define AE_spy_URLecho_mime 'MIME' // typeChar MIME type
#define AE_spy_URLecho_win 'WIND' // typeLongInt windowID
#define AE_spy_URLecho_referer 'RFRR' // typeChar referer
// Window closed
#define AE_spy_winClosed 'WNDC' // typeLong windowID
#define AE_spy_winClosedExiting 'EXIT' // typeBoolean are we quitting?
#endif // 0 - not supported in Mozilla.
/*--------------------------------------------------------------------------*/
/* ---- Eudora Suite ---- */
/*--------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
Client applications can manipulate our Mail system to send, receive
and do other mail operations by remote contro.
We can also
----------------------------------------------------------------------------*/
// ---- Class Definitions for objects Eudora can manipulate
//----------------------------------------------------------------------------------------
#define cEuMailfolder 'euMF' // Class: folder for mailboxes and mail folders
#define pEuTopLevel 'euTL' // Property boolean: is top-level of Eudora Folder?
#define pEuFSS 'euFS' // Property alias: FSS for file
#define cEuMailbox 'euMB' /* mailbox */
#define pEuMailboxType 'euMT' /* in, out, trash, ... */
#define pEuWasteSpace 'euWS' /* space wasted in mailbox */
#define pEuNeededSpace 'euNS' /* space needed by messages in mailbox */
#define pEuTOCFSS 'eTFS' /* FSS for toc file (pEuFSS is for mailbox) */
#define cEuNotify 'eNot' /* applications to notify */
/* pEuFSS is the fsspec */
#define cEuMessage 'euMS' /* message */
#define pEuPriority 'euPY' /* priority */
#define pEuStatus 'euST' /* message status */
#define pEuSender 'euSe' /* sender */
#define pEuDate 'euDa' /* date */
#define pEuSize 'euSi' /* size */
#define pEuSubject 'euSu' /* subject */
#define pEuOutgoing 'euOu' /* outgoing? */
#define pEuSignature 'eSig' /* signature? */
#define pEuWrap 'eWrp' /* wrap? */
#define pEuFakeTabs 'eTab' /* fake tabs? */
#define pEuKeepCopy 'eCpy' /* keep copy? */
#define pEuHqxText 'eXTX' /* HQX -> TEXT? */
#define pEuMayQP 'eMQP' /* may use quoted-printable? */
#define pEuAttachType 'eATy' /* attachment type; 0 double, 1 single, 2 hqx, 3 uuencode */
#define pEuShowAll 'eBla' /* show all headers */
#define pEuTableId 'eTbl' /* resource id of table */
#define pEuBody 'eBod' /* resource id of table */
#define pEuSelectedText 'eStx' /* the text selected now */
#define pEuWillFetch 'eWFh' /* is on list to fetch next time */
#define pEuWillDelete 'eWDl' /* is on list to delete next time */
#define pEuReturnReceipt 'eRRR' /* return receipt requested */
#define pEuLabel 'eLbl' /* label index */
#define cEuField 'euFd' /* field in message */
#define cEu822Address 'e822' /* RFC 822 address */
#define cEuTEInWin 'EuWT' /* the teh of a window */
#define cEuWTEText 'eWTT' /* text from the teh of a window */
#define cEuPreference 'ePrf' /* a preference string */
#define kEudoraSuite 'CSOm' /* Eudora suite */
#define keyEuNotify 'eNot' /* Notify of new mail */
#define kEuNotify keyEuNotify
#define kEuInstallNotify 'nIns' /* install a notification */
#define kEuRemoveNotify 'nRem' /* remove a notification */
#define keyEuWhatHappened 'eWHp' /* what happened */
#define keyEuMessList 'eMLs' /* Message list */
#define eMailArrive 'wArv' /* mail has arrived */
#define eMailSent 'wSnt' /* mail has been sent */
#define eWillConnect 'wWCn' /* will connect */
#define eHasConnected 'wHCn' /* has connected */
#define kEuReply 'eRep' /* Reply */
#define keyEuToWhom 'eRWh' /* Reply to anyone in particular? */
#define keyEuReplyAll 'eRAl' /* Reply to all? */
#define keyEuIncludeSelf 'eSlf' /* Include self? */
#define keyEuQuoteText 'eQTx' /* Quote original message text? */
#define kEuForward 'eFwd' /* Forward */
#define kEuRedirect 'eRdr' /* Redirect */
#define kEuSalvage 'eSav' /* Salvage a message */
#define kEuAttach 'eAtc' /* Attach a document */
#define keyEuDocumentList 'eDcl' /* List of dox to attach */
#define kEuQueue 'eQue' /* Queue a message */
#define keyEuWhen 'eWhn' /* When to send message */
#define kEuUnQueue 'eUnQ' /* Unqueue a message */
#define kEuConnect 'eCon' /* Connect (send/queue) */
#define keyEuSend 'eSen'
#define keyEuCheck 'eChk'
#define keyEuOnIdle 'eIdl' /* wait until Eudora is idle? */
#define kEuNewAttach 'euAD' /* attach document, new style */
#define keyEuToWhat 'euMS' /* attach to what message? */
#define typeVDId 'VDId' /* vref & dirid */
#define kIn IN
#define kOut OUT
#define kTrash TRASH
#define KRegular 0

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

@ -1,50 +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) 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 ***** */
#include "nsISupports.idl"
[scriptable, uuid(2f977d49-5485-11d4-87e2-0010a4e75ef2)]
interface nsICloseAllWindows : nsISupports
{
/**
* Closes all open windows, optionally asking to confirm changes if any.
* @return TRUE if the user does not cancel from any confirmation dialog.
*/
boolean closeAll(in boolean askSave);
};

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

@ -1,205 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
%{C++
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
#define PREF_STARTUP_PREFIX "general.startup."
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsICategoryManager.h"
#include "nsIFile.h"
#include "nsIServiceManager.h"
struct nsModuleComponentInfo; // forward declaration
#define CMDLINEHANDLER_REGISTERPROC_DECLS \
static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info); \
static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info);
#define CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \
{ \
if (!aDefaultArgs) return NS_ERROR_FAILURE; \
*aDefaultArgs = ToNewUnicode(nsDependentCString(macro_default_args)); \
return NS_OK; \
}
#define CMDLINEHANDLER_GETCHROMEURL_IMPL(macro_class,macro_chrome_url)\
NS_IMETHODIMP macro_class::GetChromeUrlForTask(char **aChromeUrlForTask) \
{ \
if (!aChromeUrlForTask) return NS_ERROR_FAILURE; \
*aChromeUrlForTask = PL_strdup(macro_chrome_url); \
return NS_OK; \
}
#define CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_help_text, macro_handles_args, macro_open_window_with_args)\
NS_IMETHODIMP macro_class::GetCommandLineArgument(char **aCommandLineArgument) \
{ \
if (!aCommandLineArgument) return NS_ERROR_FAILURE; \
*aCommandLineArgument = PL_strdup(macro_cmd_line_arg); \
return NS_OK; \
} \
NS_IMETHODIMP macro_class::GetPrefNameForStartup(char **aPrefNameForStartup) \
{ \
if (!aPrefNameForStartup) return NS_ERROR_FAILURE; \
*aPrefNameForStartup = PL_strdup(macro_pref_name); \
return NS_OK; \
} \
NS_IMETHODIMP macro_class::GetHelpText(char **aHelpText) \
{ \
if (!aHelpText) return NS_ERROR_FAILURE; \
*aHelpText = PL_strdup(macro_help_text); \
return NS_OK; \
} \
NS_IMETHODIMP macro_class::GetHandlesArgs(PRBool *aHandlesArgs) \
{ \
if (!aHandlesArgs) return NS_ERROR_FAILURE; \
*aHandlesArgs = macro_handles_args; \
return NS_OK; \
} \
NS_IMETHODIMP macro_class::GetOpenWindowWithArgs(PRBool *aOpenWindowWithArgs) \
{ \
if (!aOpenWindowWithArgs) return NS_ERROR_FAILURE; \
*aOpenWindowWithArgs = macro_open_window_with_args; \
return NS_OK; \
}
#define CMDLINEHANDLER_REGISTERPROC_IMPL(macro_class, \
macro_pretty_name, \
macro_contractid) \
NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info) \
{ \
nsresult rv; \
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv); \
if (NS_FAILED(rv)) return rv; \
nsXPIDLCString prevEntry; \
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_pretty_name, macro_contractid, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
return NS_OK; \
} \
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info) \
{ \
nsresult rv; \
nsCOMPtr<nsICategoryManager> catman = do_GetService("@mozilla.org/categorymanager;1", &rv); \
if (NS_FAILED(rv)) return rv; \
rv = catman->DeleteCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_contractid, PR_TRUE); \
return NS_OK; \
}
// basic definition
#define CMDLINEHANDLER1_IMPL(macro_class, \
macro_cmd_line_arg, \
macro_pref_name, \
macro_help_text, \
macro_handles_args, \
macro_default_args, \
macro_open_window_with_args)\
CMDLINEHANDLER_OTHERS_IMPL(macro_class, macro_cmd_line_arg,macro_pref_name,\
macro_help_text, macro_handles_args, \
macro_open_window_with_args)
// provides everything above, plus GetChromeUrl and regproc stuff
#define CMDLINEHANDLER2_IMPL(macro_class, \
macro_cmd_line_arg, \
macro_pref_name, \
macro_chrome_url, \
macro_help_text, \
macro_contractid, \
macro_pretty_name, \
macro_handles_args, \
macro_open_window_with_args) \
CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,\
macro_help_text, macro_handles_args, \
macro_open_window_with_args) \
CMDLINEHANDLER_REGISTERPROC_IMPL(macro_class, macro_pretty_name, \
macro_contractid) \
CMDLINEHANDLER_GETCHROMEURL_IMPL(macro_class,macro_chrome_url)
// deprecated: includes everything above, plus getdefaultargs
#define CMDLINEHANDLER_IMPL(macro_class, \
macro_cmd_line_arg,\
macro_pref_name, \
macro_chrome_url,\
macro_help_text, \
macro_contractid, \
macro_pretty_name, \
macro_handles_args, \
macro_default_args, \
macro_open_window_with_args) \
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args) \
CMDLINEHANDLER2_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name, \
macro_chrome_url,macro_help_text, macro_contractid, \
macro_pretty_name, macro_handles_args, \
macro_open_window_with_args)
//Creates a version without the GetChromeUrlForTaskFunction
#define CMDLINEHANDLER3_IMPL(macro_class, \
macro_cmd_line_arg, \
macro_pref_name, \
macro_help_text, \
macro_contractid, \
macro_pretty_name, \
macro_handles_args, \
macro_default_args, \
macro_open_window_with_args)\
CMDLINEHANDLER_GETDEFAULTARGS_IMPL(macro_class,macro_default_args)\
CMDLINEHANDLER_OTHERS_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,\
macro_help_text, macro_handles_args, \
macro_open_window_with_args) \
CMDLINEHANDLER_REGISTERPROC_IMPL(macro_class, macro_pretty_name, \
macro_contractid)
%}
[scriptable, uuid(ae12670a-1dd1-11b2-80cd-82ec93559deb)]
interface nsICmdLineHandler : nsISupports
{
readonly attribute string commandLineArgument;
readonly attribute string prefNameForStartup;
readonly attribute string chromeUrlForTask;
readonly attribute string helpText;
readonly attribute boolean handlesArgs;
readonly attribute wstring defaultArgs;
readonly attribute boolean openWindowWithArgs;
};

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

@ -1,94 +0,0 @@
/* -*- Mode: IDL; 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
#include "nsIFactory.idl"
#include "nsICmdLineHandler.idl"
[ptr] native charArray(char*);
[scriptable, uuid(e34783f4-ac08-11d2-8d19-00805fc2500c)]
interface nsICmdLineService : nsISupports
{
/**
* initialize
* Used to pass the original argv/argc from main()
* Warning: This will hold a reference to the original argv
* passed into Initialze();
*/
[noscript] void initialize(in long argc, out string argv);
/**
* getCmdLineValue
* returns the 2nd parameter, if any, to the parameter passed in
* For example, getCmdLineValue "-edit" will return any url that
* came after the -edit parameter
*/
string getCmdLineValue(in string argv);
/**
* URLToLoad
* The URL to load as passed to the command line
*/
readonly attribute string URLToLoad;
/**
* programName
*
*/
readonly attribute string programName;
/**
* argc
* The number of parameters passed in on the command line
*/
readonly attribute long argc;
/**
* argv
* returns a direct reference to the parameter array passed in
* to initialize() - do NOT dereference this array!
*/
[noscript] readonly attribute charArray argv;
/**
* Get the command line handler for the given parameter
* @param param - can be any parameter, with or without leading
* "-" such as "-mail" or "edit" - Pass in a null
* string if you want the "default" handler
*/
nsICmdLineHandler getHandlerForParam(in string param);
};

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

@ -1,192 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bill Law <law@netscape.com>
* Blake Ross <blake@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
/* nsINativeAppSupport
*
* This "pseudo" (in the XPCOM sense) interface provides for
* platform-specific general aplication support:
* o It subsumes the old "NS_CanRun" and "NS_CreateSplashScreen"
* functions that managed display of the application splash
* screen at startup.
* o It manages the details of the simple DDE communication
* supported on the Win32 platform (it is the addition of this
* item that prompted the creation of this interface.
*
* Due to the nature of the beast, this interface is not a full-blown
* XPCOM component. The primary reason is that objects that implement
* this interface generally must be operational *before* XPCOM (or any
* of the rest of Mozilla) are initialized. As a result, this
* interface is instantiated by somewhat unconventional means.
*
* To create the implementor of this interface, you call the function
* NS_CreateNativeAppSupport. This is done in the startup code
* in mozilla/xpfe/bootstrap.
*
* You can use this interface by obtaining an instance via the
* "nativeAppSupport" attribute of the nsIAppShellService
* interface/service.
*
* The interface provides these functions:
* start - You call this to inform the native app support that the
* application is starting. In addition, it serves as a
* query as to whether the application should continue to
* run. In that respect, it is rougly equivalent to the
* NS_CanStart function, which it replaces.
*
* If the returned boolean result is PR_FALSE, then the
* application should exit without further processing. In
* such cases, the returned nsresult indicates whether the
* reason to exit is due to an error or not.
*
* Win32 Note: In the case of starting a second instance
* of this executable, this function will return
* PR_FALSE and nsresult==NS_OK. This means that
* the command line arguments have been
* successfully passed to the instance of the
* application acting as a DDE server.
*
* stop - You call this to inform the native app support that the
* application *wishes* to terminate. If the returned boolean
* value is PR_FALSE, then the application should continue
* (as if there were still additional top-level windows open).
*
* Win32 Note: If this is the instance of the application
* acting as the DDE server, and there are current
* DDE conversations active with other instances
* acting as DDE clients, then this function will
* return PR_FALSE.
*
* quit - Like Stop, but this method *forces* termination (or more
* precisely, indicates that the application is about to be
* terminated regardless of what a call to Stop might have
* returned.
*
* This method is intended to be called when the user selects
* the "Quit" option (close all windows and exit).
*
* Win32 Note: Stop is problematic in the case of "Quit" (close
* all windows and exit the application) because
* either we don't Quit or (potentially) we lose
* requests coming from other instances of the
* application. The strategy is to give preference
* to the user's explicit Quit request. In the
* unlikely event that a request is pending from
* another instance of the application, then such
* requests are essentially ignored. This is
* roughly equivalent to handling that request by
* opening a new window, followed by immediately
* closing it. Since this is the same as if the
* request came in immediately before the Quit
* call (versus immediately after it), no harm.
*
* There is an exposure here: Upon return from this
* function, any DDE connect request (for Mozilla)
* will fail and other instances of the application
* will start up as a DDE server. In that case,
* those instances may do things that conflict with
* the subsequent shutting down of the instance that
* is quitting. For this reason, the call to Quit
* should be deferred as long as possible.
*
* showSplashScreen - Causes the platform-specific splash screen to be
* displayed. This is a replacement for the old
* method of invoking the Show() method on the
* nsISplashScreen interface obtained by calling
* NS_CreateSplashScreen.
*
* hideSplashScreen - Causes the splash screen to be removed (if it is
* being shown). This replaces the old method of
* invoking the Hide() method on the nsISplashScreen
* interface maintained by the app shell service.
*
* startServerMode - Method that "starts" server mode. Typically, this
* will create a hidden Navigator window (and then close
* it) in order to fill the cache, load shared libraries,
* etc. Note that this method does not set the
* isServerMode attribute, nor does setting that attribute
* "start" server mode (at least in the same sense as is
* meant by this method). Basically, native code will
* set isServerMode to tell nsAppRunner; nsAppRunner will
* then call this method (implemented back in the same
* native code) at the appropriate time for any additional
* server-mode startup to be completed.
*
* onLastWindowClosing - Called when the last window is closed. Used as a
* "soft" shutdown, passwords are flushed.
*
* This interface has these attributes:
* isServerMode - Boolean attribute indicating whether the application
* is running in "server mode." Server mode means the
* application was started to pre-load shared-libraries,
* initialize services, and open a hidden Navigator window
* in order to quickly surface that window when the user
* launches the application in the normal mode. This
* mode is currently Win32-only (and may really only make
* sense there) and is intended to be initiated from the
* Windows startup folder at system initialization.
*
*
*/
interface nsIXULWindow;
interface nsICmdLineService;
[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
interface nsINativeAppSupport : nsISupports {
// Startup/shutdown.
boolean start();
boolean stop();
void quit();
[noscript] void ensureProfile(in nsICmdLineService aCmdService);
// Splash screen functions.
void showSplashScreen();
void hideSplashScreen();
// Server mode.
attribute boolean isServerMode;
attribute boolean shouldShowUI;
void startServerMode();
void onLastWindowClosing();
void ReOpen();
};

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

@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bill Law <law@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
/* This file has *public* stuff needed for the Win32 implementation of
* the nsINativeAppSupport interface. It has to be broken out into a
* separate file in order to ensure that the generated .h file can be
* used in a Win32 .rc file. See /mozilla/xpfe/bootstrap/splash.rc.
*
* This file, and the generated .h, are only needed on Win32 platforms.
*/
%{C++
// Constants identifying Win32 "native" resources.
#ifdef MOZ_PHOENIX
// Splash screen dialog ID.
#define IDD_SPLASH 100
// Splash screen bitmap ID.
#define IDB_SPLASH 101
// DDE application name
#define ID_DDE_APPLICATION_NAME 102
#define IDI_APPICON 0
#define IDI_DOCUMENT 1
#endif
// String that goes in the WinXP Start Menu.
#define IDS_STARTMENU_APPNAME 103
%}

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

@ -1,72 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bill Law law@netscape.com
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#ifndef nsISplashScreen_h__
#define nsISplashScreen_h__
#include "nsISupports.h"
// {B5030250-D530-11d3-8070-00600811A9C3}
#define NS_ISPLASHSCREEN_IID \
{ 0xb5030250, 0xd530, 0x11d3, { 0x80, 0x70, 0x0, 0x60, 0x8, 0x11, 0xa9, 0xc3 } }
/*
* This class specifies the interface to be used by xp code to manage the
platform-specific splash screen. Each platform (that has a splash screen)
should implement this interface and return a instance of that class from
the function NS_CreateSplashScreen.
Note that the nature of the splash screen object is such that it is
impossible to obtain an instance of this interface via standard XPCOM
means (componenter manager/service manager).
For the same reason, implementors should take care to implement this
interface without introducing any dependencies on other components.
This includes XPCOM itself as it will not have been initialized when
an object that implements this interface will be created. Implementors
should implement the nsISupports member functions "manually" (rather
than via the standard NS_*IMPL macros) to avoid any dependencies
lurking in those macros.
*/
class nsISplashScreen : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR( NS_ISPLASHSCREEN_IID )
NS_IMETHOD Show() = 0;
NS_IMETHOD Hide() = 0;
}; // class nsISplashScreen
#endif // nsISplashScreen_h__

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

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
[scriptable, uuid(6c1034f0-1dd2-11b2-aa14-e6657ed7bb0b)]
interface nsIUserInfo : nsISupports
{
/* these are things the system may know about the current user */
readonly attribute wstring fullname;
readonly attribute string emailAddress;
/* should this be a wstring? */
readonly attribute string username;
readonly attribute string domain;
};
%{C++
// 14c13684-1dd2-11b2-9463-bb10ba742554
#define NS_USERINFO_CID \
{ 0x14c13684, 0x1dd2, 0x11b2, \
{0x94, 0x63, 0xbb, 0x10, 0xba, 0x74, 0x25, 0x54}}
#define NS_USERINFO_CONTRACTID "@mozilla.org/userinfo;1"
%}

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

@ -1,144 +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) 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 ***** */
/* This file implements the nsCloseAllWindows component which implements
* the nsICloseAllWindows interface. Use this component when all
* windows need to be closed and confirmation to save changes is required.
*/
/* ctor
*/
function nsCloseAllWindows() {
}
nsCloseAllWindows.prototype = {
// This "class" supports nsICloseAllWindows, and nsISupports.
QueryInterface: function (iid) {
if (iid.equals(Components.interfaces.nsICloseAllWindows) ||
iid.equals(Components.interfaces.nsISupports))
return this;
Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
return null;
},
// ---------- nsICloseAllWindows methods ----------
// closeAll: Close all open windows
closeAll: function(aAskToSave) {
var windowMediator = Components.classes['@mozilla.org/appshell/window-mediator;1'].
getService(Components.interfaces.nsIWindowMediator);
var enumerator = windowMediator.getEnumerator(null);
while (enumerator.hasMoreElements()) {
var domWindow = enumerator.getNext();
if (aAskToSave && ("tryToClose" in domWindow)) {
if (!domWindow.tryToClose())
return false;
}
domWindow.close();
};
return true;
}
}
// This Component's module implementation. All the code below is used to get this
// component registered and accessible via XPCOM.
var module = {
firstTime: true,
// registerSelf: Register this component.
registerSelf: function (compMgr, fileSpec, location, type) {
if (this.firstTime) {
this.firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation( this.cid,
"Close All Windows",
this.contractId,
fileSpec,
location,
type );
},
// getClassObject: Return this component's factory object.
getClassObject: function (compMgr, cid, iid) {
if (!cid.equals(this.cid)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
if (!iid.equals(Components.interfaces.nsIFactory)) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}
return this.factory;
},
/* CID for this class */
cid: Components.ID("{2f977d48-5485-11d4-87e2-0010a4e75ef2}"),
/* Contract ID for this class */
contractId: "@mozilla.org/appshell/closeallwindows;1",
/* factory object */
factory: {
// createInstance: Return a new nsCloseAllWindows object.
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return (new nsCloseAllWindows()).QueryInterface(iid);
}
},
// canUnload: n/a (returns true)
canUnload: function(compMgr) {
return true;
}
};
// NSGetModule: Return the nsIModule object.
function NSGetModule(compMgr, fileSpec) {
return module;
}

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

@ -1,398 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsICmdLineService.h"
#include "nsCommandLineService.h"
#include "nsIComponentManager.h"
#include "nsILocalFile.h"
#include "nsString.h"
#include "plstr.h"
#include "nsCRT.h"
#include "nsNetUtil.h"
#ifdef XP_MACOSX
#include "nsCommandLineServiceMac.h"
#endif
nsCmdLineService::nsCmdLineService()
: mArgCount(0), mArgc(0), mArgv(0)
{
}
/*
* Implement the nsISupports methods...
*/
NS_IMPL_ISUPPORTS1(nsCmdLineService, nsICmdLineService)
static void* ProcessURLArg(char* str)
{
// Problem: since the arg parsing code doesn't know which flags
// take arguments, it always calls this method for the last
// non-flag argument. But sometimes that argument is actually
// the arg for the last switch, e.g. -width 500 or -Profile default.
// nsLocalFile will only work on absolute pathnames, so return
// if str doesn't start with '/' or '\'.
if (str && (*str == '\\' || *str == '/'))
{
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), str);
if (NS_FAILED(rv))
{
nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
if (file)
{
rv = file->InitWithNativePath(nsDependentCString(str));
if (NS_SUCCEEDED(rv))
{
nsCAutoString fileurl;
rv = NS_GetURLSpecFromFile(file, fileurl);
if (NS_SUCCEEDED(rv))
return NS_REINTERPRET_CAST(void*, ToNewCString(fileurl));
}
}
}
}
return NS_REINTERPRET_CAST(void*, nsCRT::strdup(str));
}
NS_IMETHODIMP
nsCmdLineService::Initialize(int aArgc, char ** aArgv)
{
PRInt32 i=0;
nsresult rv = nsnull;
#ifdef XP_MACOSX
rv = InitializeMacCommandLine(aArgc, aArgv);
NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed");
#endif
// Save aArgc and argv
mArgc = aArgc;
mArgv = new char*[ aArgc ];
for(i=0; i<aArgc; i++) {
mArgv[i] = nsCRT::strdup( aArgv[i] ? aArgv[i] : "" );
}
//Insert the program name
if (aArgc > 0 && aArgv[0])
{
mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("-progname")));
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[0])));
mArgCount++;
i++;
}
for(i=1; i<aArgc; i++) {
if ((aArgv[i][0] == '-')
#if defined(XP_WIN) || defined(XP_OS2)
|| (aArgv[i][0] == '/')
#endif
) {
/* An option that starts with -. May or may not
* have a value after it.
*/
mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[i])));
//Increment the index to look ahead at the next option.
i++;
//Look ahead if this option has a value like -w 60
if (i == aArgc) {
/* All args have been parsed. Append a PR_TRUE for the
* previous option in the mArgValueList
*/
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("1")));
mArgCount++;
break;
}
if ((aArgv[i][0] == '-')
#if defined(XP_WIN) || defined(XP_OS2)
|| (aArgv[i][0] == '/')
#endif
) {
/* An other option. The previous one didn't have a value.
* So, store the previous one's value as PR_TRUE in the
* mArgValue array and retract the index so that this option
* will get stored in the next iteration
*/
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("1")));
mArgCount++;
i--;
continue;
}
else {
/* The next argument does not start with '-'. This
* could be value to the previous option
*/
if (i == (aArgc-1)) {
/* This is the last argument and a URL
* Append a PR_TRUE for the previous option in the value array
*/
//mArgValueList.AppendElement((void *)PL_strdup("1"));
//mArgCount++;
// Append the url to the arrays
//mArgList.AppendElement((void *)PL_strdup("-url"));
mArgValueList.AppendElement(ProcessURLArg(aArgv[i]));
mArgCount++;
continue;
}
else {
/* This is a value to the previous option.
* Store it in the mArgValue array
*/
mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup(aArgv[i])));
mArgCount++;
}
}
}
else {
if (i == (aArgc-1)) {
/* This must be the URL at the end
* Append the url to the arrays
*/
mArgList.AppendElement(NS_REINTERPRET_CAST(void*, nsCRT::strdup("-url")));
mArgValueList.AppendElement(ProcessURLArg(aArgv[i]));
mArgCount++;
}
else {
/* A bunch of unrecognized arguments */
rv = NS_ERROR_INVALID_ARG;
}
}
} // for
#if 0
for (i=0; i<mArgCount; i++)
{
printf("Argument: %s, ****** Value: %s\n", (char *)mArgList.ElementAt(i), (char *) mArgValueList.ElementAt(i));
}
#endif /* 0 */
return rv;
}
NS_IMETHODIMP
nsCmdLineService::GetURLToLoad(char ** aResult)
{
return GetCmdLineValue("-url", aResult);
}
NS_IMETHODIMP
nsCmdLineService::GetProgramName(char ** aResult)
{
*aResult = nsCRT::strdup((char *)mArgValueList.SafeElementAt(0));
return NS_OK;
}
PRBool nsCmdLineService::ArgsMatch(const char *lookingFor, const char *userGave)
{
if (!lookingFor || !userGave) return PR_FALSE;
if (!PL_strcasecmp(lookingFor,userGave)) return PR_TRUE;
#if defined(XP_UNIX) || defined(XP_BEOS)
/* on unix and beos, we'll allow --mail for -mail */
if (lookingFor && userGave && (lookingFor[0] != '\0') && (userGave[0] != '\0') && (userGave[1] != '\0')) {
if (!PL_strcasecmp(lookingFor+1,userGave+2) && (lookingFor[0] == '-') && (userGave[0] == '-') && (userGave[1] == '-')) return PR_TRUE;
}
#endif
#if defined(XP_WIN) || defined(XP_OS2)
/* on windows /mail is the same as -mail */
if (lookingFor && userGave && (lookingFor[0] != '\0') && (userGave[0] != '\0')) {
if (!PL_strcasecmp(lookingFor+1,userGave+1) && (lookingFor[0] == '-') && (userGave[0] == '/')) return PR_TRUE;
}
#endif
return PR_FALSE;
}
NS_IMETHODIMP
nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult)
{
nsresult rv = NS_OK;
if (nsnull == aArg || nsnull == aResult ) {
return NS_ERROR_NULL_POINTER;
}
for (int i = 0; i<mArgCount; i++)
{
if (ArgsMatch(aArg,(char *) mArgList.ElementAt(i))) {
*aResult = nsCRT::strdup((char *)mArgValueList.ElementAt(i));
return NS_OK;
}
}
*aResult = nsnull;
return rv;
}
NS_IMETHODIMP
nsCmdLineService::GetArgc(PRInt32 * aResult)
{
if (nsnull == aResult)
return NS_ERROR_NULL_POINTER;
// if we are null, we were never initialized.
if (mArgc == 0)
return NS_ERROR_FAILURE;
*aResult = mArgc;
return NS_OK;
}
NS_IMETHODIMP
nsCmdLineService::GetArgv(char *** aResult)
{
if (nsnull == aResult)
return NS_ERROR_NULL_POINTER;
// if we are 0, we were never set.
if (!mArgv)
return NS_ERROR_FAILURE;
*aResult = mArgv;
return NS_OK;
}
nsCmdLineService::~nsCmdLineService()
{
PRInt32 curr = mArgList.Count();
while ( curr ) {
char* str = NS_REINTERPRET_CAST(char*, mArgList[curr-1]);
if ( str )
nsMemory::Free(str);
--curr;
}
curr = mArgValueList.Count();
while ( curr ) {
char* str = NS_REINTERPRET_CAST(char*, mArgValueList[curr-1]);
if ( str )
nsMemory::Free(str);
--curr;
}
curr = mArgc;
while ( curr ) {
char *str = mArgv ? mArgv[curr-1] : 0;
if ( str )
nsMemory::Free( mArgv[curr-1] );
--curr;
}
delete [] mArgv;
}
NS_IMETHODIMP
nsCmdLineService::GetHandlerForParam(const char *aParam,
nsICmdLineHandler** aResult)
{
nsresult rv;
// allocate temp on the stack
nsAutoVoidArray oneParameter;
nsVoidArray *paramList;
// if user passed in "null", then we want to go through each one
if (!aParam)
paramList = &mArgList;
else {
oneParameter.AppendElement((void *)aParam);
paramList = &oneParameter;
}
PRUint32 i;
for (i=0; i < (PRUint32)paramList->Count(); i++) {
const char *param = (const char*)paramList->ElementAt(i);
// skip past leading / and -
if (*param == '-' || *param == '/') {
++param;
if (*param == *(param-1)) // skip "--" or "//"
++param;
}
nsCAutoString
contractID("@mozilla.org/commandlinehandler/general-startup;1?type=");
contractID += param;
nsCOMPtr<nsICmdLineHandler> handler =
do_GetService(contractID.get(), &rv);
if (NS_FAILED(rv)) continue;
*aResult = handler;
NS_ADDREF(*aResult);
return NS_OK;
}
// went through all the parameters, didn't find one
return NS_ERROR_FAILURE;
}
#if 0
NS_IMETHODIMP
nsCmdLineService::PrintCmdArgs()
{
if (mArgCount == 0) {
printf("No command line options provided\n");
return;
}
for (int i=0; i<mArgCount; i++)
{
printf("Argument: %s, ****** Value: %s\n", mArgList.ElementAt(i), mArgValueList.ElementAt(i));
}
return NS_OK;
}
#endif

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

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#ifndef __nsCommandLineService_h
#define __nsCommandLineService_h
#include "nsISupports.h"
#include "nsVoidArray.h"
class nsCmdLineService : public nsICmdLineService
{
public:
nsCmdLineService(void);
NS_DECL_ISUPPORTS
NS_DECL_NSICMDLINESERVICE
protected:
virtual ~nsCmdLineService();
nsVoidArray mArgList; // The arguments
nsVoidArray mArgValueList; // The argument values
PRInt32 mArgCount; // This is not argc. This is # of argument pairs
// in the arglist and argvaluelist arrays. This
// normally is argc/2.
PRInt32 mArgc; // This is argc;
char ** mArgv; // This is argv;
PRBool ArgsMatch(const char *lookingFor, const char *userGave);
};
// e34783f5-ac08-11d2-8d19-00805fc2500c
#define NS_COMMANDLINESERVICE_CID \
{ 0xe34783f5, 0xac08, 0x11d2, \
{0x8d, 0x19, 0x00, 0x80, 0x5f, 0xc2, 0x50,0xc} }
#endif

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

@ -1,427 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
* Pierre Phaneuf <pp@ludusdesign.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
// Special stuff for the Macintosh implementation of command-line service.
#include "nsCommandLineServiceMac.h"
// Mozilla
#include "nsDebug.h"
#include "nsILocalFileMac.h"
#include "nsDebug.h"
#include "nsNetUtil.h"
#include "nsIAppStartup.h"
#include "nsIServiceManager.h"
#include "nsIURL.h"
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNetCID.h"
#include "nsIWebShellWindow.h"
#include "nsIWebShell.h"
#include "nsIDOMWindow.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "jsapi.h"
#include "nsReadableUtils.h"
#include "nsICloseAllWindows.h"
#include "nsIPrefService.h"
#include "nsAEEventHandling.h"
#include "nsXPFEComponentsCID.h"
// NSPR
#include "prmem.h"
#include "plstr.h"
#include "prenv.h"
#ifdef XP_MAC
#include "pprio.h" // PR_Init_Log
#endif
// the static instance
nsMacCommandLine nsMacCommandLine::sMacCommandLine;
/*
* ReadLine --
*
* Read in a line of text, terminated by CR or LF, from inStream into buf.
* The terminating CR or LF is not included. The text in buf is terminated
* by a null byte.
* Returns the number of bytes in buf. If EOF and zero bytes were read, returns -1.
*/
static PRInt32 ReadLine(FILE* inStream, char* buf, PRInt32 bufSize)
{
PRInt32 charsRead = 0;
int c;
if (bufSize < 2)
return -1;
while (charsRead < (bufSize-1)) {
c = getc(inStream);
if (c == EOF || c == '\n' || c == '\r')
break;
buf[charsRead++] = c;
}
buf[charsRead] = '\0';
return (c == EOF && !charsRead) ? -1 : charsRead;
}
//----------------------------------------------------------------------------------------
nsMacCommandLine::nsMacCommandLine()
: mArgs(NULL)
, mArgsAllocated(0)
, mArgsUsed(0)
, mStartedUp(PR_FALSE)
//----------------------------------------------------------------------------------------
{
}
//----------------------------------------------------------------------------------------
nsMacCommandLine::~nsMacCommandLine()
//----------------------------------------------------------------------------------------
{
ShutdownAEHandlerClasses();
if (mArgs) {
for (PRUint32 i = 0; i < mArgsUsed; i++)
free(mArgs[i]);
free(mArgs);
}
}
//----------------------------------------------------------------------------------------
nsresult nsMacCommandLine::Initialize(int& argc, char**& argv)
//----------------------------------------------------------------------------------------
{
mArgs = static_cast<char **>(malloc(kArgsGrowSize * sizeof(char *)));
if (!mArgs)
return NS_ERROR_FAILURE;
mArgs[0] = nsnull;
mArgsAllocated = kArgsGrowSize;
mArgsUsed = 0;
#if defined(XP_MACOSX)
// Here, we may actually get useful args.
// Copy them first to mArgv.
for (int arg = 0; arg < argc; arg++)
AddToCommandLine(argv[arg]);
#else
// init the args buffer with the program name
AddToCommandLine("mozilla");
#endif
// Set up AppleEvent handling.
OSErr err = CreateAEHandlerClasses(false);
if (err != noErr) return NS_ERROR_FAILURE;
// Snarf all the odoc and pdoc apple-events.
//
// 1. If they are odoc for 'CMDL' documents, read them into the buffer ready for
// parsing (concatenating multiple files).
//
// 2. If they are any other kind of document, convert them into -url command-line
// parameters or -print parameters, with file URLs.
EventRecord anEvent;
for (short i = 1; i < 5; i++)
::WaitNextEvent(0, &anEvent, 0, nsnull);
while (::EventAvail(highLevelEventMask, &anEvent))
{
::WaitNextEvent(highLevelEventMask, &anEvent, 0, nsnull);
if (anEvent.what == kHighLevelEvent)
{
// here we process startup odoc/pdoc events, which can
// add items to the command line.
err = ::AEProcessAppleEvent(&anEvent);
}
}
if (GetCurrentKeyModifiers() & optionKey)
AddToCommandLine("-p");
// we've started up now
mStartedUp = PR_TRUE;
argc = mArgsUsed;
argv = mArgs;
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsresult nsMacCommandLine::AddToCommandLine(const char* inArgText)
//----------------------------------------------------------------------------------------
{
if (mArgsUsed >= mArgsAllocated) {
// realloc does not free the given pointer if allocation fails.
char **temp = static_cast<char **>(realloc(mArgs, (mArgsAllocated + kArgsGrowSize) * sizeof(char *)));
if (!temp)
return NS_ERROR_OUT_OF_MEMORY;
mArgs = temp;
mArgsAllocated += kArgsGrowSize;
}
char *temp2 = strdup(inArgText);
if (!temp2)
return NS_ERROR_OUT_OF_MEMORY;
mArgs[mArgsUsed++] = temp2;
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec)
//----------------------------------------------------------------------------------------
{
// Convert the filespec to a URL
FSSpec nonConstSpec = inFileSpec;
nsCOMPtr<nsILocalFileMac> inFile;
nsresult rv = NS_NewLocalFileWithFSSpec(&nonConstSpec, PR_TRUE, getter_AddRefs(inFile));
if (NS_FAILED(rv))
return rv;
nsCAutoString specBuf;
rv = NS_GetURLSpecFromFile(inFile, specBuf);
if (NS_FAILED(rv))
return rv;
AddToCommandLine(inOptionString);
AddToCommandLine(specBuf.get());
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsresult nsMacCommandLine::AddToEnvironmentVars(const char* inArgText)
//----------------------------------------------------------------------------------------
{
(void)PR_SetEnv(inArgText);
return NS_OK;
}
//----------------------------------------------------------------------------------------
OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType)
//----------------------------------------------------------------------------------------
{
nsCOMPtr<nsILocalFileMac> inFile;
nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile));
if (NS_FAILED(rv))
return errAEEventNotHandled;
if (!mStartedUp)
{
// Is it the right type to be a command-line file?
if (inFileType == 'TEXT' || inFileType == 'CMDL')
{
// Can we open the file?
FILE *fp = 0;
rv = inFile->OpenANSIFileDesc("r", &fp);
if (NS_SUCCEEDED(rv))
{
Boolean foundArgs = false;
Boolean foundEnv = false;
char chars[1024];
static const char kCommandLinePrefix[] = "ARGS:";
static const char kEnvVarLinePrefix[] = "ENV:";
while (ReadLine(fp, chars, sizeof(chars)) != -1)
{ // See if there are any command line or environment var settings
if (PL_strstr(chars, kCommandLinePrefix) == chars)
{
(void)AddToCommandLine(chars + sizeof(kCommandLinePrefix) - 1);
foundArgs = true;
}
else if (PL_strstr(chars, kEnvVarLinePrefix) == chars)
{
(void)AddToEnvironmentVars(chars + sizeof(kEnvVarLinePrefix) - 1);
foundEnv = true;
}
}
fclose(fp);
#ifndef XP_MACOSX
// If we found any environment vars we need to re-init NSPR's logging
// so that it knows what the new vars are
if (foundEnv)
PR_Init_Log();
#endif
// If we found a command line or environment vars we want to return now
// raather than trying to open the file as a URL
if (foundArgs || foundEnv)
return noErr;
}
}
// If it's not a command-line argument, and we are starting up the application,
// add a command-line "-url" argument to the global list. This means that if
// the app is opened with documents on the mac, they'll be handled the same
// way as if they had been typed on the command line in Unix or DOS.
return AddToCommandLine("-url", inFileSpec);
}
// Final case: we're not just starting up. How do we handle this?
nsCAutoString specBuf;
rv = NS_GetURLSpecFromFile(inFile, specBuf);
if (NS_FAILED(rv))
return errAEEventNotHandled;
return OpenURL(specBuf.get());
}
OSErr nsMacCommandLine::OpenURL(const char* aURL)
{
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
nsXPIDLCString browserURL;
if (NS_SUCCEEDED(rv))
rv = prefBranch->GetCharPref("browser.chromeURL", getter_Copies(browserURL));
if (NS_FAILED(rv)) {
NS_WARNING("browser.chromeURL not supplied! How is the app supposed to know what the main window is?");
browserURL.Assign("chrome://navigator/content/navigator.xul");
}
rv = OpenWindow(browserURL.get(), NS_ConvertASCIItoUCS2(aURL).get());
if (NS_FAILED(rv))
return errAEEventNotHandled;
return noErr;
}
//----------------------------------------------------------------------------------------
OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType)
//----------------------------------------------------------------------------------------
{
// If we are starting up the application,
// add a command-line "-print" argument to the global list. This means that if
// the app is opened with documents on the mac, they'll be handled the same
// way as if they had been typed on the command line in Unix or DOS.
if (!mStartedUp)
return AddToCommandLine("-print", inFileSpec);
// Final case: we're not just starting up. How do we handle this?
NS_NOTYETIMPLEMENTED("Write Me");
return errAEEventNotHandled;
}
//----------------------------------------------------------------------------------------
nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url)
//----------------------------------------------------------------------------------------
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsCOMPtr<nsISupportsString> urlWrapper(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
if (!wwatch || !urlWrapper)
return NS_ERROR_FAILURE;
urlWrapper->SetData(nsDependentString(url));
nsCOMPtr<nsIDOMWindow> newWindow;
nsresult rv;
rv = wwatch->OpenWindow(0, chrome, "_blank",
"chrome,dialog=no,all", urlWrapper,
getter_AddRefs(newWindow));
return rv;
}
//----------------------------------------------------------------------------------------
OSErr nsMacCommandLine::DispatchURLToNewBrowser(const char* url)
//----------------------------------------------------------------------------------------
{
OSErr err = errAEEventNotHandled;
if (mStartedUp)
return OpenURL(url);
else {
err = AddToCommandLine("-url");
if (err == noErr)
err = AddToCommandLine(url);
}
return err;
}
//----------------------------------------------------------------------------------------
OSErr nsMacCommandLine::Quit(TAskSave askSave)
//----------------------------------------------------------------------------------------
{
nsresult rv;
nsCOMPtr<nsICloseAllWindows> closer =
do_CreateInstance("@mozilla.org/appshell/closeallwindows;1", &rv);
if (NS_FAILED(rv))
return errAEEventNotHandled;
PRBool doQuit;
rv = closer->CloseAll(askSave != eSaveNo, &doQuit);
if (NS_FAILED(rv) || !doQuit)
return errAEEventNotHandled;
nsCOMPtr<nsIAppStartup> appStartup =
(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
if (NS_FAILED(rv))
return errAEEventNotHandled;
(void)appStartup->Quit(nsIAppStartup::eAttemptQuit);
return noErr;
}
//========================================================================================
// InitializeMacCommandLine
// The only external entry point to this file.
//========================================================================================
#pragma mark -
//----------------------------------------------------------------------------------------
nsresult InitializeMacCommandLine(int& argc, char**& argv)
//----------------------------------------------------------------------------------------
{
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
return cmdLine.Initialize(argc, argv);
} // InitializeMac

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

@ -1,115 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
// Special stuff for the Macintosh implementation of command-line service.
#ifndef nsCommandLineServiceMac_h_
#define nsCommandLineServiceMac_h_
#include <Files.h>
#include "nscore.h"
#include "nsError.h"
#include "nsString.h"
#include "nsAEDefs.h"
#ifdef __cplusplus
class nsMacCommandLine
{
public:
enum
{
kArgsGrowSize = 20
};
nsMacCommandLine();
~nsMacCommandLine();
nsresult Initialize(int& argc, char**& argv);
nsresult AddToCommandLine(const char* inArgText);
nsresult AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec);
nsresult AddToEnvironmentVars(const char* inArgText);
OSErr HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType);
OSErr HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType);
OSErr DispatchURLToNewBrowser(const char* url);
OSErr Quit(TAskSave askSave);
protected:
OSErr OpenURL(const char* aURL);
nsresult OpenWindow(const char *chrome, const PRUnichar *url);
char** mArgs; // array of arg pointers (augmented argv)
PRUint32 mArgsAllocated; // number of slots available in mArgs
PRUint32 mArgsUsed; // number of slots used in mArgs
PRBool mStartedUp;
public:
static nsMacCommandLine& GetMacCommandLine() { return sMacCommandLine; }
private:
static nsMacCommandLine sMacCommandLine;
};
#endif //__cplusplus
#ifdef __cplusplus
extern "C" {
#endif
nsresult InitializeMacCommandLine(int& argc, char**& argv);
#ifdef __cplusplus
}
#endif
#endif // nsCommandLineServiceMac_h_

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

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#ifndef __nsUserInfo_h
#define __nsUserInfo_h
#include "nsIUserInfo.h"
class nsUserInfo: public nsIUserInfo
{
public:
nsUserInfo(void);
NS_DECL_ISUPPORTS
NS_DECL_NSIUSERINFO
virtual ~nsUserInfo();
};
#endif /* __nsUserInfo_h */

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

@ -1,142 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsUserInfo.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsIInternetConfigService.h"
nsUserInfo::nsUserInfo()
{
}
nsUserInfo::~nsUserInfo()
{
}
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
nsresult result = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
nsCAutoString cName;
result = icService->GetString(nsIInternetConfigService::eICString_RealName, cName);
if ( NS_SUCCEEDED ( result ) )
{
nsString fullName;
*aFullname = ToNewUnicode(cName);
}
}
return result;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
nsresult result = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
nsCAutoString tempString;
result = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if (NS_SUCCEEDED(result))
*aEmailAddress = ToNewCString(tempString);
}
return result;
}
NS_IMETHODIMP
nsUserInfo::GetUsername(char * *aUsername)
{
*aUsername = nsnull;
nsCAutoString tempString;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if ( NS_FAILED( rv ) ) return rv;
const char* atString = "@";
PRInt32 atOffset = tempString.Find(atString);
if (atOffset != kNotFound)
tempString.Truncate(atOffset);
*aUsername = ToNewCString(tempString);
return NS_OK;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
nsCAutoString tempString;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if ( NS_FAILED( rv ) ) return rv;
const char* atString = "@";
PRInt32 atOffset = tempString.Find(atString);
if (atOffset != kNotFound)
{
nsCAutoString domainString;
tempString.Right(domainString, tempString.Length() - (atOffset + 1));
*aDomain = ToNewCString(domainString);
return NS_OK;
}
// no domain in the pref
return NS_ERROR_FAILURE;
}
#pragma mark -

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

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#ifndef __nsUserInfoMac_h
#define __nsUserInfoMac_h
#include "nsIUserInfo.h"
#include <InternetConfig.h>
class nsUserInfo: public nsIUserInfo
{
public:
nsUserInfo(void);
virtual ~nsUserInfo();
NS_DECL_ISUPPORTS
NS_DECL_NSIUSERINFO
protected:
nsresult EnsureInitted();
static OSType GetAppCreatorCode();
static PRUnichar* PStringToNewUCS2(ConstStr255Param str);
protected:
ICInstance mInstance;
PRBool mInitted;
};
#endif /* __nsUserInfo_h */

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

@ -1,87 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 *****
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/11/2000 IBM Corp. Created for OS/2 VisualAge build.
*/
#include "nsUserInfo.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsXPIDLString.h"
nsUserInfo::nsUserInfo()
{
}
nsUserInfo::~nsUserInfo()
{
}
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
NS_IMETHODIMP
nsUserInfo::GetUsername(char **aUsername)
{
*aUsername = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
*aFullname = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
*aEmailAddress = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -1,199 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsUserInfo.h"
#include "nsCRT.h"
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/utsname.h>
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
/* Some UNIXy platforms don't have pw_gecos. In this case we use pw_name */
#if defined(NO_PW_GECOS)
#define PW_GECOS pw_name
#else
#define PW_GECOS pw_gecos
#endif
nsUserInfo::nsUserInfo()
{
}
nsUserInfo::~nsUserInfo()
{
}
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
struct passwd *pw = nsnull;
pw = getpwuid (geteuid());
if (!pw || !pw->PW_GECOS) return NS_ERROR_FAILURE;
#ifdef DEBUG_sspitzer
printf("fullname = %s\n", pw->PW_GECOS);
#endif
nsCAutoString fullname(pw->PW_GECOS);
// now try to parse the GECOS information, which will be in the form
// Full Name, <other stuff> - eliminate the ", <other stuff>
// also, sometimes GECOS uses "&" to mean "the user name" so do
// the appropriate substitution
// truncate at first comma (field delimiter)
PRInt32 index;
if ((index = fullname.Find(",")) != kNotFound)
fullname.Truncate(index);
// replace ampersand with username
if (pw->pw_name) {
nsCAutoString username(pw->pw_name);
if (!username.IsEmpty() && nsCRT::IsLower(username.CharAt(0)))
username.SetCharAt(nsCRT::ToUpper(username.CharAt(0)), 0);
fullname.ReplaceSubstring("&", username.get());
}
*aFullname = ToNewUnicode(fullname);
if (*aFullname)
return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsUserInfo::GetUsername(char * *aUsername)
{
struct passwd *pw = nsnull;
// is this portable? those are POSIX compliant calls, but I need to check
pw = getpwuid(geteuid());
if (!pw || !pw->pw_name) return NS_ERROR_FAILURE;
#ifdef DEBUG_sspitzer
printf("username = %s\n", pw->pw_name);
#endif
*aUsername = nsCRT::strdup(pw->pw_name);
return NS_OK;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
nsresult rv = NS_ERROR_FAILURE;
struct utsname buf;
char *domainname = nsnull;
// is this portable? that is a POSIX compliant call, but I need to check
if (uname(&buf)) {
return rv;
}
#if defined(HAVE_UNAME_DOMAINNAME_FIELD)
domainname = buf.domainname;
#elif defined(HAVE_UNAME_US_DOMAINNAME_FIELD)
domainname = buf.__domainname;
#endif
if (domainname && domainname[0]) {
*aDomain = nsCRT::strdup(domainname);
rv = NS_OK;
}
else {
// try to get the hostname from the nodename
// on machines that use DHCP, domainname may not be set
// but the nodename might.
if (buf.nodename && buf.nodename[0]) {
// if the nodename is foo.bar.org, use bar.org as the domain
char *pos = strchr(buf.nodename,'.');
if (pos) {
*aDomain = nsCRT::strdup(pos+1);
rv = NS_OK;
}
}
}
return rv;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
// use username + "@" + domain for the email address
nsresult rv;
nsCAutoString emailAddress;
nsXPIDLCString username;
nsXPIDLCString domain;
rv = GetUsername(getter_Copies(username));
if (NS_FAILED(rv)) return rv;
rv = GetDomain(getter_Copies(domain));
if (NS_FAILED(rv)) return rv;
if (!username.IsEmpty() && !domain.IsEmpty()) {
emailAddress = (const char *)username;
emailAddress += "@";
emailAddress += (const char *)domain;
}
else {
return NS_ERROR_FAILURE;
}
*aEmailAddress = ToNewCString(emailAddress);
return NS_OK;
}

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

@ -1,93 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@netscape.com>
* Seth Spitzer <sspitzer@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsUserInfo.h"
#include "nsString.h"
#include "windows.h"
#include "nsCRT.h"
#include "nsXPIDLString.h"
nsUserInfo::nsUserInfo()
{
}
nsUserInfo::~nsUserInfo()
{
}
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo)
NS_IMETHODIMP
nsUserInfo::GetUsername(char **aUsername)
{
*aUsername = nsnull;
TCHAR username[256];
DWORD size = 256;
if (!GetUserName(username, &size))
return NS_ERROR_FAILURE;
*aUsername = nsCRT::strdup(username);
if (*aUsername) return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
*aFullname = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
*aEmailAddress = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -1,68 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Travis Bogard <travis@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
/**
* The nsIXULBrowserWindow supplies the methods that may be called from the
* internals of the browser area to tell the containing xul window to update
* it's ui.
*/
interface nsIRequest;
[scriptable, uuid(46B4015C-0121-11d4-9877-00C04FA0D27A)]
interface nsIXULBrowserWindow : nsISupports
{
/*
Sets the status according to JS' version of status.
*/
void setJSStatus(in wstring status);
/*
Sets the default status according to JS' version of default status.
*/
void setJSDefaultStatus(in wstring status);
/*
Tells the object implementing this function what link we are currently over.
*/
void setOverLink(in wstring link);
};