예제 #1
0
Maybe<IProtocol*>
IProtocol::ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable,
                     const char* aActorDescription, int32_t aProtocolTypeId)
{
    int32_t id;
    if (!IPC::ReadParam(aMessage, aIter, &id)) {
        ActorIdReadError(aActorDescription);
        return Nothing();
    }

    if (id == 1 || (id == 0 && !aNullable)) {
        BadActorIdError(aActorDescription);
        return Nothing();
    }

    if (id == 0) {
        return Some(static_cast<IProtocol*>(nullptr));
    }

    IProtocol* listener = this->Lookup(id);
    if (!listener) {
        ActorLookupError(aActorDescription);
        return Nothing();
    }

    if (listener->GetProtocolTypeId() != aProtocolTypeId) {
        MismatchedActorTypeError(aActorDescription);
        return Nothing();
    }

    return Some(listener);
}
예제 #2
0
	void AccountsListWidget::on_Delete__released()
	{
		QModelIndex index = Ui_.Accounts_->
		selectionModel ()->currentIndex ();
		if (!index.isValid ())
			return;

		IAccount *acc = index
				.data (RAccObj).value<IAccount*> ();

		if (QMessageBox::question (this,
					"LeechCraft",
					tr ("Are you sure you want to remove the account %1?")
						.arg (acc->GetAccountName ()),
					QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
			return;

		QObject *protoObj = acc->GetParentProtocol ();
		IProtocol *proto = qobject_cast<IProtocol*> (protoObj);
		if (!proto)
		{
			qWarning () << Q_FUNC_INFO
					<< "parent protocol for"
					<< acc->GetAccountID ()
					<< "doesn't implement IProtocol";
			return;
		}
		proto->RemoveAccount (acc->GetObject ());
	}
예제 #3
0
IProtocol * Kernel::Protocol (string name)
{
	for (ProtocolList::iterator it = _protocols.begin(); it != _protocols.end(); ++it) {
		IProtocol *p = *it ;
		if (name == p->Class()) return p ;
	}
	return NULL ;
}
	void AddAccountWizardFirstPage::handleAccepted ()
	{
		QObject *obj = Ui_.ProtoBox_->itemData (field ("AccountProto").toInt ()).value<QObject*> ();
		IProtocol *proto = qobject_cast<IProtocol*> (obj);
		if (!proto)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to cast"
					<< obj
					<< "to IProtocol";
			return;
		}
		
		proto->RegisterAccount (Ui_.NameEdit_->text (), Widgets_);
	}
예제 #5
0
	void		Execute( CBuffer* pBuffer )
	{
		IProtocol*	pPrevProtocol	= NULL;
		IProtocol*	pCurrProtocol	= NULL;

		std::vector<IProtocol*>::iterator	it = list.begin();
		for( ; it!=list.end(); it++ )
		{
			pCurrProtocol	= (IProtocol*)*it;

			if( pCurrProtocol->Execute(pBuffer, pPrevProtocol) >= 0 )
			{
				pPrevProtocol	= pCurrProtocol;
			}
		}
	}
예제 #6
0
  ///Retrieves the messages from the buffer. Returns the number of messages retrieved.
  int UDPSocket::RetieveData( MessageList *messages )
  {
    ProtocolType ptype;
    IProtocol *protocol = 0;

    ///Determine the type of protocol to use.
    rstream.ReadData(ptype);
    protocol = NetAPI->GetProtocol(ptype);

    ///Protocol doesn't exist!!
    if (!protocol)
      return 0;

    ///Return the number of messages added.
    return protocol->ExtractMessages( rstream, messages );
  }
예제 #7
0
void AdminServer::process(IProtocol & protocol) {
  uint32_t id = protocol.readUInt32();
  switch (id) {
  case AdminID_Exit:        processExit(protocol);        break;
  case AdminID_LoadHandler: processLoadHandler(protocol); break;
  default:
    throw std::runtime_error("AdminServer::process: unknown ID");
  }
}
예제 #8
0
void AccountsListDialog::on_Delete__released()
{
    QModelIndex index = Ui_.Accounts_->
                        selectionModel ()->currentIndex ();
    if (!index.isValid ())
        return;

    IAccount *acc = index
                    .data (RAccObj).value<IAccount*> ();
    QObject *protoObj = acc->GetParentProtocol ();
    IProtocol *proto = qobject_cast<IProtocol*> (protoObj);
    if (!proto)
    {
        qWarning () << Q_FUNC_INFO
                    << "parent protocol for"
                    << acc->GetAccountID ()
                    << "doesn't implement IProtocol";
        return;
    }
    proto->RemoveAccount (acc->GetObject ());
}
예제 #9
0
nsresult
SerializeUntyped(BlobImpl* aBlobImpl, IProtocol* aActor, IPCBlob& aIPCBlob)
{
  // We always want to act on the toplevel protocol.
  IProtocol* manager = aActor;
  while (manager->Manager()) {
    manager = manager->Manager();
  }

  // We always need the toplevel protocol
  switch(manager->GetProtocolTypeId()) {
  case PBackgroundMsgStart:
    if (manager->GetSide() == mozilla::ipc::ParentSide) {
      return SerializeInternal(aBlobImpl,
                               static_cast<PBackgroundParent*>(manager),
                               aIPCBlob);
    } else {
      return SerializeInternal(aBlobImpl,
                               static_cast<PBackgroundChild*>(manager),
                               aIPCBlob);
    }
  case PContentMsgStart:
    if (manager->GetSide() == mozilla::ipc::ParentSide) {
      return SerializeInternal(aBlobImpl,
                               static_cast<ContentParent*>(manager),
                               aIPCBlob);
    } else {
      return SerializeInternal(aBlobImpl,
                               static_cast<ContentChild*>(manager),
                               aIPCBlob);
    }
  default:
    MOZ_CRASH("Unsupported protocol passed to BlobImpl serialize");
  }
}
예제 #10
0
void AdminServer::processLoadHandler(IProtocol & protocol) {
  m_app.loadHandler(protocol.readString());
}
예제 #11
0
	//	virtual unsigned		HandleEvent( unsigned eventType )	= 0;
		DWORD					HandleEvent( DWORD eventType ) {
			if( m_pProtocol )
				return m_pProtocol->HandleEvent( eventType );
			return 0;
		}