示例#1
0
    void ServerGroupDialog::editIdentity()
    {
        QPointer<IdentityDialog> dlg = new IdentityDialog(this);
        dlg->setCurrentIdentity(m_mainWidget->m_identityCBox->currentIndex());

        if(dlg->exec() == KDialog::Accepted)
        {
            IdentityList identities = Preferences::identityList();
            m_mainWidget->m_identityCBox->clear();

            for(IdentityList::ConstIterator it = identities.constBegin(); it != identities.constEnd(); ++it)
            {
                m_mainWidget->m_identityCBox->addItem((*it)->getName());
            }

            const int i = m_mainWidget->m_identityCBox->findText(dlg->currentIdentity()->getName());
            if (i != -1)
            {
                m_mainWidget->m_identityCBox->setCurrentIndex(i);
            }
            else
            {
                m_mainWidget->m_identityCBox->setItemText(m_mainWidget->m_identityCBox->currentIndex(), dlg->currentIdentity()->getName());
            }

            m_identitiesNeedsUpdate = true; // and what's this for?
            ViewContainer* vc = Application::instance()->getMainWindow()->getViewContainer();
            vc->updateViewEncoding(vc->getFrontView());
        }
        delete dlg;
    }
示例#2
0
QStringList KonvIdentDCOP::listIdentities()
{
    QStringList identities;
    IdentityList ids = Preferences::identityList();
    for(IdentityList::ConstIterator it = ids.begin(); it != ids.end(); ++it)
    {
        identities.append((*it)->getName());
    }
    return identities;
}
示例#3
0
    ServerGroupDialog::ServerGroupDialog(const QString& title, QWidget *parent)
        : KDialog(parent)
    {
        setCaption(title);
        setButtons(Ok|Cancel);

        m_id = -1;
        m_identitiesNeedsUpdate = false;
        m_editedServer = false;

        m_mainWidget = new Ui::ServerGroupDialogUI();
        m_mainWidget->setupUi(mainWidget());
        mainWidget()->layout()->setMargin(0);
        m_mainWidget->serverWidget->layout()->setMargin(0);
        m_mainWidget->channelWidget->layout()->setMargin(0);

        connect(m_mainWidget->m_editIdentityButton, SIGNAL(clicked()), this, SLOT(editIdentity()));

        IdentityList identities = Preferences::identityList();

        for (IdentityList::ConstIterator it = identities.constBegin(); it != identities.constEnd(); ++it)
            m_mainWidget->m_identityCBox->addItem((*it)->getName());

        m_mainWidget->m_removeServerButton->setIcon(KIcon("list-remove"));
        m_mainWidget->m_upServerBtn->setIcon(KIcon("arrow-up"));
        m_mainWidget->m_downServerBtn->setIcon(KIcon("arrow-down"));

        connect(m_mainWidget->m_addServerButton, SIGNAL(clicked()), this, SLOT(addServer()));
        connect(m_mainWidget->m_changeServerButton, SIGNAL(clicked()), this, SLOT(editServer()));
        connect(m_mainWidget->m_removeServerButton, SIGNAL(clicked()), this, SLOT(deleteServer()));
        connect(m_mainWidget->m_serverLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateServerArrows()));
        connect(m_mainWidget->m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
        connect(m_mainWidget->m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));

        m_mainWidget->m_removeChannelButton->setIcon(KIcon("list-remove"));
        m_mainWidget->m_upChannelBtn->setIcon(KIcon("arrow-up"));
        m_mainWidget->m_downChannelBtn->setIcon(KIcon("arrow-down"));

        connect(m_mainWidget->m_addChannelButton, SIGNAL(clicked()), this, SLOT(addChannel()));
        connect(m_mainWidget->m_changeChannelButton, SIGNAL(clicked()), this, SLOT(editChannel()));
        connect(m_mainWidget->m_removeChannelButton, SIGNAL(clicked()), this, SLOT(deleteChannel()));
        connect(m_mainWidget->m_channelLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateChannelArrows()));
        connect(m_mainWidget->m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
        connect(m_mainWidget->m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));

        setButtonGuiItem(Ok, KGuiItem(i18n("&OK"), "dialog-ok", i18n("Change network information")));
        setButtonGuiItem(Cancel, KGuiItem(i18n("&Cancel"), "dialog-cancel", i18n("Discards all changes made")));

        m_mainWidget->m_nameEdit->setFocus();

        setInitialSize(QSize(320, 400));
    }
示例#4
0
	/**
	 * @brief  Gets TLV value in a byte string format
	 * @param  byte_str [out] Output byte string
	 * @return void
	 */
	void toByteString(uint8_t * byte_str) {
		IdentityList::iterator iter;
		*((uint16_t *)byte_str) = tlvType;  // tlvType already in network byte order
		byte_str += sizeof(tlvType);
		*((uint16_t *)byte_str) = PLAT_htons
			((uint16_t)identityList.size()*PTP_CLOCK_IDENTITY_LENGTH);
		byte_str += sizeof(uint16_t);
		for
			(iter = identityList.begin();
			 iter != identityList.end(); ++iter) {
			iter->getIdentityString(byte_str);
			byte_str += PTP_CLOCK_IDENTITY_LENGTH;
		}
	}
示例#5
0
QString KonvIdentDCOP::getrealName(const QString &id_name)
{
    IdentityList ids = Preferences::identityList();

    for(IdentityList::ConstIterator it = ids.begin(); it != ids.end(); ++it)
    {
        if ((*it)->getName() == id_name)
        {
            return (*it)->getRealName();
        }
    }

    return QString();
}
示例#6
0
void KonvIdentDCOP::setrealName(const QString &id_name, const QString& name)
{
    IdentityList ids = Preferences::identityList();

    for(IdentityList::iterator it = ids.begin(); it != ids.end(); ++it)
    {
        if ((*it)->getName() == id_name)
        {
            (*it)->setRealName(name);
            return;
        }
    }

}
/*
 * Class:     com_openpeer_javaapi_OPAccount
 * Method:    removeIdentities
 * Signature: (Ljava/util/List;)V
 */
JNIEXPORT void JNICALL Java_com_openpeer_javaapi_OPAccount_removeIdentities
(JNIEnv *, jobject owner, jobject identitiesToRemove)
{
	jclass cls;
	jmethodID method;
	jobject object;
	JNIEnv *jni_env = 0;

	//Core identity list
	IdentityList coreIdentitiesToRemove;

	//fetch JNI env
	jni_env = getEnv();
	if(jni_env)
	{
		//create return object - java/util/List is interface, ArrayList is implementation
		jclass arrayListClass = findClass("java/util/ArrayList");
		if(jni_env->IsInstanceOf(identitiesToRemove, arrayListClass) != JNI_TRUE)
		{
			return;
		}
		// Fetch "java.util.List.get(int location)" MethodID
		jmethodID listGetMethodID = jni_env->GetMethodID(arrayListClass, "get", "(I)Ljava/lang/Object;");
		// Fetch "int java.util.List.size()" MethodID
		jmethodID sizeMethodID = jni_env->GetMethodID( arrayListClass, "size", "()I" );

		// Call "int java.util.List.size()" method and get count of items in the list.
		int listItemsCount = (int)jni_env->CallIntMethod( identitiesToRemove, sizeMethodID );

		for( int i=0; i<listItemsCount; ++i )
		{
			// Call "java.util.List.get" method and get IdentParams object by index.
			jobject identityObject = jni_env->CallObjectMethod( identitiesToRemove, listGetMethodID, i - 1 );
			if( identityObject != NULL )
			{
				IIdentityPtr identity = identityMap.find(identityObject)->second;
				//add core identities to list for removal
				coreIdentitiesToRemove.push_front(identity);
				//remove identity entry from jni identity map
				identityMap.erase(identityObject);
			}
		}
	}
	//remove associated identities from core
	if (accountPtr)
	{
		accountPtr->removeIdentities(coreIdentitiesToRemove);
	}
}
示例#8
0
	/**
	 * @brief  Parses ClockIdentity from message buffer
	 * @param  buffer [in] Message buffer. It should be at least ::PTP_CLOCK_IDENTITY_LENGTH bytes long.
	 * @param  size [in] Buffer size. Should be the length of the data pointed to by the buffer argument.
	 * @return void
	 */
	void parseClockIdentity(uint8_t *buffer, int size) {
		int length = PLAT_ntohs(*(uint16_t*)buffer);

		buffer += sizeof(uint16_t);
		size -= sizeof(uint16_t);

		if((unsigned)size < (unsigned)length) {
			length = size;
		}
		length /= PTP_CLOCK_IDENTITY_LENGTH;

		for(; length > 0; --length) {
			ClockIdentity add;
			add.set(buffer);
			identityList.push_back(add);
			buffer += PTP_CLOCK_IDENTITY_LENGTH;
		}
	}
示例#9
0
	/**
	 * @brief  Gets the total length of TLV.
	 * Total length of TLV is length of type field (UINT16) + length of 'length'
	 * field (UINT16) + length of
	 * identities (each PTP_CLOCK_IDENTITY_LENGTH) in the path
	 * @return Total length
	 */
	int length() {
		return (int)(2*sizeof(uint16_t) + PTP_CLOCK_IDENTITY_LENGTH*identityList.size());
	}
示例#10
0
	/**
	 * @brief  Looks for a specific ClockIdentity on the current TLV
	 * @param  id [in] Desired ClockIdentity
	 * @return TRUE if it has found it, FALSE otherwise.
	 */
	bool has(ClockIdentity *id) {
		return std::find
			(identityList.begin(), identityList.end(), *id) !=
			identityList.end();
	}
示例#11
0
	/**
	 * @brief  Appends new ClockIdentity to internal ClockIdentity list
	 * @param  id ClockIdentity to be appended
	 * @return void
	 */
	void appendClockIdentity(ClockIdentity * id) {
		identityList.push_back(*id);
	}
示例#12
0
文件: disco.cpp 项目: AimuTran/avbot
  bool Disco::handleIq( const IQ& iq )
  {
    switch( iq.subtype() )
    {
      case IQ::Get:
      {
        IQ re( IQ::Result, iq.from(), iq.id() );
        re.setFrom( iq.to() );

        const SoftwareVersion* sv = iq.findExtension<SoftwareVersion>( ExtVersion );
        if( sv )
        {
          re.addExtension( new SoftwareVersion( m_versionName, m_versionVersion, m_versionOs ) );
          m_parent->send( re );
          return true;
        }

        const Info *info = iq.findExtension<Info>( ExtDiscoInfo );
        if( info )
        {
          Info *i = new Info( EmptyString, true );
          if( !info->node().empty() )
          {
            i->setNode( info->node() );
            IdentityList identities;
            StringList features;
            DiscoNodeHandlerMap::const_iterator it = m_nodeHandlers.find( info->node() );
            if( it == m_nodeHandlers.end() )
            {
              delete i;
              IQ re( IQ::Error, iq.from(), iq.id() );
              re.addExtension( new Error( StanzaErrorTypeCancel, StanzaErrorItemNotFound ) );
              m_parent->send( re );
              return true;
            }
            else
            {
              DiscoNodeHandlerList::const_iterator in = (*it).second.begin();
              for( ; in != (*it).second.end(); ++in )
              {
                IdentityList il = (*in)->handleDiscoNodeIdentities( iq.from(), info->node() );
                il.sort(); // needed on win32
                identities.merge( il );
                StringList fl = (*in)->handleDiscoNodeFeatures( iq.from(), info->node() );
                fl.sort();  // needed on win32
                features.merge( fl );
              }
            }
            i->setIdentities( identities );
            i->setFeatures( features );
          }
          else
          {
            IdentityList il;
            IdentityList::const_iterator it = m_identities.begin();
            for( ; it != m_identities.end(); ++it )
            {
              il.push_back( new Identity( *(*it) ) );
            }
            i->setIdentities( il );
            i->setFeatures( m_features );
            if( m_form )
              i->setForm( new DataForm( *m_form ) );
          }

          re.addExtension( i );
          m_parent->send( re );
          return true;
        }

        const Items *items = iq.findExtension<Items>( ExtDiscoItems );
        if( items )
        {
          Items *i = new Items( items->node() );
          if( !items->node().empty() )
          {
            DiscoNodeHandlerMap::const_iterator it = m_nodeHandlers.find( items->node() );
            if( it == m_nodeHandlers.end() )
            {
              delete i;
              IQ re( IQ::Error, iq.from(), iq.id() );
              re.addExtension( new Error( StanzaErrorTypeCancel, StanzaErrorItemNotFound ) );
              m_parent->send( re );
              return true;
            }
            else
            {
              ItemList itemlist;
              DiscoNodeHandlerList::const_iterator in = (*it).second.begin();
              for( ; in != (*it).second.end(); ++in )
              {
                ItemList il = (*in)->handleDiscoNodeItems( iq.from(), iq.to(), items->node() );
                il.sort(); // needed on win32
                itemlist.merge( il );
              }
              i->setItems( itemlist );
            }
          }

          re.addExtension( i );
          m_parent->send( re );
          return true;
        }
        break;
      }

      case IQ::Set:
      {
        bool res = false;
        DiscoHandlerList::const_iterator it = m_discoHandlers.begin();
        for( ; it != m_discoHandlers.end(); ++it )
        {
          if( (*it)->handleDiscoSet( iq ) )
            res = true;
        }
        return res;
        break;
      }

      default:
        break;
    }
    return false;
  }