コード例 #1
0
ファイル: main.cpp プロジェクト: Eric89GXL/CTK
// dummy main
int main(int argc, char** argv)
{
    QCoreApplication myApp(argc, argv);

    QString tmpPath = QDir::tempPath() + "/snippet-eventadmin-intro";
    ctkProperties fwProps;
    fwProps[ctkPluginConstants::FRAMEWORK_STORAGE] = tmpPath;
    fwProps[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN] = ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
    fwProps["org.commontk.pluginfw.debug.resolve"] = true;
    fwProps["org.commontk.pluginfw.debug.service_reference"] = true;
    fwProps["org.commontk.pluginfw.debug.errors"] = true;
    fwProps["org.commontk.pluginfw.debug.pluginfw"] = true;
    fwProps["org.commontk.pluginfw.debug.lazy_activation"] = true;
    ctkPluginFrameworkLauncher::setFrameworkProperties(fwProps);
    ctkPluginFrameworkLauncher::start("org.commontk.eventadmin");

    ctkPluginContext* pluginContext = ctkPluginFrameworkLauncher::getPluginContext();

    ReportManager reportManager(pluginContext);

    //! [Event Handler service registration]
    ReportEventHandler eventHandler;
    ctkDictionary props;
    props[ctkEventConstants::EVENT_TOPIC] = "com/acme/reportgenerator/GENERATED";
    pluginContext->registerService<ctkEventHandler>(&eventHandler, props);
    //! [Event Handler service registration]

    // You can also use a wildcard in the final character of the EVENT_TOPIC
    //! [Event Handler service registration wildcard]
    props[ctkEventConstants::EVENT_TOPIC] = "com/acme/reportgenerator/*";
    pluginContext->registerService<ctkEventHandler>(&eventHandler, props);
    //! [Event Handler service registration wildcard]

    // Or you could use a filter expression (using LDAP syntax)
    //! [Event Handler service registration filter]
    props[ctkEventConstants::EVENT_TOPIC] = "com/acme/reportgenerator/GENERATED";
    props[ctkEventConstants::EVENT_FILTER] = "(title=samplereport)";
    pluginContext->registerService<ctkEventHandler>(&eventHandler, props);
    //! [Event Handler service registration filter]

    //! [Event Handler service registration slot]
    ReportEventHandlerUsingSlots eventHandlerUsingSlots;
    ctkDictionary propsForSlot;
    propsForSlot[ctkEventConstants::EVENT_TOPIC] = "com/acme/reportgenerator/*";
    ctkServiceReference ref = pluginContext->getServiceReference<ctkEventAdmin>();
    if (ref)
    {
        ctkEventAdmin* eventAdmin = pluginContext->getService<ctkEventAdmin>(ref);
        eventAdmin->subscribeSlot(&eventHandlerUsingSlots, SLOT(handleEvent(ctkEvent)), propsForSlot);
    }
    //! [Event Handler service registration slot]

    reportManager.reportGenerated(Report());
}
コード例 #2
0
CNcdReportManager& CNcdServerReportManager::ReportManagerL( MCatalogsBaseMessage& aMessage )
    {
    // Get current context
    MCatalogsContext& context( aMessage.Session().Context() );

    // All the clients have their own report manager.
    TNcdProviderContext providerContext;
    Provider().GetProviderContextL( context, providerContext );
    CNcdReportManager& reportManager( *providerContext.iReportManager );
    
    return reportManager;
    }
コード例 #3
0
void CNcdServerReportManager::NodeSetAsInstalledRequestL( MCatalogsBaseMessage& aMessage )
    {
    HBufC8* input = HBufC8::NewLC( aMessage.InputLength() );
    TPtr8 inputPtr = input->Des();
    aMessage.ReadInput( inputPtr );
    RDesReadStream inputStream( *input );
    CleanupClosePushL( inputStream );

    TInt errorCode( inputStream.ReadInt32L() );
    CNcdNodeIdentifier* identifier( CNcdNodeIdentifier::NewLC( inputStream ) );

    CNcdReportManager& reportManager( ReportManagerL( aMessage ) );
    CNcdNode& node( Provider().NodeManager().NodeL( *identifier ) ); 
    CNcdNodeMetaData& metaData( node.NodeMetaDataL() );
    
    TNcdReportStatusInfo info( ENcdReportCreate, errorCode );
    // Use the node identifier to identify the content in install report.
    // Node id uniquely identifies the node that contains contents
    // that will be installed. One node may contains multiple contents but
    // they are all thought as one bundle, in one operation. Also, notice that 
    // multiple nodes can contain same metadata and same content.
    TNcdReportId reportId = 
        reportManager.RegisterInstallL( 
            identifier->NodeId(),
            metaData.Identifier(),
            info,
            metaData.Identifier().ServerUri(),
            metaData.Identifier().NodeNameSpace() );

    // Set access point for report.
    UpdateInstallReportAccessPointL( aMessage.Session().Context().FamilyId(),
                                     reportId,
                                     node,
                                     metaData,
                                     reportManager,
                                     HttpSessionL( aMessage.Session().Context() ) );    

    // Set the final success information directly into the report instead of
    // reporting other install statuses here.
    TNcdReportStatus status( ENcdReportSuccess );
    if ( errorCode == KErrNone )
        {
        status = ENcdReportSuccess;
        }
    else if ( errorCode == KErrCancel )
        {
        status = ENcdReportCancel;
        }
    else 
        {
        status = ENcdReportFail;
        }
    
    // Create the status info object with the given info.
    info.iStatus = status;
    info.iErrorCode = errorCode;
    
    reportManager.ReportInstallStatusL(
            reportId,
            info );
    
    CleanupStack::PopAndDestroy( identifier );
    CleanupStack::PopAndDestroy( &inputStream );
    CleanupStack::PopAndDestroy( input );

    aMessage.CompleteAndRelease( KErrNone );    
    }