示例#1
0
bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
{
    if (*cmd)
    {
        for (uint32 i = 0; table[i].Name != NULL; ++i)
        {
            // must be available (ignore handler existence for show command with possible available subcommands)
            if (!isAvailable(table[i]))
                continue;

            if (!hasStringAbbr(table[i].Name, cmd))
                continue;

            // have subcommand
            char const* subcmd = (*cmd) ? strtok(NULL, " ") : "";

            if (table[i].ChildCommands && subcmd && *subcmd)
            {
                if (ShowHelpForCommand(table[i].ChildCommands, subcmd))
                    return true;
            }

            if (!table[i].Help.empty())
                SendSysMessage(table[i].Help.c_str());

            if (table[i].ChildCommands)
                if (ShowHelpForSubCommands(table[i].ChildCommands, table[i].Name, subcmd ? subcmd : ""))
                    return true;

            return !table[i].Help.empty();
        }
    }
    else
    {
        for (uint32 i = 0; table[i].Name != NULL; ++i)
        {
            // must be available (ignore handler existence for show command with possible available subcommands)
            if (!isAvailable(table[i]))
                continue;

            if (strlen(table[i].Name))
                continue;

            if (!table[i].Help.empty())
                SendSysMessage(table[i].Help.c_str());

            if (table[i].ChildCommands)
                if (ShowHelpForSubCommands(table[i].ChildCommands, "", ""))
                    return true;

            return !table[i].Help.empty();
        }
    }

    return ShowHelpForSubCommands(table, "", cmd);
}
TEST_F(DBusCommunicationTest, SameStubCanBeRegisteredSeveralTimes) {
    auto defaultTestProxy = runtime_->buildProxy<VERSION::commonapi::tests::TestInterfaceProxy>(domain_, serviceAddress_);
    auto defaultTestProxy2 = runtime_->buildProxy<VERSION::commonapi::tests::TestInterfaceProxy>(domain_, serviceAddress2_);
    auto defaultTestProxy3 = runtime_->buildProxy<VERSION::commonapi::tests::TestInterfaceProxy>(domain_, serviceAddress3_);
    ASSERT_TRUE((bool)defaultTestProxy);
    ASSERT_TRUE((bool)defaultTestProxy2);
    ASSERT_TRUE((bool)defaultTestProxy3);

    auto stub = std::make_shared<VERSION::commonapi::tests::TestInterfaceStubDefault>();
    interface_ = stub->getStubAdapter()->getInterface();

    bool serviceRegistered = runtime_->registerService(domain_, serviceAddress_, stub, "connection");
    bool serviceRegistered2 = runtime_->registerService(domain_, serviceAddress2_, stub, "connection");
    bool serviceRegistered3 = runtime_->registerService(domain_, serviceAddress3_, stub, "connection");
    for (unsigned int i = 0; (!serviceRegistered || !serviceRegistered2 || !serviceRegistered3) && i < 100; ++i) {
        if (!serviceRegistered) {
            serviceRegistered = runtime_->registerService(domain_, serviceAddress_, stub, "connection");
        }
        if (!serviceRegistered2) {
            serviceRegistered2 = runtime_->registerService(domain_, serviceAddress2_, stub, "connection");
        }
        if (!serviceRegistered3) {
            serviceRegistered3 = runtime_->registerService(domain_, serviceAddress3_, stub, "connection");
        }
        usleep(10000);
    }
    ASSERT_TRUE(serviceRegistered);
    ASSERT_TRUE(serviceRegistered2);
    ASSERT_TRUE(serviceRegistered3);

    for(unsigned int i = 0; (!defaultTestProxy->isAvailable() || !defaultTestProxy2->isAvailable() || !defaultTestProxy3->isAvailable()) && i < 100; ++i) {
        usleep(10000);
    }
    ASSERT_TRUE(defaultTestProxy->isAvailable());
    ASSERT_TRUE(defaultTestProxy2->isAvailable());
    ASSERT_TRUE(defaultTestProxy3->isAvailable());

    uint32_t v1 = 5;
    std::string v2 = "Ciao ;)";
    CommonAPI::CallStatus stat, stat2, stat3;
    defaultTestProxy->testVoidPredefinedTypeMethod(v1, v2, stat);
    defaultTestProxy2->testVoidPredefinedTypeMethod(v1, v2, stat2);
    defaultTestProxy3->testVoidPredefinedTypeMethod(v1, v2, stat3);

    EXPECT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
    EXPECT_EQ(stat2, CommonAPI::CallStatus::SUCCESS);
    EXPECT_EQ(stat3, CommonAPI::CallStatus::SUCCESS);
}
void testConnectServer(){
	init();
	if (connectExpandable()){
		TRACE_WIN32A("[connectExpandable] ¼º°ø");
		
		isAvailable();
		TRACE_WIN32A("[connectExpandable] isAvail ´ÙÀ½");

	/*	std::string buffer;
		NOTIFICATION_ITEM item;
		item.type = PROGRESSVALUE;
		item.value = 66;
		item.infomation.hwnd = 50;
		item.infomation.pid = 4500;
		memcpy(item.infomation.pname, "chrome.exe", 11);
		writeJSON(item, buffer);
		if (isConnected()){
			sendData(buffer);
		}*/
	}
	while (1){
	}
	disconnectExpandable();
	clean();
}
示例#4
0
void DOMSelection::deleteFromDocument() {
    if (!isAvailable())
        return;

    FrameSelection& selection = frame()->selection();

    if (selection.isNone())
        return;

    // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
    // needs to be audited.  See http://crbug.com/590369 for more details.
    // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
    frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();

    Range* selectedRange =
        createRange(selection.selection().toNormalizedEphemeralRange());
    if (!selectedRange)
        return;

    selectedRange->deleteContents(ASSERT_NO_EXCEPTION);

    setBaseAndExtent(selectedRange->startContainer(),
                     selectedRange->startOffset(),
                     selectedRange->startContainer(),
                     selectedRange->startOffset(), ASSERT_NO_EXCEPTION);
}
示例#5
0
void DOMSelection::collapse(Node* node,
                            int offset,
                            ExceptionState& exceptionState) {
    if (!isAvailable())
        return;

    if (!node) {
        UseCounter::count(frame(), UseCounter::SelectionCollapseNull);
        frame()->selection().clear();
        return;
    }

    if (offset < 0) {
        exceptionState.throwDOMException(
            IndexSizeError, String::number(offset) + " is not a valid offset.");
        return;
    }

    if (!isValidForPosition(node))
        return;
    Range::checkNodeWOffset(node, offset, exceptionState);
    if (exceptionState.hadException())
        return;

    frame()->selection().setSelection(
        SelectionInDOMTree::Builder()
        .collapse(Position(node, offset))
        .setIsDirectional(frame()->selection().isDirectional())
        .build());
}
示例#6
0
TrayIcon::TrayIcon(const QIcon &icon, QObject *parent)
: QObject(parent), d(new Data) {
    d->p = this;
    if (!isAvailable())
        return;
#ifdef Q_OS_LINUX
    if (d->unity) {
        d->gmenu = gtk_menu_new();
        auto quit = gtk_menu_item_new_with_label(tr("Quit").toLocal8Bit());
        auto show = gtk_menu_item_new_with_label(tr("Show").toLocal8Bit());
        gtk_menu_shell_append(GTK_MENU_SHELL(d->gmenu), show);
        gtk_menu_shell_append(GTK_MENU_SHELL(d->gmenu), quit);
        gtk_widget_show(show);
        gtk_widget_show(quit);
        g_signal_connect(show, "activate", G_CALLBACK(onShow), this);
        g_signal_connect(quit, "activate", G_CALLBACK(onQuit), this);
        d->indicator = app_indicator_new("net.xylosper.CMPlayer.AppIndicator", "cmplayer", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
        app_indicator_set_menu(d->indicator, GTK_MENU(d->gmenu));
        return;
    }
#endif
    d->tray = new QSystemTrayIcon(icon, this);
    connect(d->tray, &QSystemTrayIcon::activated, [this] (QSystemTrayIcon::ActivationReason r) {
        emit activated(static_cast<ActivationReason>(r));
    });
}
void ComponentSessionStanzaChannel::send(boost::shared_ptr<Stanza> stanza) {
	if (!isAvailable()) {
		std::cerr << "Warning: Component: Trying to send a stanza while disconnected." << std::endl;
		return;
	}
	session->sendStanza(stanza);
}
示例#8
0
QtopiaNetworkInterface::Status LanImpl::status()
{
    //don't change status - initialize has not been called yet
    if ( ifaceStatus == QtopiaNetworkInterface::Unknown) {
        return ifaceStatus;
    }

    QtopiaNetworkInterface::Status status = QtopiaNetworkInterface::Unavailable;

    if ( isAvailable() ) {
        status = QtopiaNetworkInterface::Down;

        if ( thread.remainingTasks() > 0 ) {
            //still some jobs to do -> don't do anything until they are done
            status = ifaceStatus;
        } else {
            switch( ifaceStatus ) {
            case QtopiaNetworkInterface::Demand:
                status = ifaceStatus;
                break;
            case QtopiaNetworkInterface::Pending:
            default:
                if ( isActive() )
                    status = QtopiaNetworkInterface::Up;
                break;
            }
        }
    }

    ifaceStatus = status;
    netSpace->setAttribute( "State", (int)ifaceStatus );
    updateTrigger();
    return ifaceStatus;
}
示例#9
0
void VideoOutput::handlePaintEvent()
{
    if (!isAvailable())
        return;
    DPTR_D(VideoOutput);
    d.impl->handlePaintEvent();
}
示例#10
0
void VideoOutput::drawFrame()
{
    if (!isAvailable())
        return;
    DPTR_D(VideoOutput);
    d.impl->drawFrame();
}
示例#11
0
void VideoOutput::drawBackground()
{
    if (!isAvailable())
        return;
    DPTR_D(VideoOutput);
    d.impl->drawBackground();
}
示例#12
0
bool VideoOutput::needUpdateBackground() const
{
    if (!isAvailable())
        return false;
    DPTR_D(const VideoOutput);
    return d.impl->needUpdateBackground();
}
示例#13
0
void QAudioManager::add(const QAudioManager::Mode mode,  QAbstractCoder *coder)
{
	setError(QCoder::NoError);
	if(mode == QAudioManager::Available)
	{
		if(!isAvailable(coder))
		{
			mAvailableCoders.append(coder);
			QList<QAudioCodec*> codecs = coder->supportedCodecs();
			for(int i = 0; i < codecs.size(); ++i)
			{
				add(mode, codecs[i]);
			}
		}
	}
	else
	{
		if(!isSupported(coder))
		{
			mSupportedCoders.append(coder);
			QList<QAudioCodec*> codecs = coder->supportedCodecs();
			for(int i = 0; i < codecs.size(); ++i)
			{
				add(mode, codecs[i]);
			}
		}
	}
}
/**
* @test Synchronous Calls Do Not Deadlock.
* 	- get proxy with available flag = true
* 	- call synchronous test method in syncCallThread
* 	- 5 broadcasts should arrive in the right order
* 	- run the mainloop again in order to give the syncCallThread a chance to return
*/
TEST_F(MainLoopTest, SyncCallsDoNotDeadlock) {
    auto proxy = mainloopFactoryProxy_->buildProxy<commonapi::tests::TestInterfaceProxy>(testAddress8);
    ASSERT_TRUE((bool) proxy);

    std::thread stubThread = std::thread([&]() {mainLoopForStub_->run();});

    // let the proxy become available
    while (!proxy->isAvailable()) {
        mainLoopForProxy_->doSingleIteration();
        usleep(500);
    }

    uint32_t inInt, outInt;
    std::string inStr, outStr;
    inInt = 1;
    outInt = 0;

    callStatus = CommonAPI::CallStatus::REMOTE_ERROR;

    std::thread syncCallThread = std::thread(
                    [&]() {proxy->testPredefinedTypeMethod(inInt, inStr, callStatus, outInt, outStr);}
                    );
    sleep(10);

    ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus);

    if (callStatus != CommonAPI::CallStatus::SUCCESS) {
        mainLoopForProxy_->runVerification(10, true, true); // run the mainloop again in order to give the syncCallThread a chance to return
    }
    mainLoopForStub_->stop();
    stubThread.join();
    syncCallThread.join();
}
示例#15
0
bool DispatchStage::execute(InstRef &IR) {
  const InstrDesc &Desc = IR.getInstruction()->getDesc();
  if (!isAvailable(Desc.NumMicroOps) || !canDispatch(IR))
    return false;
  dispatch(IR);
  return true;
}
示例#16
0
void VideoOutput::onResizeRenderer(int width, int height)
{
    if (!isAvailable())
        return;
    DPTR_D(VideoOutput);
    d.impl->resizeRenderer(width, height);
}
void ClientSessionStanzaChannel::send(std::shared_ptr<Stanza> stanza) {
    if (!isAvailable()) {
        SWIFT_LOG(warning) << "Client: Trying to send a stanza while disconnected." << std::endl;
        return;
    }
    session->sendStanza(stanza);
}
示例#18
0
QPointF VideoOutput::onMapFromFrame(const QPointF& p) const
{
    if (!isAvailable())
        return QPointF();
    DPTR_D(const VideoOutput);
    return d.impl->onMapFromFrame(p);
}
示例#19
0
void BluetoothImpl::initialize()
{
    if ( !netSpace ) { //initialize the value space for this interface
        QByteArray path("/Network/Interfaces/"+ QByteArray::number(qHash(configIface->configFile())) );
        netSpace = new QValueSpaceObject( path, this );
        netSpace->setAttribute( QLatin1String("Config"), configIface->configFile() );
        netSpace->setAttribute( QLatin1String("State"), QtopiaNetworkInterface::Unknown );
        netSpace->setAttribute( QLatin1String("Error"), QtopiaNetworkInterface::NotInitialized );
        netSpace->setAttribute( QLatin1String("ErrorString"), tr("Interface hasn't been initialized yet.") );
        netSpace->setAttribute( QLatin1String("NetDevice"), QVariant() );
        netSpace->setAttribute( QLatin1String("BtDevice"), QVariant() );
        netSpace->setAttribute( QLatin1String("UpdateTrigger"), 0 );
    }
    if ( !dialupDev ) {
        dialupDev = new BluetoothDialupDevice( this );
        connect( dialupDev, SIGNAL(deviceStateChanged()),
                this, SLOT(updateState()) );
        connect( dialupDev, SIGNAL(connectionEstablished()),
                this, SLOT(serialPortConnected()) );
    }

    if ( isAvailable() ) {
        ifaceStatus = Down;
    } else {
        ifaceStatus = Unavailable;
    }
    netSpace->setAttribute( QLatin1String("State"), ifaceStatus );
    updateTrigger();
}
示例#20
0
bool Win32Event::wait( long milliseconds ) {
    if( isAvailable() ) {
        DWORD result = WaitForSingleObject( event_ , milliseconds );
        switch( result ) {
        case WAIT_TIMEOUT:
            // タイムアウトによるリターン
            return false;
        case WAIT_OBJECT_0:
            // 正常にwaitから解放された。
            return true;
        case WAIT_ABANDONED:
            // 所有権が放棄されたeventだった。
            return true;
        case WAIT_FAILED:
            PSS_THROW_PARAM1( ::pss::std::Win32Error(GetLastError()) , "");
        default:
            // 不明なエラー
            PSS_THROW_PARAM1( ::pss::std::Win32Error(GetLastError()) , "");
        }
        return false;
    } else {
        //	eventオブジェクト生成時のエラー
        PSS_THROW_PARAM1( ::pss::std::Win32Error(constructError_) , "");
        return false;
    }
}
示例#21
0
eCzCameraStatus CzPlatformCam::getStatus()
{
	if (!isAvailable() || !Started)
		return CS_Failed;

	return CS_Failed;
}
示例#22
0
string album_db::exportFactor(purchase_list purchaseList)
{
    std::ostringstream factor;
    double cost = 0;

    for(int i=0;i<purchaseList.list.size();i++)
    {
        purchase item;
        item = purchaseList.list.at(i);

        if(isAvailable(item.get_album_id()))
        {
            if(item.get_track_id() == 0)
            {
                factor << findAlbumInfo(item.get_album_id())<<"\n";
                cost = cost + findAlbumPrice(item.get_album_id());
            }
            else
            {
                factor << findTrackInfo(item.get_album_id(),item.get_track_id())<<"\n";
                cost = cost + findTrackPrice(item.get_album_id(),item.get_track_id());
            }
        }
    }
    factor <<"\nTotal Price : "<<cost << "\n";
    return factor.str();
}
示例#23
0
文件: vrpn_Mutex.C 项目: ASPePeX/vrpn
void vrpn_Mutex_Remote::request(void)
{
    if (!isAvailable()) {

#ifdef VERBOSE
        fprintf(stderr, "Requested unavailable mutex.\n");
#endif
        triggerDenyCallbacks();
        return;
    }
    else if (d_myIndex == -1) {
#ifdef VERBOSE
        fprintf(stderr, "Requested mutex before initialization; deferring.\n");
#endif
        d_requestBeforeInit = vrpn_TRUE;
        return;
    }

#ifdef VERBOSE
    fprintf(stderr, "Requesting mutex\n");
#endif

    d_state = REQUESTING;
    sendRequest(d_myIndex);

    return;
}
示例#24
0
string album_db::buyAndExportFactor(purchase_list &purchaseList, purchase_list &history)
{
    std::ostringstream factor;
    double cost = 0;

    int i =0;
    while(i<purchaseList.list.size())
    {
        purchase item;
        item = purchaseList.list.at(i);

        if(isAvailable(item.get_album_id()))
        {
            if(item.get_track_id() == 0)
            {
                buyAlbum(item.get_album_id());
                factor << findAlbumInfo(item.get_album_id())<<"\n";
                cost = cost + findAlbumPrice(item.get_album_id());
            }
            else
            {
                buyTrack(item.get_album_id(),item.get_track_id());
                factor << findTrackInfo(item.get_album_id(),item.get_track_id())<<"\n";
                cost = cost + findTrackPrice(item.get_album_id(),item.get_track_id());
            }
            purchaseList.list.erase(purchaseList.list.begin()+i);
            history.list.push_back(item);
        }
        else
            i++;
    }
    factor <<"\nTotal Price : "<<cost << "\n";
    return factor.str();
}
示例#25
0
void ThinBlockWorker::setAvailable() {
    if (isAvailable())
        return;
    manager.delWorker(*this, node);
    block.SetNull();
    isReRequesting = false;
}
示例#26
0
bool VideoDecoderCUDA::decode(const QByteArray &encoded)
{
    if (!isAvailable())
        return false;
    DPTR_D(VideoDecoderCUDA);
    if (!d.parser) {
        qWarning("CUVID parser not ready");
        return false;
    }
    CUVIDSOURCEDATAPACKET cuvid_pkt;
    memset(&cuvid_pkt, 0, sizeof(CUVIDSOURCEDATAPACKET));
    cuvid_pkt.payload = (unsigned char *)encoded.data();
    cuvid_pkt.payload_size = encoded.size();
    cuvid_pkt.flags = CUVID_PKT_TIMESTAMP;
    cuvid_pkt.timestamp = 0;// ?
    //TODO: fill NALU header for h264? https://devtalk.nvidia.com/default/topic/515571/what-the-data-format-34-cuvidparsevideodata-34-can-accept-/
    {
        //cuvidCtxUnlock(d.vid_ctx_lock, 0); //TODO: why wrong context?
        CUresult cuStatus = cuvidParseVideoData(d.parser, &cuvid_pkt);
        if (cuStatus != CUDA_SUCCESS) {
            qWarning("cuMemcpyDtoH failed (%p, %s)", cuStatus, _cudaGetErrorEnum(cuStatus));
        }
    }
    // callbacks are in the same thread as this. so no queue is required?
    qDebug("frame queue size on decode: %d", d.frame_queue.size());
    return !d.frame_queue.isEmpty();

}
示例#27
0
Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) {
    if (!isAvailable())
        return nullptr;

    if (index < 0 || index >= rangeCount()) {
        exceptionState.throwDOMException(
            IndexSizeError, String::number(index) + " is not a valid index.");
        return nullptr;
    }

    // If you're hitting this, you've added broken multi-range selection support
    DCHECK_EQ(rangeCount(), 1);

    Position anchor = anchorPosition(visibleSelection());
    if (!anchor.anchorNode()->isInShadowTree())
        return frame()->selection().firstRange();

    Node* node = shadowAdjustedNode(anchor);
    if (!node)  // crbug.com/595100
        return nullptr;
    if (!visibleSelection().isBaseFirst())
        return Range::create(*anchor.document(), focusNode(), focusOffset(), node,
                             anchorOffset());
    return Range::create(*anchor.document(), node, anchorOffset(), focusNode(),
                         focusOffset());
}
示例#28
0
文件: Shader.cpp 项目: wpbest/XPF
void Shader::bind(const Shader* shader)
{
    ensureGlContext();

    // Make sure that we can use shaders
    if (!isAvailable())
    {
        err() << "Failed to bind or unbind shader: your system doesn't support shaders "
              << "(you should test Shader::isAvailable() before trying to use the Shader class)" << std::endl;
        return;
    }

    if (shader && shader->m_shaderProgram)
    {
        // Enable the program
        glCheck(GLEXT_glUseProgramObject(castToGlHandle(shader->m_shaderProgram)));

        // Bind the textures
        shader->bindTextures();

        // Bind the current texture
        if (shader->m_currentTexture != -1)
            glCheck(GLEXT_glUniform1i(shader->m_currentTexture, 0));
    }
    else
    {
        // Bind no shader
        glCheck(GLEXT_glUseProgramObject(0));
    }
}
示例#29
0
QCUPSSupport::QCUPSSupport()
    :
    prnCount(0),
    printers(0),
    page_sizes(0),
    currPrinterIndex(0),
    currPPD(0)
{
    if (!cupsLoaded)
        resolveCups();

    // getting all available printers
    if (!isAvailable())
        return;

    prnCount = _cupsGetDests(&printers);

    for (int i = 0; i <  prnCount; ++i) {
        if (printers[i].is_default) {
            currPrinterIndex = i;
            setCurrentPrinter(i);
            break;
        }
    }

#ifndef QT_NO_TEXTCODEC
    cups_lang_t *cupsLang = _cupsLangGet(0);
    codec = QTextCodec::codecForName(_cupsLangEncoding(cupsLang));
    if (!codec)
        codec = QTextCodec::codecForLocale();
#endif
}
示例#30
0
DBool InternalSoundRecorder::initialize(DUint sampleRate)
{
    // Check if the device can do audio capture
    if (!isAvailable())
    {
        sf::err() << "Failed to start capture : your system cannot capture audio data (call SoundRecorder::IsAvailable to check it)" << std::endl;
        return DFalse;
    }

    // Check that another capture is not already running
    if (captureDevice)
    {
        sf::err() << "Trying to start audio capture, but another capture is already running" << std::endl;
        return DFalse;
    }

    // Open the capture device for capturing 16 bits mono samples
    captureDevice = alcCaptureOpenDevice(NULL, sampleRate, AL_FORMAT_MONO16, sampleRate);
    if (!captureDevice)
    {
        sf::err() << "Failed to open the audio capture device" << std::endl;
        return DFalse;
    }

    // Clear the array of samples
    m_samples.clear();

    return DTrue;
}