~zulcss/ubuntu/lucid/likewise-open/likewise-open-sru

« back to all changes in this revision

Viewing changes to domainjoin/domainjoin-gui/carbon/DomainJoin/HIFramework/TApplication.cp

  • Committer: Bazaar Package Importer
  • Author(s): Rick Clark
  • Date: 2008-08-27 08:56:20 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080827085620-5q0f58b9qtog9myq
Tags: 4.1.0.2956-0ubuntu1
* missing-likewise-logo.diff: removed
* fixed copyright notice
* updated Standards-Version to 3.8.0
* removed path from command in prerm
* removed stop in S runlevel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    File:               TApplication.cp
 
3
 
 
4
    Version:    Mac OS X
 
5
 
 
6
        Disclaimer:     IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
 
7
                                ("Apple") in consideration of your agreement to the following terms, and your
 
8
                                use, installation, modification or redistribution of this Apple software
 
9
                                constitutes acceptance of these terms.  If you do not agree with these terms,
 
10
                                please do not use, install, modify or redistribute this Apple software.
 
11
 
 
12
                                In consideration of your agreement to abide by the following terms, and subject
 
13
                                to these terms, Apple grants you a personal, non-exclusive license, under Apple�s
 
14
                                copyrights in this original Apple software (the "Apple Software"), to use,
 
15
                                reproduce, modify and redistribute the Apple Software, with or without
 
16
                                modifications, in source and/or binary forms; provided that if you redistribute
 
17
                                the Apple Software in its entirety and without modifications, you must retain
 
18
                                this notice and the following text and disclaimers in all such redistributions of
 
19
                                the Apple Software.  Neither the name, trademarks, service marks or logos of
 
20
                                Apple Computer, Inc. may be used to endorse or promote products derived from the
 
21
                                Apple Software without specific prior written permission from Apple.  Except as
 
22
                                expressly stated in this notice, no other rights or licenses, express or implied,
 
23
                                are granted by Apple herein, including but not limited to any patent rights that
 
24
                                may be infringed by your derivative works or by other works in which the Apple
 
25
                                Software may be incorporated.
 
26
 
 
27
                                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
 
28
                                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
 
29
                                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
30
                                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
 
31
                                COMBINATION WITH YOUR PRODUCTS.
 
32
 
 
33
                                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
 
34
                                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 
35
                                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
36
                                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
 
37
                                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
 
38
                                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
 
39
                                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
40
 
 
41
        Copyright � 2000-2005 Apple Computer, Inc., All Rights Reserved
 
42
*/
 
43
 
 
44
#include "TApplication.h"
 
45
#include "TNib.h"
 
46
 
 
47
// -----------------------------------------------------------------------------
 
48
//      constants
 
49
// -----------------------------------------------------------------------------
 
50
//
 
51
 
 
52
// Our base class for creating a Mac OS application which is be Carbon Event-savvy.
 
53
 
 
54
// -----------------------------------------------------------------------------
 
55
//      TApplication Nib creation constructor
 
56
// -----------------------------------------------------------------------------
 
57
//
 
58
TApplication::TApplication(
 
59
        CFStringRef                             inMenuBarName,
 
60
        CFStringRef                             inNibName )
 
61
{
 
62
        Init( inMenuBarName, inNibName );
 
63
}
 
64
 
 
65
// -----------------------------------------------------------------------------
 
66
//      Init
 
67
// -----------------------------------------------------------------------------
 
68
//
 
69
OSStatus
 
70
TApplication::Init(
 
71
        CFStringRef                     inMenuBarName,
 
72
        CFStringRef                     inNibName )
 
73
{
 
74
        OSStatus                        err;
 
75
        TNib                            nib;
 
76
 
 
77
        static const
 
78
        EventTypeSpec           kEvents[] =
 
79
                                                        {
 
80
                                                                { kEventClassCommand, kEventProcessCommand },
 
81
                                                        };
 
82
 
 
83
        err = RegisterForEvents( GetEventTypeCount( kEvents ), kEvents );
 
84
        require_noerr( err, CantInit );
 
85
 
 
86
        err = nib.Init( inNibName );
 
87
        require_noerr( err, CantInit );
 
88
 
 
89
        err = nib.SetMenuBar( inMenuBarName );
 
90
        require_noerr( err, CantInit );
 
91
 
 
92
CantInit:
 
93
        return err;
 
94
}
 
95
 
 
96
// -----------------------------------------------------------------------------
 
97
//      TApplication destructor
 
98
// -----------------------------------------------------------------------------
 
99
//
 
100
TApplication::~TApplication()
 
101
{
 
102
}
 
103
 
 
104
// -----------------------------------------------------------------------------
 
105
//      GetEventTarget
 
106
// -----------------------------------------------------------------------------
 
107
//
 
108
EventTargetRef
 
109
TApplication::GetEventTarget()
 
110
{
 
111
        return GetApplicationEventTarget();
 
112
}
 
113
 
 
114
// -----------------------------------------------------------------------------
 
115
//      Run
 
116
// -----------------------------------------------------------------------------
 
117
//
 
118
void
 
119
TApplication::Run()
 
120
{
 
121
        RunApplicationEventLoop();
 
122
}
 
123
 
 
124
// -----------------------------------------------------------------------------
 
125
//      Activated
 
126
// -----------------------------------------------------------------------------
 
127
//
 
128
void
 
129
TApplication::Activated()
 
130
{
 
131
}
 
132
 
 
133
// -----------------------------------------------------------------------------
 
134
//      Deactivated
 
135
// -----------------------------------------------------------------------------
 
136
//
 
137
void
 
138
TApplication::Deactivated()
 
139
{
 
140
}
 
141
 
 
142
// -----------------------------------------------------------------------------
 
143
//      UpdateCommandStatus
 
144
// -----------------------------------------------------------------------------
 
145
//
 
146
Boolean
 
147
TApplication::UpdateCommandStatus(
 
148
        const HICommandExtended&        inCommand )
 
149
{
 
150
        return false; // not handled
 
151
}
 
152
 
 
153
// -----------------------------------------------------------------------------
 
154
//      HandleCommand
 
155
// -----------------------------------------------------------------------------
 
156
//
 
157
Boolean
 
158
TApplication::HandleCommand(
 
159
        const HICommandExtended&        inCommand )
 
160
{
 
161
        return false; // not handled
 
162
}
 
163
 
 
164
// -----------------------------------------------------------------------------
 
165
//      HandleEvent
 
166
// -----------------------------------------------------------------------------
 
167
//
 
168
OSStatus
 
169
TApplication::HandleEvent(
 
170
        EventHandlerCallRef             inRef,
 
171
        TCarbonEvent&                   inEvent )
 
172
{
 
173
        OSStatus                                result = eventNotHandledErr;
 
174
        HICommandExtended               command;
 
175
 
 
176
        switch ( inEvent.GetClass() )
 
177
        {
 
178
                case kEventClassCommand:
 
179
                        {
 
180
                                inEvent.GetParameter( kEventParamDirectObject, &command );
 
181
 
 
182
                                switch ( inEvent.GetKind() )
 
183
                                {
 
184
                                        case kEventCommandProcess:
 
185
                                                if ( this->HandleCommand( command ) )
 
186
                                                        result = noErr;
 
187
                                                break;
 
188
 
 
189
                                        case kEventCommandUpdateStatus:
 
190
                                                if ( this->UpdateCommandStatus( command ) )
 
191
                                                        result = noErr;
 
192
                                                break;
 
193
                                }
 
194
                        }
 
195
                        break;
 
196
        };
 
197
 
 
198
        return result;
 
199
}