예제 #1
0
	LogApi::LogApi(Session* aSession) : ApiModule(aSession, Access::EVENTS) {
		LogManager::getInstance()->addListener(this);

		createSubscription("log_message");
		createSubscription("log_info");

		METHOD_HANDLER("clear", Access::EVENTS, ApiRequest::METHOD_POST, (), false, LogApi::handleClear);
		METHOD_HANDLER("read", Access::EVENTS, ApiRequest::METHOD_POST, (), false, LogApi::handleRead);
		METHOD_HANDLER("info", Access::EVENTS, ApiRequest::METHOD_GET, (), false, LogApi::handleGetInfo);
		METHOD_HANDLER("messages", Access::EVENTS, ApiRequest::METHOD_GET, (NUM_PARAM), false, LogApi::handleGetLog);
	}
예제 #2
0
	ShareProfileApi::ShareProfileApi(Session* aSession) : ApiModule(aSession, Access::SETTINGS_VIEW) {

		ShareManager::getInstance()->addListener(this);

		METHOD_HANDLER("profiles", Access::ANY, ApiRequest::METHOD_GET, (), false, ShareProfileApi::handleGetProfiles);
		METHOD_HANDLER("profile", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (), true, ShareProfileApi::handleAddProfile);
		METHOD_HANDLER("profile", Access::SETTINGS_EDIT, ApiRequest::METHOD_PATCH, (TOKEN_PARAM), true, ShareProfileApi::handleUpdateProfile);
		METHOD_HANDLER("profile", Access::SETTINGS_EDIT, ApiRequest::METHOD_DELETE, (TOKEN_PARAM), false, ShareProfileApi::handleRemoveProfile);
		METHOD_HANDLER("profile", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("default")), false, ShareProfileApi::handleDefaultProfile);

		createSubscription("share_profile_added");
		createSubscription("share_profile_updated");
		createSubscription("share_profile_removed");
	}
예제 #3
0
	ViewFileApi::ViewFileApi(Session* aSession) : ApiModule(aSession, Access::VIEW_FILES_VIEW) {

		ViewFileManager::getInstance()->addListener(this);

		createSubscription("view_file_added");
		createSubscription("view_file_removed");
		createSubscription("view_file_updated");
		createSubscription("view_file_finished");

		METHOD_HANDLER("sessions", Access::VIEW_FILES_VIEW, ApiRequest::METHOD_GET, (), false, ViewFileApi::handleGetFiles);
		METHOD_HANDLER("session", Access::VIEW_FILES_EDIT, ApiRequest::METHOD_POST, (), true, ViewFileApi::handleAddFile);
		METHOD_HANDLER("session", Access::VIEW_FILES_EDIT, ApiRequest::METHOD_DELETE, (TTH_PARAM), false, ViewFileApi::handleRemoveFile);

		METHOD_HANDLER("session", Access::VIEW_FILES_VIEW, ApiRequest::METHOD_GET, (TTH_PARAM, EXACT_PARAM("text")), false, ViewFileApi::handleGetText);
	}
예제 #4
0
	SessionApi::SessionApi(Session* aSession) : SubscribableApiModule(aSession, Access::ADMIN) {
		METHOD_HANDLER("activity", Access::ANY, ApiRequest::METHOD_POST, (), false, SessionApi::handleActivity);
		METHOD_HANDLER("auth", Access::ANY, ApiRequest::METHOD_DELETE, (), false, SessionApi::handleLogout);

		// Just fail these...
		METHOD_HANDLER("auth", Access::ANY, ApiRequest::METHOD_POST, (), false, SessionApi::failAuthenticatedRequest);
		METHOD_HANDLER("socket", Access::ANY, ApiRequest::METHOD_POST, (), false, SessionApi::failAuthenticatedRequest);

		METHOD_HANDLER("sessions", Access::ADMIN, ApiRequest::METHOD_GET, (), false, SessionApi::handleGetSessions);

		aSession->getServer()->getUserManager().addListener(this);

		createSubscription("session_created");
		createSubscription("session_removed");
	}
예제 #5
0
/*
 * Create a Subscription Topic to communicate with the Controllers/Master
 *
 *					Author Greg Brissey 4-26-04
 */
NDDS_ID createLockCmdSub(NDDS_ID nddsId, char *topic, void *callbackArg)
{

   NDDS_ID  pSubObj;
   char subtopic[128];

    /* Build Data type Object for both publication and subscription to Expproc */
    /* ------- malloc space for data type object --------- */
    if ( (pSubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL )
    {
        return(NULL);
    }
 
    /* zero out structure */
    memset(pSubObj,0,sizeof(NDDS_OBJ));
    memcpy(pSubObj,nddsId,sizeof(NDDS_OBJ));
 
    strcpy(pSubObj->topicName,topic);
 
    /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */
    getLock_CmdInfo(pSubObj);
 
#ifndef RTI_NDDS_4x
    pSubObj->callBkRtn = Lock_CmdCallback;
    pSubObj->callBkRtnParam = callbackArg;
#endif  /* RTI_NDDS_4x */
    pSubObj->MulticastSubIP[0] = 0;   /* use UNICAST */

#ifdef RTI_NDDS_4x
    initSubscription(pSubObj);
    attachOnDataAvailableCallback(pSubObj,Lock_CmdCallback,&callbackArg);
#endif  /* RTI_NDDS_4x */
    createSubscription(pSubObj);
    return ( pSubObj );
}
예제 #6
0
/*
 * Create a Exception Subscription to communicate with the Controllers/Master
 *
 *
 *                                      Author Greg Brissey  8/18/05
 *
 */
NDDS_ID createDDRSyncCommSub(NDDS_ID nddsId, char *topic, char *multicastIP, void *callbackArg)
{

   NDDS_ID  pSubObj;

    /* Build Data type Object for both publication and subscription to Expproc */
    /* ------- malloc space for data type object --------- */
    if ( (pSubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL )
    {
        return(NULL);
    }
 
    /* zero out structure */
    memset(pSubObj,0,sizeof(NDDS_OBJ));
    memcpy(pSubObj,nddsId,sizeof(NDDS_OBJ));
 
    strcpy(pSubObj->topicName,topic);
 
    /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */
    getCntlr_CommInfo(pSubObj);
 
    pSubObj->callBkRtn = DDRSync_CommCallback;
    pSubObj->callBkRtnParam = NULL;
    if (multicastIP == NULL)
       pSubObj->MulticastSubIP[0] = 0;   /* use UNICAST */
    else
       strcpy(pSubObj->MulticastSubIP,multicastIP);

    DPRINT1(-1,"createDDRSyncCommSub: create subscript for topic: '%s'\n",pSubObj->topicName);
    createSubscription(pSubObj);
    return ( pSubObj );
}
예제 #7
0
	UserApi::UserApi(Session* aSession) : SubscribableApiModule(aSession, Access::ANY) {

		ClientManager::getInstance()->addListener(this);
		MessageManager::getInstance()->addListener(this);

		METHOD_HANDLER("ignores", Access::SETTINGS_VIEW, ApiRequest::METHOD_GET, (), false, UserApi::handleGetIgnores);
		METHOD_HANDLER("ignore", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (CID_PARAM), false, UserApi::handleIgnore);
		METHOD_HANDLER("ignore", Access::SETTINGS_EDIT, ApiRequest::METHOD_DELETE, (CID_PARAM), false, UserApi::handleUnignore);

		createSubscription("user_connected");
		createSubscription("user_updated");
		createSubscription("user_disconnected");

		createSubscription("ignored_user_added");
		createSubscription("ignored_user_removed");
	}
예제 #8
0
	TransferApi::TransferApi(Session* aSession) : ApiModule(aSession, Access::ANY), timer(WebServerManager::getInstance()->addTimer([this] { onTimer(); }, 1000)) {
		DownloadManager::getInstance()->addListener(this);
		UploadManager::getInstance()->addListener(this);

		METHOD_HANDLER("stats", Access::ANY, ApiRequest::METHOD_GET, (), false, TransferApi::handleGetStats);

		createSubscription("statistics");
		timer->start();
	}
예제 #9
0
int main(int argc, char** argv)
{
    CIMClient client;
    CIMListener listener(listenerPort);
    receivedIndications = 0;
    mut = new Mutex();
    EmbeddedInstanceIndicationConsumer consumer1;
    listener.addConsumer(&consumer1);
    listener.start();

    try
    {
        client.connectLocal();
    }
    catch (...)
    {
        printf("Embedded Test Failed: Could not connect to server\n");
        return -1;
    }

    int ret = 0;

    ret = createSubscription(client);

    if (ret == 0)
        ret = createErrorInstance(client);

    errorPropList.append("errorKey");
    errorPropList.append("EmbeddedInst");
    if (ret == 0)
        ret = retrieveErrorInstance(client);

    if (ret == 0)
        ret = signalIndication(client);

    if (ret == 0)
        ret = retrieveIndicationInstance(client);

    if (ret == 0)
        ret = removeErrorInstance(client);

    if (ret == 0)
        ret = removeSubscription(client);
    else
    {
        removeErrorInstance(client);
        removeSubscription(client);
    }

    listener.removeConsumer(&consumer1);
    listener.stop();

    if (ret == 0)
        printf("+++EmbeddedInstanceTest passed+++\n");
    delete mut;
    return ret;
}
예제 #10
0
	HashApi::HashApi(Session* aSession) : SubscribableApiModule(aSession, Access::ANY),
		timer(getTimer([this] { onTimer(); }, 1000)) {

		HashManager::getInstance()->addListener(this);

		METHOD_HANDLER("database_status", Access::SETTINGS_VIEW, ApiRequest::METHOD_GET, (), false, HashApi::handleGetDbStatus);
		METHOD_HANDLER("optimize_database", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (), true, HashApi::handleOptimize);

		METHOD_HANDLER("pause", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (), false, HashApi::handlePause);
		METHOD_HANDLER("resume", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (), false, HashApi::handleResume);
		METHOD_HANDLER("stop", Access::SETTINGS_EDIT, ApiRequest::METHOD_POST, (), false, HashApi::handleStop);

		createSubscription("hash_database_status");
		createSubscription("hash_statistics");
		createSubscription("hasher_directory_finished");
		createSubscription("hasher_finished");

		timer->start(false);
	}
예제 #11
0
	SystemApi::SystemApi(Session* aSession) : ApiModule(aSession, Access::ANY), timer(aSession->getServer()->addTimer([this] { onTimer(); }, 500)) {

		METHOD_HANDLER("stats", Access::ANY, ApiRequest::METHOD_GET, (), false, SystemApi::handleGetStats);

		METHOD_HANDLER("away", Access::ANY, ApiRequest::METHOD_GET, (), false, SystemApi::handleGetAwayState);
		METHOD_HANDLER("away", Access::ANY, ApiRequest::METHOD_POST, (), true, SystemApi::handleSetAway);

		createSubscription("away_state");
		timer->start(true);
	}
예제 #12
0
NDDS_ID  createMonitorCmdsSub(char *subName)
{
    void processChanMsge();
    NDDS_ID pSubObj;
 
    /* Build Data type Object for both publication and subscription to Expproc */
    /* ------- malloc space for data type object --------- */
    if ( (pSubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL )
    {
        return(NULL);
    }
 
    /* create pipe for messages from NDDS signal handler Console to Expproc */
    if ( pipe(MonCmdPipe) != 0)
    {
        errLogSysQuit(ErrLogOp,debugInfo,"Expproc: createMonitorCmdsSub(): could not create Message Pipe\n" );
    }

    pMonitor_CmdBufMngr = nddsBufMngrCreate(50,(sizeof(Monitor_Cmd) + CMD_MAX_STR_SIZE + 4));

    /* set the callback routine to processMonitorCmd() and mark as direct
       this avoid the ssocket related setting which are not whated for the pipe
       set for the reading fd of the pipe
    */

    DPRINT2(1,"---> pipe fd[0]: %d, fd[1]: %d\n",MonCmdPipe[0],MonCmdPipe[1]);
    /* zero out structure */
    memset(pSubObj,0,sizeof(NDDS_OBJ));
    memcpy(pSubObj,NDDS_Domain,sizeof(NDDS_OBJ));
 
    strcpy(pSubObj->topicName,subName);
 
    /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */
    getMonitor_CmdInfo(pSubObj);
 
    /* NDDS issue callback routine */
#ifndef RTI_NDDS_4x
    pSubObj->callBkRtn = Monitor_CmdCallback;
    pSubObj->callBkRtnParam = pMonitor_CmdBufMngr; /* MonCmdPipe; /* pCntlrThr->SubPipeFd;    write end of pipe */
#endif /* RTI_NDDS_4x */

    pSubObj->MulticastSubIP[0] = 0;   /* use UNICAST */

#ifdef RTI_NDDS_4x
    initSubscription(pSubObj);
    attachOnDataAvailableCallback(pSubObj, Monitor_CmdCallback, pMonitor_CmdBufMngr);
#endif /* RTI_NDDS_4x */

    createSubscription(pSubObj);
 
    return(pSubObj);
 
}
예제 #13
0
void PrintQueueModel::createSubscriptionFinished()
{
    KCupsRequest *request = qobject_cast<KCupsRequest*>(sender());
    if (!request || request->hasError() || request->subscriptionId() < 0) {
        // in case of an error probe the server again in 1.5 seconds
        QTimer::singleShot(1000, this, SLOT(createSubscription()));
        request->deleteLater();
        m_subscriptionId = -1;
        return;
    }

    m_subscriptionId = request->subscriptionId();
    request->deleteLater();
}
예제 #14
0
PrintersEngine::PrintersEngine(QObject *parent, const QVariantList &args) :
    Plasma::DataEngine(parent, args),
    m_subscriptionId(-1)
{
    // We ignore any arguments - data engines do not have much use for them
    Q_UNUSED(args)

    m_printerAttributes << KCUPS_PRINTER_NAME;
    m_printerAttributes << KCUPS_PRINTER_INFO;
    m_printerAttributes << KCUPS_PRINTER_STATE;
    m_printerAttributes << KCUPS_PRINTER_STATE_MESSAGE;
    // to get proper icons
    m_printerAttributes << KCUPS_PRINTER_TYPE;

    createSubscription();
}
예제 #15
0
QueueApi::QueueApi(Session* aSession) : ApiModule(aSession, Access::QUEUE_VIEW),
    bundlePropertyHandler(bundleProperties,
                          QueueUtils::getStringInfo, QueueUtils::getNumericInfo, QueueUtils::compareBundles, QueueUtils::serializeBundleProperty),
    bundleView("bundle_view", this, bundlePropertyHandler, QueueUtils::getBundleList) {

    QueueManager::getInstance()->addListener(this);
    DownloadManager::getInstance()->addListener(this);

    createSubscription("bundle_added");
    createSubscription("bundle_removed");
    createSubscription("bundle_updated");
    createSubscription("bundle_status");
    createSubscription("bundle_tick");

    createSubscription("file_added");
    createSubscription("file_removed");
    createSubscription("file_updated");

    METHOD_HANDLER("bundles", Access::QUEUE_VIEW, ApiRequest::METHOD_GET, (NUM_PARAM, NUM_PARAM), false, QueueApi::handleGetBundles);
    METHOD_HANDLER("bundles", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("remove_finished")), false, QueueApi::handleRemoveFinishedBundles);
    METHOD_HANDLER("bundles", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("priority")), true, QueueApi::handleBundlePriorities);

    METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("file")), true, QueueApi::handleAddFileBundle);
    METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("directory")), true, QueueApi::handleAddDirectoryBundle);

    METHOD_HANDLER("bundle", Access::QUEUE_VIEW, ApiRequest::METHOD_GET, (TOKEN_PARAM), false, QueueApi::handleGetBundle);
    METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("remove")), false, QueueApi::handleRemoveBundle);
    METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_PATCH, (TOKEN_PARAM), true, QueueApi::handleUpdateBundle);

    METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("search")), false, QueueApi::handleSearchBundle);
    METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("share")), false, QueueApi::handleShareBundle);

    /*METHOD_HANDLER("temp_item", ApiRequest::METHOD_POST, (), true, QueueApi::handleAddTempItem);
    METHOD_HANDLER("temp_item", ApiRequest::METHOD_GET, (TOKEN_PARAM), false, QueueApi::handleGetFile);
    METHOD_HANDLER("temp_item", ApiRequest::METHOD_DELETE, (TOKEN_PARAM), false, QueueApi::handleRemoveFile);

    METHOD_HANDLER("filelist", ApiRequest::METHOD_POST, (), true, QueueApi::handleAddFilelist);
    METHOD_HANDLER("filelist", ApiRequest::METHOD_GET, (TOKEN_PARAM), false, QueueApi::handleGetFile);
    METHOD_HANDLER("filelist", ApiRequest::METHOD_DELETE, (TOKEN_PARAM), false, QueueApi::handleRemoveFile);*/

    METHOD_HANDLER("remove_source", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (), true, QueueApi::handleRemoveSource);
    METHOD_HANDLER("remove_file", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (), true, QueueApi::handleRemoveFile);
    METHOD_HANDLER("find_dupe_paths", Access::ANY, ApiRequest::METHOD_POST, (), true, QueueApi::handleFindDupePaths);
}
예제 #16
0
	TransferApi::TransferApi(Session* aSession) : 
		SubscribableApiModule(aSession, Access::ANY),
		timer(getTimer([this] { onTimer(); }, 1000)),
		view("transfer_view", this, TransferUtils::propertyHandler, std::bind(&TransferApi::getTransfers, this))
	{
		DownloadManager::getInstance()->addListener(this);
		UploadManager::getInstance()->addListener(this);
		ConnectionManager::getInstance()->addListener(this);

		METHOD_HANDLER("tranferred_bytes", Access::ANY, ApiRequest::METHOD_GET, (), false, TransferApi::handleGetTransferredBytes);
		METHOD_HANDLER("stats", Access::ANY, ApiRequest::METHOD_GET, (), false, TransferApi::handleGetTransferStats);

		METHOD_HANDLER("force", Access::TRANSFERS, ApiRequest::METHOD_POST, (TOKEN_PARAM), false, TransferApi::handleForce);
		METHOD_HANDLER("disconnect", Access::TRANSFERS, ApiRequest::METHOD_POST, (TOKEN_PARAM), false, TransferApi::handleDisconnect);

		createSubscription("transfer_statistics");
		timer->start(false);

		loadTransfers();
	}
예제 #17
0
NDDS_ID createMasterFidSub(char *topic)
{
   NDDS_ID pSubObj;
   DPRINT(-1,"createMasterFidSub()");
   /* malloc subscription space */
   if ( (pSubObj = (NDDS_ID) malloc( sizeof(NDDS_OBJ)) ) == NULL )
   {
      return(NULL);
   }

   /* zero out structure */
   memset(pSubObj,0,sizeof(NDDS_OBJ));
   memcpy(pSubObj,NDDS_Domain,sizeof(NDDS_OBJ));

   strcpy(pSubObj->topicName,topic);

   /* fills in dataTypeName, TypeRegisterFunc, TypeAllocFunc, TypeSizeFunc */
   getFidCt_StatInfo(pSubObj);

   /* NDDS issue callback routine */
#ifndef RTI_NDDS_4x
   pSubObj->callBkRtn = FidCt_StatCallback;
   pSubObj->callBkRtnParam = NULL;
#endif  /* RTI_NDDS_4x */
   pSubObj->MulticastSubIP[0] = 0;   /* use UNICAST */
   pSubObj->BE_UpdateMinDeltaMillisec = 250;  /* 4 times a second */

#ifndef RTI_NDDS_4x
   createBESubscription(pSubObj);
#else  /* RTI_NDDS_4x */
   initBESubscription(pSubObj);
   attachOnDataAvailableCallback(pSubObj,FidCt_StatCallback,NULL);
   createSubscription(pSubObj);
#endif  /* RTI_NDDS_4x */

   return(pSubObj);
}
예제 #18
0
	QueueApi::QueueApi(Session* aSession) : SubscribableApiModule(aSession, Access::QUEUE_VIEW),
			bundleView("bundle_view", this, QueueBundleUtils::propertyHandler, getBundleList), fileView("queue_file_view", this, QueueFileUtils::propertyHandler, getFileList) {

		QueueManager::getInstance()->addListener(this);
		DownloadManager::getInstance()->addListener(this);

		createSubscription("bundle_added");
		createSubscription("bundle_removed");
		createSubscription("bundle_updated");

		// These are included in bundle_updated events as well
		createSubscription("bundle_tick");
		createSubscription("bundle_content");
		createSubscription("bundle_priority");
		createSubscription("bundle_status");
		createSubscription("bundle_sources");

		createSubscription("file_added");
		createSubscription("file_removed");
		createSubscription("file_updated");

		METHOD_HANDLER("bundles", Access::QUEUE_VIEW, ApiRequest::METHOD_GET, (NUM_PARAM, NUM_PARAM), false, QueueApi::handleGetBundles);
		METHOD_HANDLER("bundles", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("remove_finished")), false, QueueApi::handleRemoveFinishedBundles);
		METHOD_HANDLER("bundles", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("priority")), true, QueueApi::handleBundlePriorities);

		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("file")), true, QueueApi::handleAddFileBundle);
		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (EXACT_PARAM("directory")), true, QueueApi::handleAddDirectoryBundle);

		METHOD_HANDLER("bundle", Access::QUEUE_VIEW, ApiRequest::METHOD_GET, (TOKEN_PARAM, EXACT_PARAM("sources")), false, QueueApi::handleGetBundleSources);
		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_DELETE, (TOKEN_PARAM, EXACT_PARAM("source"), CID_PARAM), false, QueueApi::handleRemoveBundleSource);

		METHOD_HANDLER("bundle", Access::QUEUE_VIEW, ApiRequest::METHOD_GET, (TOKEN_PARAM), false, QueueApi::handleGetBundle);
		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("remove")), false, QueueApi::handleRemoveBundle);
		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_PATCH, (TOKEN_PARAM), true, QueueApi::handleUpdateBundle);

		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("search")), false, QueueApi::handleSearchBundle);
		METHOD_HANDLER("bundle", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("share")), false, QueueApi::handleShareBundle);

		METHOD_HANDLER("file", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (TOKEN_PARAM, EXACT_PARAM("search")), false, QueueApi::handleSearchFile);
		METHOD_HANDLER("file", Access::QUEUE_EDIT, ApiRequest::METHOD_PATCH, (TOKEN_PARAM), true, QueueApi::handleUpdateFile);

		METHOD_HANDLER("remove_source", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (), true, QueueApi::handleRemoveSource);
		METHOD_HANDLER("remove_file", Access::QUEUE_EDIT, ApiRequest::METHOD_POST, (), true, QueueApi::handleRemoveTarget);
		METHOD_HANDLER("find_dupe_paths", Access::ANY, ApiRequest::METHOD_POST, (), true, QueueApi::handleFindDupePaths);
	}
예제 #19
0
PrintQueueModel::PrintQueueModel(const QString &destName, WId parentId, QObject *parent) :
    QStandardItemModel(parent),
    m_printer(new KCupsPrinter(destName)),
    m_jobRequest(0),
    m_destName(destName),
    m_whichjobs(CUPS_WHICHJOBS_ACTIVE),
    m_parentId(parentId),
    m_subscriptionId(-1)
{
    setHorizontalHeaderItem(ColStatus,        new QStandardItem(i18n("Status")));
    setHorizontalHeaderItem(ColName,          new QStandardItem(i18n("Name")));
    setHorizontalHeaderItem(ColUser,          new QStandardItem(i18n("User")));
    setHorizontalHeaderItem(ColCreated,       new QStandardItem(i18n("Created")));
    setHorizontalHeaderItem(ColCompleted,     new QStandardItem(i18n("Completed")));
    setHorizontalHeaderItem(ColPages,         new QStandardItem(i18n("Pages")));
    setHorizontalHeaderItem(ColProcessed,     new QStandardItem(i18n("Processed")));
    setHorizontalHeaderItem(ColSize,          new QStandardItem(i18n("Size")));
    setHorizontalHeaderItem(ColStatusMessage, new QStandardItem(i18n("Status Message")));
    setHorizontalHeaderItem(ColPrinter,       new QStandardItem(i18n("Printer")));

    // Setup the attributes we want from jobs
    m_jobAttributes << KCUPS_JOB_ID;
    m_jobAttributes << KCUPS_JOB_NAME;
    m_jobAttributes << KCUPS_JOB_K_OCTETS;
    m_jobAttributes << KCUPS_JOB_K_OCTETS_PROCESSED;
    m_jobAttributes << KCUPS_JOB_STATE;
    m_jobAttributes << KCUPS_TIME_AT_COMPLETED;
    m_jobAttributes << KCUPS_TIME_AT_CREATION;
    m_jobAttributes << KCUPS_TIME_AT_PROCESSING;
    m_jobAttributes << KCUPS_JOB_PRINTER_URI;
    m_jobAttributes << KCUPS_JOB_ORIGINATING_USER_NAME;
    m_jobAttributes << KCUPS_JOB_MEDIA_PROGRESS;
    m_jobAttributes << KCUPS_JOB_MEDIA_SHEETS;
    m_jobAttributes << KCUPS_JOB_MEDIA_SHEETS_COMPLETED;
    m_jobAttributes << KCUPS_JOB_PRINTER_STATE_MESSAGE;
    m_jobAttributes << KCUPS_JOB_PRESERVED;

    // This is emitted when a job change it's state
    connect(KCupsConnection::global(),
            SIGNAL(jobState(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)),
            this,
            SLOT(insertUpdateJob(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // This is emitted when a job is created
    connect(KCupsConnection::global(),
            SIGNAL(jobCreated(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)),
            this,
            SLOT(insertUpdateJob(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // This is emitted when a job is stopped
    connect(KCupsConnection::global(),
            SIGNAL(jobStopped(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)),
            this,
            SLOT(insertUpdateJob(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // This is emitted when a job has it's config changed
    connect(KCupsConnection::global(),
            SIGNAL(jobConfigChanged(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)),
            this,
            SLOT(insertUpdateJob(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // This is emitted when a job change it's progress
    connect(KCupsConnection::global(),
            SIGNAL(jobProgress(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)),
            this,
            SLOT(insertUpdateJob(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    // This is emitted when a printer is removed
    connect(KCupsConnection::global(),
            SIGNAL(jobCompleted(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)),
            this,
            SLOT(jobCompleted(QString,QString,QString,uint,QString,bool,uint,uint,QString,QString,uint)));

    createSubscription();

    // Get all jobs
    getJobs();
}