epoc32/include/mw/lbtstartuptrigger.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  Concrete class representing start-up trigger entries.
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
#ifndef LBTSTARTUPTRIGGER_H
williamr@2
    20
#define LBTSTARTUPTRIGGER_H
williamr@2
    21
williamr@2
    22
#include <lbttriggerentry.h>
williamr@2
    23
#include <lbs.h>
williamr@2
    24
williamr@2
    25
/**
williamr@2
    26
 *  Concrete class representing start-up trigger entries.
williamr@2
    27
 *
williamr@2
    28
 *  When a start-up trigger is fired, Location Triggering Server tries to 
williamr@2
    29
 *  launch a new instance of the trigger handling process. Trigger handling
williamr@2
    30
 *  process is specified by the client application when the trigger is 
williamr@2
    31
 *  created. The command line arguments, if specified, are passed to the 
williamr@2
    32
 *  thread function of the new process's main thread. If the specified 
williamr@2
    33
 *  process can't be launched when the trigger is fired, Location Triggering 
williamr@2
    34
 *  Server will try to launch the process next time when the trigger is 
williamr@2
    35
 *  fired again. 
williamr@2
    36
 *
williamr@2
    37
 *  Start-up trigger has following additional attributes
williamr@2
    38
 *
williamr@2
    39
 *  -  <B>Trigger handling process identity</B> Trigger handling process 
williamr@2
    40
 *  identity consists of the executable name of the trigger handling process.
williamr@2
    41
 *  The process is launched when the start-up trigger is fired. This attribute 
williamr@2
    42
 *  can't be modified after the start-up trigger is created.
williamr@2
    43
 *
williamr@2
    44
 *  -  <B> SID of the trigger handling process</B> When SID of the trigger 
williamr@2
    45
 *  handling process is specified when the trigger is created, the trigger 
williamr@2
    46
 *  handling process is able to access the trigger. If the SID is not specified,
williamr@2
    47
 *  the trigger handling process can't access the trigger. This attribute 
williamr@2
    48
 *  cannot be modified after the start-up trigger is created.
williamr@2
    49
 *
williamr@2
    50
 *  -  <B>Command-line argument string</B> Command-line argument string is passed
williamr@2
    51
 *  as an argument to the main thread of the launched process, when it's 
williamr@2
    52
 *  first scheduled. Command-line argument string is passed to the launched 
williamr@2
    53
 *  process as it is specified. Location Triggering Server doesn't interpret any
williamr@2
    54
 *  special character. This attribute can be modified after the trigger is
williamr@2
    55
 *  created.
williamr@2
    56
 *
williamr@2
    57
 *  Trigger handling process identity must be specified when the trigger 
williamr@2
    58
 *  is created in Location Triggering Server. SID of the trigger handling 
williamr@2
    59
 *  process and Command-line argument string is optional.
williamr@2
    60
 *
williamr@2
    61
 *  If the trigger handling process is not the owner process of the trigger and
williamr@2
    62
 *  the SID of the trigger handling process is not specified when the trigger 
williamr@2
    63
 *  is created, it can't access the firing trigger
williamr@2
    64
 *  information. In this case, if the trigger handling process needs to 
williamr@2
    65
 *  get information of the firing trigger, it can get it either from 
williamr@2
    66
 *  command-line argument string which is set when the trigger is created 
williamr@2
    67
 *  or request a service from the owner process.
williamr@2
    68
 *
williamr@2
    69
 *  If a UIKON based UI application is specified as trigger handling process,
williamr@2
    70
 *  the UIKON framework will prevent starting a new instance of the application if
williamr@2
    71
 *  it's already running. In this case, the trigger handling process (UI application)
williamr@2
    72
 *  shall issue trigger firing event notification request to Location Triggering 
williamr@2
    73
 *  Server when it's started.
williamr@2
    74
 *
williamr@2
    75
 *  If the owner process, Manager UI or trigger handling process 
williamr@2
    76
 *  of a trigger is removed from the system, the trigger becomes 
williamr@2
    77
 *  invalid. The process can be removed for example when the process's 
williamr@2
    78
 *  executable resides in removable media (like MMC), and that media is 
williamr@2
    79
 *  removed from the terminal. An invalid trigger is not supervised by 
williamr@2
    80
 *  the system. If a trigger has been invalid longer than the predefined system 
williamr@2
    81
 *  clean up time, the trigger is removed from the system. System clean up time 
williamr@2
    82
 *  is defined by system and cant' be accessed by client application.
williamr@2
    83
 * 
williamr@2
    84
 *  @see RLbt
williamr@2
    85
 *
williamr@2
    86
 *  @lib lbt.lib
williamr@2
    87
 *  @since S60 5.1
williamr@2
    88
 */
williamr@2
    89
class CLbtStartupTrigger : public CLbtTriggerEntry
williamr@2
    90
    {
williamr@2
    91
public:
williamr@2
    92
    /**
williamr@2
    93
     * Allocates and constructs a new start-up trigger entry.
williamr@2
    94
     * Default values are assigned to the attributes. 
williamr@2
    95
     * The default values are
williamr@2
    96
     * 
williamr@2
    97
     *  - Trigger Id is KLbtNullTriggerId.
williamr@2
    98
     *
williamr@2
    99
     *  - Trigger Name is an empty string.
williamr@2
   100
     *
williamr@2
   101
     *  - Trigger State CLbtTriggerEntry::EStateEnabled.
williamr@2
   102
     *  
williamr@2
   103
     *  - Requestors are not set. 
williamr@2
   104
     *
williamr@2
   105
     *  - Manager UI is not set(KNullUid). 
williamr@2
   106
     *
williamr@2
   107
     *  - Trigger condition is not set.
williamr@2
   108
     *
williamr@2
   109
     *  - Trigger handling process file name is empty string.
williamr@2
   110
     * 
williamr@2
   111
     *  - SID of the trigger handling process is KNullUid.
williamr@2
   112
     *
williamr@2
   113
     *  - Command-line argument string is an empty string
williamr@2
   114
     *
williamr@2
   115
     * @return Pointer to the new start-up trigger entry.
williamr@2
   116
     */
williamr@2
   117
    IMPORT_C static CLbtStartupTrigger* NewL();
williamr@2
   118
williamr@2
   119
    /**
williamr@2
   120
     * Allocates and constructs a new start-up trigger entry. The
williamr@2
   121
     * constructed object is pushed onto cleanup stack.
williamr@2
   122
     * Default values are assigned to the attributes. 
williamr@2
   123
     * The default values are
williamr@2
   124
     * 
williamr@2
   125
     *  - Trigger Id is KLbtNullTriggerId.
williamr@2
   126
     *
williamr@2
   127
     *  - Trigger Name is an empty string.
williamr@2
   128
     *
williamr@2
   129
     *  - Trigger State CLbtTriggerEntry::EStateEnabled.
williamr@2
   130
     *  
williamr@2
   131
     *  - Requestors are not set. 
williamr@2
   132
     *
williamr@2
   133
     *  - Manager UI is not set(KNullUid). 
williamr@2
   134
     *
williamr@2
   135
     *  - Trigger condition is not set.
williamr@2
   136
     *
williamr@2
   137
     *  - Trigger handling process file name is empty string.
williamr@2
   138
     * 
williamr@2
   139
     *  - SID of the trigger handling process is KNullUid.
williamr@2
   140
     *
williamr@2
   141
     *  - Command-line argument string is an empty string
williamr@2
   142
     *
williamr@2
   143
     * @return Pointer to the new start-up trigger entry.
williamr@2
   144
     */
williamr@2
   145
    IMPORT_C static CLbtStartupTrigger* NewLC();
williamr@2
   146
williamr@2
   147
    /**
williamr@2
   148
     * Allocates and constructs a new start-up trigger entry.
williamr@2
   149
     *
williamr@2
   150
     * @param[in] aName The name of the trigger entry.
williamr@2
   151
     * @param[in] aState The state of trigger entry.
williamr@2
   152
     * @param[in] aRequestorType Identifies the type of requestor, a
williamr@2
   153
     * service or a contact.
williamr@2
   154
     * @param[in] aRequestorFormat Determines the type of data held 
williamr@2
   155
     * in aRequestorData
williamr@2
   156
     * @param[in] aRequestorData Requestor data. Can be a telephone 
williamr@2
   157
     * number, a URL etc.
williamr@2
   158
     * @param[in] aManagerUi The UID of manager UI. 
williamr@2
   159
     * @param[in] aCondition Pointer of the new trigger condition object.
williamr@2
   160
     * This object takes the ownership of aCondition.
williamr@2
   161
     * @param[in] aFileName A descriptor containing the full path name of
williamr@2
   162
     * the executable to be loaded when the start-up trigger is fired. If 
williamr@2
   163
     * this name has no file extension, an extension of .exe is appended. 
williamr@2
   164
     * The length of the resulting full path name must not be greater 
williamr@2
   165
     * than KMaxFileName. The length of the file name itself must not be 
williamr@2
   166
     * greater than KMaxOsName. If no path is specified, the system will 
williamr@2
   167
     * look in system executable directories on all local drives, in the  
williamr@2
   168
     * same search order as specified in TFindFile::FindByPath().
williamr@2
   169
     * @param[in] aSecureId The SID of the trigger handling process.
williamr@2
   170
     * If the specified value is KNullUid or a wrong value is specified,
williamr@2
   171
     * the trigger handling process would not be able to access the 
williamr@2
   172
     * trigger.
williamr@2
   173
     * @param[in] aCommandLine Command-line argument string.
williamr@2
   174
     * @return Pointer to the new start-up trigger entry.
williamr@2
   175
     * @leave KErrArgument If the name of the trigger is longer than
williamr@2
   176
     *   @p KLbtMaxNameLength.
williamr@2
   177
     * @leave Other standard symbian error code, such as KErrNoMemory,
williamr@2
   178
     * KErrGeneral, etc.
williamr@2
   179
     * @panic ELbtErrArgument The length of aFileName is longer than
williamr@2
   180
     * @p KMaxFileName.
williamr@2
   181
     */
williamr@2
   182
    IMPORT_C static CLbtStartupTrigger* NewL( 
williamr@2
   183
        const TDesC& aName,
williamr@2
   184
        TLbtTriggerState aState,
williamr@2
   185
        CRequestor::TRequestorType aRequestorType,
williamr@2
   186
        CRequestor::TRequestorFormat aRequestorFormat,
williamr@2
   187
        const TDesC& aRequestorData,
williamr@2
   188
        TUid aManagerUi,
williamr@2
   189
        CLbtTriggerConditionBase* aCondition,
williamr@2
   190
        const TDesC& aFileName, 
williamr@2
   191
        const TSecureId& aSecureId = KNullUid,
williamr@2
   192
        const TDesC& aCommandLine = KNullDesC() );
williamr@2
   193
    
williamr@2
   194
    /**
williamr@2
   195
     * Allocates and construct a new start-up trigger entry.
williamr@2
   196
     *
williamr@2
   197
     * @panic ELbtErrArgument The length of aFileName is greater than
williamr@2
   198
     * @p KMaxFileName.
williamr@2
   199
     *
williamr@2
   200
     * @param[in] aName The name of the trigger entry.
williamr@2
   201
     * @param[in] aState The state of trigger entry.
williamr@2
   202
     * @param[in] aRequestors The requestor for the service. This object
williamr@2
   203
     * does not take the ownership of aRequestor.
williamr@2
   204
     * @param[in] aManagerUi The UID of manager UI.
williamr@2
   205
     * @param[in] aCondition Pointer of the new trigger condition object.
williamr@2
   206
     * This object takes the ownership of aCondition.
williamr@2
   207
     * @param[in] aFileName A descriptor containing the full path name of
williamr@2
   208
     * the executable to be loaded when the start-up trigger is fired. If 
williamr@2
   209
     * this name has no file extension, an extension of .exe is appended. 
williamr@2
   210
     * The length of the resulting full path name must not be greater 
williamr@2
   211
     * than KMaxFileName. The length of the file name itself must not be 
williamr@2
   212
     * greater than KMaxOsName. If no path is specified, the system will 
williamr@2
   213
     * look in system executable directories on all local drives, in the  
williamr@2
   214
     * same search order as specified in TFindFile::FindByPath().
williamr@2
   215
     * @param[in] aSecureId The SID of the trigger handling process.
williamr@2
   216
     * If the specified value is KNullUid or a wrong value is specified,
williamr@2
   217
     * the trigger handling process would not be able to access the 
williamr@2
   218
     * trigger.
williamr@2
   219
     * @param[in] aCommandLine Command-line argument string.
williamr@2
   220
     * @return Pointer to the new start-up trigger entry.
williamr@2
   221
     * @leave KErrArgument If the name of the trigger is longer than
williamr@2
   222
     * @p KLbtMaxNameLength.
williamr@2
   223
     * @leave Other standard symbian error code, such as KErrNoMemory,
williamr@2
   224
     * KErrGeneral, etc.
williamr@2
   225
     */
williamr@2
   226
    IMPORT_C static CLbtStartupTrigger* NewL( 
williamr@2
   227
        const TDesC& aName,
williamr@2
   228
        TLbtTriggerState aState,
williamr@2
   229
        const RRequestorStack& aRequestors,
williamr@2
   230
        TUid aManagerUi,
williamr@2
   231
        CLbtTriggerConditionBase* aCondition,
williamr@2
   232
        const TDesC& aFileName, 
williamr@2
   233
        const TSecureId& aSecureId = KNullUid,
williamr@2
   234
        const TDesC& aCommandLine = KNullDesC() );
williamr@2
   235
williamr@2
   236
    /**
williamr@2
   237
     * Destructor
williamr@2
   238
     */
williamr@2
   239
    IMPORT_C ~CLbtStartupTrigger();
williamr@2
   240
williamr@2
   241
    /**
williamr@2
   242
     * Gets the type of trigger entry, CLbtTriggerEntry::EStartup.
williamr@2
   243
     *
williamr@2
   244
     * @return CLbtTriggerEntry::EStartup.
williamr@2
   245
     */
williamr@2
   246
    IMPORT_C TType Type() const;
williamr@2
   247
    
williamr@2
   248
    /**
williamr@2
   249
     * Gets identity of the trigger handling process.
williamr@2
   250
     * 
williamr@2
   251
     * @param[out] aFileName On return contains the full path name
williamr@2
   252
     * of the executable of trigger handling process. Maximum length 
williamr@2
   253
     * of the resulting full path name is KMaxFileName. Client gets 
williamr@2
   254
     * panic USER 11 if the length of executable full path name is 
williamr@2
   255
     * greater than the maximum length of aFileName. Empty string 
williamr@2
   256
     * is returned if the attribute has not been set.
williamr@2
   257
     * @param[out] aSecureId On return contains the SID of
williamr@2
   258
     * the triggering handling process. KNullUid is returned if
williamr@2
   259
     * the SID has not been previously set. 
williamr@2
   260
     */
williamr@2
   261
    IMPORT_C void GetProcessId( 
williamr@2
   262
        TDes& aFileName, 
williamr@2
   263
        TSecureId& aSecureId ) const;
williamr@2
   264
    
williamr@2
   265
    /**
williamr@2
   266
     * Sets the identity of the trigger handling process.
williamr@2
   267
     *
williamr@2
   268
     * @param[in] aFileName A descriptor containing the full path name of
williamr@2
   269
     * the executable to be loaded when the start-up trigger is fired. If 
williamr@2
   270
     * this name has no file extension, an extension of .exe is appended. 
williamr@2
   271
     * The length of the resulting full path name must not be greater 
williamr@2
   272
     * than @p KMaxFileName. The length of the file name itself must not be 
williamr@2
   273
     * greater than KMaxOsName. If no path is specified, the system will 
williamr@2
   274
     * look in system executable directories on all local drives, in the  
williamr@2
   275
     * same search order as specified in TFindFile::FindByPath().
williamr@2
   276
     * @param[in] aSecureId The SID of the trigger handling process.
williamr@2
   277
     * If the specified value is KNullUid or a wrong value is specified,
williamr@2
   278
     * the trigger handling process would not be able to access the 
williamr@2
   279
     * trigger.
williamr@2
   280
     * @panic ELbtErrArgument The length of aFileName is greater than
williamr@2
   281
     * @p KMaxFileName.
williamr@2
   282
     */
williamr@2
   283
    IMPORT_C void SetProcessId( 
williamr@2
   284
        const TDesC& aFileName, 
williamr@2
   285
        const TSecureId& aSecureId );
williamr@2
   286
    
williamr@2
   287
    /**
williamr@2
   288
     * Gets the command-line argument string.
williamr@2
   289
     *
williamr@2
   290
     * @return The command-line argument string. Empty string is returned
williamr@2
   291
     * if the command-line argument string has not been set
williamr@2
   292
     */
williamr@2
   293
    IMPORT_C const TDesC& CommandLine() const;
williamr@2
   294
    
williamr@2
   295
    /**
williamr@2
   296
     * Sets the command-line argument string.
williamr@2
   297
     * 
williamr@2
   298
     * @param[in] aCommandLine The command-line argument string. It can
williamr@2
   299
     * be an empty string.
williamr@2
   300
     */
williamr@2
   301
    IMPORT_C void SetCommandLineL( const TDesC& aCommandLine );
williamr@2
   302
    
williamr@2
   303
    
williamr@2
   304
protected:
williamr@2
   305
    
williamr@2
   306
    /**
williamr@2
   307
     * Internalize method that subclass must implement.
williamr@2
   308
     * @param[in] aStream Stream from which the object should be internalized.
williamr@2
   309
     */
williamr@2
   310
    virtual void DoInternalizeL(RReadStream& aStream);
williamr@2
   311
    
williamr@2
   312
    /**
williamr@2
   313
     * Externalize method that subclass must implement.
williamr@2
   314
     * @param[in] aStream Stream to which the object should be externalized.
williamr@2
   315
     */
williamr@2
   316
    virtual void DoExternalizeL(RWriteStream& aStream) const;  
williamr@2
   317
williamr@2
   318
         
williamr@2
   319
williamr@2
   320
private:
williamr@2
   321
    /**
williamr@2
   322
     * Default constructor
williamr@2
   323
     */
williamr@2
   324
    CLbtStartupTrigger(); 
williamr@2
   325
        
williamr@2
   326
    /**
williamr@2
   327
     * By default, prohibit copy constructor
williamr@2
   328
     */
williamr@2
   329
    CLbtStartupTrigger( const CLbtStartupTrigger& );
williamr@2
   330
    
williamr@2
   331
    /**
williamr@2
   332
     * Prohibit assigment operator
williamr@2
   333
     */
williamr@2
   334
    CLbtStartupTrigger& operator= ( const CLbtStartupTrigger& );
williamr@2
   335
    
williamr@2
   336
    /**
williamr@2
   337
     * Symbian 2nd phase constructor
williamr@2
   338
     */
williamr@2
   339
    void ConstructL();
williamr@2
   340
    
williamr@2
   341
    /**
williamr@2
   342
     * Symbian 2nd phase constructor
williamr@2
   343
     */
williamr@2
   344
    void ConstructL(const TDesC& aName,
williamr@2
   345
        TLbtTriggerState aState,
williamr@2
   346
        CRequestor::TRequestorType aRequestorType,
williamr@2
   347
        CRequestor::TRequestorFormat aRequestorFormat,
williamr@2
   348
        const TDesC& aRequestorData,
williamr@2
   349
        TUid aManagerUi,
williamr@2
   350
        CLbtTriggerConditionBase* aCondition,
williamr@2
   351
        const TDesC& aFileName, 
williamr@2
   352
        const TSecureId& aSecureId ,
williamr@2
   353
        const TDesC& aCommandLine);
williamr@2
   354
    
williamr@2
   355
    /**
williamr@2
   356
     * Symbian 2nd phase constructor
williamr@2
   357
     */    
williamr@2
   358
    void CLbtStartupTrigger::ConstructL( const TDesC& aName,
williamr@2
   359
        CLbtTriggerEntry::TLbtTriggerState aState,
williamr@2
   360
        const RRequestorStack& aRequestors,
williamr@2
   361
        TUid aManagerUi,
williamr@2
   362
        CLbtTriggerConditionBase* aCondition,
williamr@2
   363
        const TDesC& aFileName, 
williamr@2
   364
        const TSecureId& aSecureId ,
williamr@2
   365
        const TDesC& aCommandLine);
williamr@2
   366
        
williamr@2
   367
private:
williamr@2
   368
    /**
williamr@2
   369
     * Process file name 
williamr@2
   370
     */
williamr@2
   371
    TFileName iProcessFileName;
williamr@2
   372
    
williamr@2
   373
    /**
williamr@2
   374
     * Secure Id
williamr@2
   375
     */
williamr@2
   376
    TSecureId iSecureId;
williamr@2
   377
    
williamr@2
   378
    /**
williamr@2
   379
     * Command line arguement
williamr@2
   380
     */
williamr@2
   381
    HBufC* iCommandLine;
williamr@2
   382
    };
williamr@2
   383
williamr@2
   384
williamr@2
   385
#endif // LBTSTARTUPTRIGGER_H