Example #1
0
 virtual void TriggerProperty(const std::string& key) {
     if (key == show_help_prop.get_key()) {
         panel_agent->request_help();
     }
     else if (key == logo_prop.get_key()) {
         panel_agent->request_factory_menu();
     }
     else if (key.substr(0, 9) == factory_prop_prefix) {
         panel_agent->change_factory(key.substr(9));// skip "/Factory/"
     }
     else if (key.substr(0, 8) == helper_prop_prefix) {
         panel_agent->start_helper(key.substr(8));// skip "/Helper/"
     }
     else {
         for (size_t i = 0; i < panel_props.size(); ++i) {
             if (key == panel_props.at(i).get_key()) {
                 // found one
                 std::vector<String> list_result;
                 for (size_t j = 0; j < panel_props.size(); ++j) {
                     if (panel_props.at(j).is_a_leaf_of(panel_props.at(i))) {
                         list_result.push_back(Property2String(panel_props.at(j)));
                     }
                 }
                 if (list_result.size() == 0) {
                     panel_agent->trigger_property(key);
                 }
                 else {
                     this->ExecMenu(list_result);
                 }
                 break;
             }
         }
     }
 }
	PropertyFilter::PropertyFilter(const PropertyList& aPropertyTypes) :
		propertyCount(aPropertyTypes.size()),
		defMethod(StringMatch::PARTIAL),
		currentFilterProperty(aPropertyTypes.size()),
		inverse(false),
		usingTypedMethod(false),
		numComparisonMode(LAST),
		propertyTypes(aPropertyTypes),
		id(lastFilterToken++)
	{
	}
void DBusInterfaceManager::supportedChanged(const PropertyList &supportedProperties)
{
	DebugOut()<<"supported Properties: "<<supportedProperties.size()<<endl;
	if(!connection)
	{
		return;
	}

	registerTypes();
}
uHTTP::HTTP::StatusCode ControlPoint::httpRequestRecieved(HTTPRequest *httpReq) {
  if (Debug::isOn() == true)
    httpReq->print();
    
  // Thanks for Giordano Sassaroli <*****@*****.**> (09/08/03)
  if (httpReq->isNotifyRequest() == true) {
    NotifyRequest notifyReq(httpReq);
    string uuidBuf;
    const char *uuid = notifyReq.getSID(uuidBuf);
    long seq = notifyReq.getSEQ();
    PropertyList *props = notifyReq.getPropertyList();
    int propCnt = props->size();
    for (int n = 0; n < propCnt; n++) {
      Property *prop = props->getProperty(n);
      const char *varName = prop->getName();
      const char *varValue = prop->getValue();
      performEventListener(uuid, seq, varName, varValue);
    }
    return httpReq->returnOK();
  }
    
  return httpReq->returnBadRequest();
}
Example #5
0
int main(int argc, char* argv[])
{
    String config_name("simple");
    String display_name;
    bool daemon = false;
    bool should_resident = true;

    //parse command options
    int i = 1;
    while (i < argc) {
        if (String("-l") == argv[i] || String("--list") == argv[i]) {
            std::cout << "\n";
            std::cout << "Available Config module:\n";
            // get config module list
            std::vector<String> config_list;
            scim_get_config_module_list(config_list);
            config_list.push_back("dummy");
            std::vector<String>::iterator it = config_list.begin();
            for (; it != config_list.end(); ++it) {
                std::cout << "    " << *it << "\n";
            }
            return 0;
        }
        else if (String("-c") == argv[i] || String("--config") == argv[i]) {
            if (++i >= argc) {
                std::cerr << "no argument for option " << argv[i-1] << "\n";
                return -1;
            }
            config_name = argv[i];
        }
        else if (String("-h") == argv[i] || String("--help") == argv[i]) {
            std::cout << "Usage: " << argv [0] << " [option]...\n\n"
                      << "The options are: \n"
                      << "  --display DISPLAY    Run on display DISPLAY.\n"
                      << "  -l, --list           List all of available config modules.\n"
                      << "  -c, --config NAME    Uses specified Config module.\n"
                      << "  -d, --daemon         Run " << argv [0] << " as a daemon.\n"
                      << "  -ns, --no-stay       Quit if no connected client.\n"
                      << "  -h, --help           Show this help message.\n";
            return 0;
        }
        else if (String("-d") == argv[i] || String("--daemon") == argv[i]) {
            daemon = true;
        }
        else if (String("-ns") == argv[i] || String("--no-stay") == argv[i]) {
            should_resident = false;
        }
        else if (String("--display") == argv[i]) {
            if (++i >= argc) {
                std::cerr << "No argument for option " << argv[i-1] << "\n";
                return -1;
            }
            display_name = argv[i];
        }
        else {
            std::cerr << "Invalid command line option: " << argv[i] << "\n";
            return -1;
        }
        ++i;
    }

    // Make up DISPLAY env.
    if (display_name.length()) {
        setenv("DISPLAY", display_name.c_str(), 1);
    }

    if (config_name == "dummy") {
        _config = new DummyConfig();
    }
    else {
        _config_module = new ConfigModule(config_name);
        if (!_config_module || !_config_module->valid()) {
            std::cerr << "Can not load " << config_name << " Config module.\n";
            return -1;
        }
        _config = _config_module->create_config();
    }

    if (_config.null()) {
        std::cerr << "Failed to create instance from " << config_name << " Config module.\n";
        return -1;
    }


    signal(SIGTERM, niam);
    signal(SIGINT, niam);

    if (!initialize_panel_agent(config_name, display_name, should_resident)) {
        std::cerr << "Failed to initialize PanelAgent.\n";
        return -1;
    }

    if (daemon)
        scim_daemon();

    if (!run_panel_agent()) {
        std::cerr << "Failed to run Socket Server!\n";
        return -1;
    }

    start_auto_start_helpers();

    DBus::default_dispatcher = &dispatcher;

    DBus::Connection conn = DBus::Connection::SessionBus();
    conn.request_name("org.kde.impanel.inputmethod");

    panel = new Panel(conn);

    /// add initial helper as helper property
    PropertyList props;
    std::vector<HelperInfo>::const_iterator it = _helper_list.begin();
    std::vector<HelperInfo>::const_iterator end = _helper_list.end();
    while (it != end) {
        if ((it->option & SCIM_HELPER_STAND_ALONE)
                && !(it->option & SCIM_HELPER_AUTO_START)) {
            props.push_back(Property(String(helper_prop_prefix) + it->uuid,
                                     it->name,
                                     it->icon,
                                     it->description));
        }
        ++it;
    }
    if (props.size()) {
        helper_props_map[0] = props;
    }

    dispatcher.enter();

    delete panel;

    return 0;
}
/** 
 * Get a bean with bean's name
 * @param basename Bean's base class name
 * @return A pointer to the bean or to its base class
 */
void* BeanFactoryImpl::getBean(const string& name, const string& basename)
{
	void* p;
	int i;

	BeanConfig* bc = this->Config->getBeanConfig(name);
	// Not found
	if( bc == NULL ){
		AutumnLog::getInstance()->error("BeanFactoryImpl->getBean: bean[" +
				name + "]'s config is not found");
		return NULL;
	}

	// If singleton
	if( bc->isSingleton() ){
		p = this->ManagerOfBean->getSingleton(name);
		if( p != NULL) 
			return this->ManagerOfBean->getBeanWrapper(p)->cast2Base(basename);
	}

	// Create depended objects, they should be singletons.
	const StrValueList vl = bc->getDependedObjects();
	for( i=0; i<vl.size(); i++){
		if( this->ManagerOfBean->getSingleton(vl[i]) == NULL)
			this->getBean(vl[i]);
	}

	//Use auto_ptr to free pw if exception happens?
	auto_ptr<IBeanWrapper> pw(bc->createWrapper());

	// if use factory, use factory's wrapper to create bean.
	// pwc only to create bean, it may be bean wrapper or factory's wrapper.
	IBeanWrapper* pwc = NULL;
	if( ! bc->getFactoryBeanName().empty()) {
		void* pf = this->getBean(bc->getFactoryBeanName());
		if( pf == NULL){
			throw CreateBeanFailedEx("BeanFactoryImpl", "getBean", 
				string("Create Bean [") + name + "] failed! Get factory [" +
				bc->getFactoryBeanName() + "] failed!");
		}
		pwc = this->ManagerOfBean->getBeanWrapper(pf);
	}
	if( NULL == pwc ) pwc = pw.get();

	//Create bean
	typedef void* void_ptr;
	string conMethod = bc->getConMethod();
	PropertyList* pargs = bc->getConArgs(pwc);
	int num = pargs->size();
	if( num > 0 ){	//Has constructor arguments
		auto_ptr<void_ptr> pp( new void_ptr[num] );
		void_ptr* pv = pp.get();

		for(i=0; i<num; i++){
			// add argument into pw, not pwc
			pv[i] = (*pargs)[i]->takeoutValue(pw.get(), this->ManagerOfType);
		}
		p = pwc->execCreateMethod(conMethod, pv, num);
	}
	else{
		void_ptr* pDummy = NULL;
		p = pwc->execCreateMethod(conMethod, pDummy, num);
	}	

	if( NULL == p){
		throw CreateBeanFailedEx("BeanFactoryImpl", "getBean", 
			string("Create Bean [") + name + "] failed!");
	}
	//if bean created by factory, it should be set into pw.
	if( ! bc->getFactoryBeanName().empty()) {
		pw->setBean(p);
	}

	//Set properties
	PropertyList* props = bc->getProperties();
	for(i=0; i<props->size(); i++){
		(*props)[i]->setProperty(pw.get(), this->ManagerOfType);
	}

	//Initialize bean
	string initmethod = pw->getInitMethod();
	if( !initmethod.empty() ){
		pw->execVoidMethod(initmethod, NULL, 0);
	}

	IBeanWrapper* pw_tmp = pw.get();
	//Add to bean manager
	this->ManagerOfBean->addBean(name, pw.release());

	return pw_tmp->cast2Base(basename);
}
    bool EqualityHelper::internalEqual(DataObjectPtr dataObject1,
                                                DataObjectPtr dataObject2,
                                            bool fullEqual)
    {

    
        PropertyList pl = dataObject1->getInstanceProperties();
        for (unsigned int i=0;i < pl.size(); i++)
        {
            // data objects are only compared the deep equality case
            if (pl[i].getType().isDataObjectType())
            {
                if (!fullEqual) 
                {
                    continue;
                }
                else
                {
                    if (pl[i].isMany())
                    {
                        DataObjectList& dolold = dataObject1->getList(pl[i]);
                        DataObjectList& dolnew = dataObject2->getList(pl[i]);
                        if (dolnew.size() != dolold.size()) return false;

                        for (unsigned int i=0;i< dolold.size(); i++)
                        {
                            if (!internalEqual(dolold[i], dolnew[i], true))
                            {
                                return false;
                            }
                        }
                    }
                    else 
                    {
                        if (!internalEqual(
                            dataObject1->getDataObject(pl[i]),
                            dataObject2->getDataObject(pl[i]), true))
                        {
                            return false;
                        }
                    }
                }
            }
            else 
            {
                if (pl[i].isMany())
                {
                    DataObjectList& dolold = dataObject1->getList(pl[i]);
                    DataObjectList& dolnew = dataObject2->getList(pl[i]);
                    if (dolold.size() != dolnew.size()) return false;
                    if (!comparelist(dolold, dolnew, pl[i].getTypeEnum())) return false;
                }
                else 
                {
                    if (!compareitem(dataObject1,dataObject2, pl[i]))
                    {
                        return false;
                    }
                } // else
            } 
        } 
        return true;
    }