Exemplo n.º 1
0
void AllowedGroupConnectorsMessageArg::append(MessageBuilder &builder) const
{
  static GroupConnector::Type types[] = {
    GroupConnector::andGC, GroupConnector::orGC, GroupConnector::seqGC,
    GroupConnector::grpcGC, GroupConnector::dtgcGC
    };
  static Syntax::DelimGeneral delims[] = {
    Syntax::dAND, Syntax::dOR, Syntax::dSEQ,
    Syntax::dGRPC, Syntax::dDTGC
    };
  Boolean first = 1;
  for (size_t i = 0; i < SIZEOF(types); i++)
    if (allow_.groupConnector(types[i])) {
      if (!first)
	builder.appendFragment(ParserMessages::listSep);
      else
	first = 0;
      const StringC &delim = syntax_->delimGeneral(delims[i]);
      builder.appendFragment(ParserMessages::delimStart);
      builder.appendChars(delim.data(), delim.size());
#if 0
      builder.appendFragment(ParserMessages::delimEnd);
#endif
    }
}
Exemplo n.º 2
0
void SpectatorCommands::setBrowserPosition(int position)
{
    MessageBuilder builder;
    builder.messageType    = FRAGTV::BrowserMessage;
    builder.writeAttributes(FRAGTV::Browser::VideoPosition, position);

    QByteArray message     = builder.generate();    
    currentBrowserPosition = message;

    emit this->relayBrowserPosition(message);
}
Exemplo n.º 3
0
void SpectatorCommands::setMotd(QString html)
{
    MessageBuilder builder;
    builder.messageType   = FRAGTV::MotdMessage;
    builder.writeAttributes(FRAGTV::Motd::Html, html);

    QByteArray message    = builder.generate();
    currentMotdMessage = message;

    qDebug() << "set MOTD: " << html;

    emit this->relayMotdMessage(message);
}
Exemplo n.º 4
0
void SpectatorCommands::setBrowserChatUrl(QString url)
{
    MessageBuilder builder;
    builder.messageType   = FRAGTV::BrowserMessage;
    builder.writeAttributes(FRAGTV::Browser::ChatUrl, url);

    QByteArray message    = builder.generate();
    currentBrowserChatUrl = message;


    qDebug() << "Chat URL: " << url;

    emit this->relayBrowserChatUrl(message);
}
Exemplo n.º 5
0
Arquivo: Group.C Projeto: juddy/edcde
void AllowedGroupTokensMessageArg::append(MessageBuilder &builder) const
{
  const MessageFragment *fragment[4];
  int nFragments = 0;
  if (allow_.groupToken(GroupToken::dataTagLiteral))
    fragment[nFragments++] = &ParserMessages::parameterLiteral;
  if (allow_.groupToken(GroupToken::dataTagGroup))
    fragment[nFragments++] = &ParserMessages::dataTagGroup;
  switch (allow_.group()) {
  case GroupToken::modelGroup:
    fragment[nFragments++] = &ParserMessages::modelGroup;
    break;
  case GroupToken::dataTagTemplateGroup:
    fragment[nFragments++] = &ParserMessages::dataTagTemplateGroup;
    break;
  default:
    break;
  }
  switch (allow_.nameStart()) {
  case GroupToken::name:
    fragment[nFragments++] = &ParserMessages::name;
    break;
  case GroupToken::nameToken:
    fragment[nFragments++] = &ParserMessages::nameToken;
    break;
  case GroupToken::elementToken:
    fragment[nFragments++] = &ParserMessages::elementToken;
    break;
  default:
    break;
  }
  Boolean first = 1;
  for (int i = 0; i < nFragments; i++) {
    if (!first)
      builder.appendFragment(ParserMessages::listSep);
    else
      first = 0;
    builder.appendFragment(*fragment[i]);
  }
  if (allow_.groupToken(GroupToken::pcdata)) {
    if (!first)
      builder.appendFragment(ParserMessages::listSep);
    StringC pcdata(syntax_->delimGeneral(Syntax::dRNI));
    pcdata += syntax_->reservedName(Syntax::rPCDATA);
    builder.appendChars(pcdata.data(), pcdata.size());
  }
}
Exemplo n.º 6
0
int main()
{
  std::cout << "Builder GoF Kata" << std::endl;

  MessageBuilder messageBuilder;
  std::vector<std::string> result;
  MessageAssembler* messageAssembler = NULL;

  messageAssembler = new XmlMessageAssembler();
  result = messageBuilder.buildMessage(messageAssembler);
  std::copy(result.begin(), result.end(), std::ostream_iterator<std::string>(std::cout, "\n")); // love it or hate!
  delete messageAssembler; messageAssembler = NULL;

  std::cout << std::endl;

  messageAssembler = new TxtMessageAssembler();
  result = messageBuilder.buildMessage(messageAssembler);
  std::copy(result.begin(), result.end(), std::ostream_iterator<std::string>(std::cout, "\n")); // love it or hate!
  delete messageAssembler; messageAssembler = NULL;
} 
void ApplicationUI::SendSMSMessage(QString ToStr, QString BodyStr) {

	MessageService messageService;
	AccountService accountService;

	//Get the SMS/MMS account
	QList<Account> accountList = accountService.accounts(Service::Messages,
			"sms-mms");
	AccountKey accountId = accountList.first().id();

	//Create a conversation  because sms/mms chats most of the time is a conversation
	ConversationBuilder* conversationBuilder = ConversationBuilder::create();
	conversationBuilder->accountId(accountId);

	// Create a contact to whom you want to send sms/mms.
	int contactKey = -1;
	MessageContact recipient = MessageContact(contactKey, MessageContact::To,
			ToStr, ToStr);
	QList<MessageContact> participants;
	participants.append(recipient);

	//Add the contact to the conversation
	conversationBuilder->participants(participants);
	Conversation conversation = *conversationBuilder;
	ConversationKey conversationId = messageService.save(accountId,
			conversation);

	//Create a message Builder for sms/mms
	MessageBuilder* messageBuilder = MessageBuilder::create(accountId);
	messageBuilder->conversationId(conversationId);
	messageBuilder->addRecipient(recipient);
	messageBuilder->addAttachment(
			Attachment("text/plain", "body.txt", BodyStr));
	Message message;
	message = *messageBuilder;

	//Sending SMS/MMS
	messageService.send(accountId, message);
	ShowToast("SMS sent successfully");
}
Exemplo n.º 8
0
bool URI::append_as_record(MessageBuilder &message_builder, bool is_last_record) const
{
    if (!_uri) {
        return false;
    }

    // Build the record type
    RecordType type(
        RecordType::well_known_type,
        uri_record_type_value
    );

    // build the record payload
    RecordPayload payload(_uri, _uri_size);

    return message_builder.append_record(type, payload, is_last_record);
}
Exemplo n.º 9
0
void MainScreen::doSend()
{
	QList<int> order = randomizeBuyers();
	//QList<Participant> receivers(m_participants.size());

	typedef QPair<Participant, Participant> ParticipantPair;
	QList<ParticipantPair> pairs;

	bool success = false;
	while(!success)
	{
	  bool errorOccurred = false;
	  for(int i = 0; !errorOccurred && i < m_participants.size(); ++i)
	  {
	          // refactor the drafting out into it's own class.  The Input reader
	          // should not know about how drafting occurs
		  	  int j = order[i];

	          Participant buyer(m_participants.value(j)["name"].value<QString>(), m_participants.value(j)["email"].value<QString>(), m_participants.value(j)["exl"].value<QStringList>());
	          Participant receiver(m_participants.value(i)["name"].value<QString>(), m_participants.value(i)["email"].value<QString>(), m_participants.value(i)["exl"].value<QStringList>());
	          if(!IsValidPair(buyer, receiver))
	          {
	            errorOccurred = true;
	          }
	          else
	          {
	        	  pairs.append(ParticipantPair(buyer,receiver));
	          }
	  }

	  if(errorOccurred)
	  {

		  order = randomizeBuyers();
			pairs.clear();
	  }
	  else
	  {
		success = true;
	  }
	}

	AccountService* as = new AccountService();
	Account account = as->defaultAccount(Service::Messages);

	MessageService ms;
	m_subject = m_mainPage->findChild<TextField*>("emailSubject")->text();
	QString body = "<p>" + m_mainPage->findChild<TextArea*>("emailBody")->text() + "</p>";

	for(int i = 0; i < pairs.size(); ++i)
	{
	  QString greeting = "<p>Hi " + pairs[i].first.getName() + "!</p>";
	  QString youGot = "You Received: " + pairs[i].second.getName();
		MessageBuilder* builder = MessageBuilder::create(account.id());
		MessageContact rto = MessageContact(-1,MessageContact::To,pairs[i].first.getName(), pairs[i].first.getEmail());
		QString fullMsg = greeting + body + youGot;
		QByteArray bodyData = fullMsg.toAscii();
		builder->subject(m_subject);
		bool added;
		builder->addRecipient(rto,&added);
		builder->body(MessageBody::Html,bodyData);
		Message message = *builder;

/*
	    connect(&m_messageService, SIGNAL( messageUpdated(bb::pim::account::AccountKey, bb::pim::message::ConversationKey, bb::pim::message::MessageKey, bb::pim::message::MessageUpdate) ),
	            &m_ml,
	            SLOT( messageUpdate(bb::pim::account::AccountKey, bb::pim::message::ConversationKey, bb::pim::message::MessageKey, bb::pim::message::MessageUpdate) ) );
*/


		/*MessageKey mk = */ms.send(account.id(), message);
		/*Message sentMessage = ms.message(account.id(), mk);
		m_ml.setAk(account.id());
		m_ml.setMk(sentMessage.id());
		m_ml.setCk(sentMessage.conversationId());
		m_ml.setMsg(sentMessage);*/
		//********************************************************
	    // Set created root object as the application scene
	    //m_navPane->setBackButtonsVisible(false);
	}

	m_worker->exit();

}
Exemplo n.º 10
0
void OtherMessageArg::append(MessageBuilder &builder) const
{
  builder.appendOther(this);
}
Exemplo n.º 11
0
void OrdinalMessageArg::append(MessageBuilder &builder) const
{
  builder.appendOrdinal(n_);
}
Exemplo n.º 12
0
void NumberMessageArg::append(MessageBuilder &builder) const
{
  builder.appendNumber(n_);
}
Exemplo n.º 13
0
void StringMessageArg::append(MessageBuilder &builder) const
{
  builder.appendChars(s_.data(), s_.size());
}
Exemplo n.º 14
0
void AllowedParamsMessageArg::append(MessageBuilder &builder) const
{
  Syntax::DelimGeneral delims[3];
  int nDelims = 0;
  if (allow_.mdc())
    delims[nDelims++] = Syntax::dMDC;
  if (allow_.dso())
    delims[nDelims++] = Syntax::dDSO;
  switch (allow_.mainMode()) {
  case mdMinusMode:
    delims[nDelims++] = Syntax::dMINUS;
    break;
  case mdPeroMode:
    delims[nDelims++] = Syntax::dPERO;
    break;
  default:
    break;
  }
  Boolean first = 1;
  int i;
  for (i = 0; i < nDelims; i++) {
    if (!first)
      builder.appendFragment(ParserMessages::listSep);
    else
      first = 0;
    const StringC &delim = syntax_->delimGeneral(delims[i]);
    builder.appendFragment(ParserMessages::delimStart);
    builder.appendChars(delim.data(), delim.size());
#if 0
    builder.appendFragment(ParserMessages::delimEnd);
#endif
  }
  const MessageFragment *fragment[5];
  int nFragments = 0;
  if (allow_.inclusions())
    fragment[nFragments++] = &ParserMessages::inclusions;
  if (allow_.exclusions())
    fragment[nFragments++] = &ParserMessages::exclusions;
  switch (allow_.literal()) {
  case Param::minimumLiteral:
    fragment[nFragments++] = &ParserMessages::minimumLiteral;
    break;
  case Param::attributeValueLiteral:
  case Param::tokenizedAttributeValueLiteral:
    fragment[nFragments++] = &ParserMessages::attributeValueLiteral;
    break;
  case Param::systemIdentifier:
    fragment[nFragments++] = &ParserMessages::systemIdentifier;
    break;
  case Param::paramLiteral:
    fragment[nFragments++] = &ParserMessages::parameterLiteral;
    break;
  }
  switch (allow_.nameStart()) {
  case Param::name:
  case Param::entityName:
  case Param::paramEntityName:
    fragment[nFragments++] = &ParserMessages::name;
    break;
  case Param::attributeValue:
    fragment[nFragments++] = &ParserMessages::attributeValue;
    break;
  }
  if (allow_.digit() == Param::number)
    fragment[nFragments++] = &ParserMessages::number;
  
  for (i = 0; i < nFragments; i++) {
    if (!first)
      builder.appendFragment(ParserMessages::listSep);
    else
      first = 0;
    builder.appendFragment(*fragment[i]);
  }
  if (allow_.rni() || allow_.nameStart() == Param::reservedName) {
    for (int i = 0; i < Syntax::nNames; i++) {
      if (allow_.reservedName(Syntax::ReservedName(i))) {
	if (!first)
	  builder.appendFragment(ParserMessages::listSep);
	else
	  first = 0;
	StringC str;
	if (allow_.rni())
	  str = syntax_->delimGeneral(Syntax::dRNI);
	str += syntax_->reservedName(Syntax::ReservedName(i));
	builder.appendChars(str.data(), str.size());
      }
    }
  }
}