Beispiel #1
0
int GoogleAppsMailbox::loginRequest()
{
    //const QRegExp moorhuntHashRegex("(<<a[a-h].*>>)");


    page = doGet("https://www.google.com/a/"+getMailbox());
    int pos = 0;
    QRegExp re3("GALX\\\".*value=\\\"(.*)\\\"./>");
    re3.setMinimal(true);
    if (re3.indexIn(page, pos) == -1)
        return 1;

    //LOG(Log::Info, page);
    const QString vars = QString("ltmpl=default&ltmplcache=2&continue=")
                + escape("https://mail.google.com/a/"+getMailbox()+"/")
                +"&service=mail&GALX="
                + escape(re3.cap(1))
                +"&rm=false&hl=pl&Email="+escape(getUser())
                +"&Passwd="+escape(getPassword())
                +"&rmShown=1";
    page = doPost("https://www.google.com/a/"+getMailbox()+"/LoginAction2?service=mail",vars, true);

    QString username = getUser();

    QRegExp re(username);
    QRegExp re2("&amp;");
    QRegExp authre("auth=([\\w\\d-]+)"); // To Do

    if (re.indexIn(page, pos) != -1)
    {
        QString url = re.cap(1);

        LOG(Log::Info, page + " <f");
        if(url.indexOf("answer=40695") != -1)
        {
            LOG(Log::Info, "Niestety, konto zostało wyłączone. - " + getMailbox());
            return 1;
        }
        url.replace(re2, "&");
        url = unescape(url);
        if (authre.indexIn(page, pos) != -1)
            auth = authre.cap(1);
            LOG(Log::Info, auth + " <s");
        return 0;
    }
    else
        return 1;
}
Beispiel #2
0
static void parseClass(const QString& name, const QString& in)
      {
      Class cl;
      cl.name = name;

      QStringList sl = in.split("\n");
      QStringList methodDescription;

      QRegExp re("@P ([^\\s]+)\\s+([^\\s]+)(.*)");

      // matches Q_INVOKABLE void mops(int a);   // comment
      QRegExp re1("Q_INVOKABLE +([^ ]+) +([^;]+); */*(.*)");
      QRegExp re2("Q_INVOKABLE +([^ ]+) +([^\\{]+)\\{");
      QRegExp re3("Q_INVOKABLE +([^ ]+) +(\\w+\\([^\\)]*\\))\\s+const\\s*([^\\{]*)\\{");

      QRegExp reD("//@ (.*)");
      QRegExp re4 ("class +(\\w+) *: *public +(\\w+) *\\{");
      QRegExp re4b("class +(\\w+) *: *public +(\\w+), *public");

      Q_ASSERT(re1.isValid() && re2.isValid() && re3.isValid());

      bool parseClassDescription = true;

      foreach(const QString& s, sl) {
            if (re.indexIn(s, 0) != -1) {             //@P
                  parseClassDescription = false;
                  Prop p;
                  p.name        = re.cap(1);
                  p.type        = re.cap(2);
                  p.description = re.cap(3);
                  cl.props.append(p);
                  }
            else if (re2.indexIn(s, 0) != -1) {
                  parseClassDescription = false;
                  Proc p;
                  p.type        = re2.cap(1);
                  p.name        = re2.cap(2);
                  p.description = methodDescription;
                  methodDescription.clear();
                  cl.procs.append(p);
                  }
            else if (re1.indexIn(s, 0) != -1) {
                  parseClassDescription = false;
                  Proc p;
                  p.type        = re1.cap(1);
                  p.name        = re1.cap(2);
                  p.description = methodDescription;
                  methodDescription.clear();
                  cl.procs.append(p);
                  }
            else if (re3.indexIn(s, 0) != -1) {
                  parseClassDescription = false;
                  Proc p;
                  p.type        = re3.cap(1);
                  p.name        = re3.cap(2);
                  p.description = methodDescription;
                  methodDescription.clear();
                  cl.procs.append(p);
                  }
            else if ((reD.indexIn(s, 0) != -1)) {
                  if (parseClassDescription)
                        cl.description.append(reD.cap(1));
                  else
                        methodDescription.append(reD.cap(1));
                  }
            else if (s.startsWith("///")) {
                  QString ss = s.mid(3);
                  if (parseClassDescription)
                        cl.description.append(ss);
                  else
                        methodDescription.append(ss);
                  }
            else if (re4.indexIn(s, 0) != -1) {
                  parseClassDescription = false;
                  QString parent = re4.cap(2).simplified();
                  if (name == re4.cap(1).simplified()) {
                        cl.parent = parent;
                        }
                  else {
                        printf("?<%s>!=<%s> derived from <%s>\n",
                           qPrintable(name), qPrintable(re4.cap(1).simplified()), qPrintable(parent));
                        }
                  }
            else if (re4b.indexIn(s, 0) != -1) {
                  parseClassDescription = false;
                  QString parent = re4b.cap(2).simplified();
                  if (name == re4b.cap(1).simplified()) {
                        cl.parent = parent;
                        }
                  else {
                        printf("?<%s>!=<%s> derived from <%s>\n",
                           qPrintable(name), qPrintable(re4b.cap(1).simplified()), qPrintable(parent));
                        }
                  }
            }
      classes.append(cl);
      }
Beispiel #3
0
Settings::Settings()
{
  static_assert(TEAM_BLUE == blue && TEAM_RED == red && TEAM_YELLOW == yellow && TEAM_BLACK == black
                && TEAM_WHITE == white && TEAM_GREEN == green && TEAM_ORANGE == orange
                && TEAM_PURPLE == purple && TEAM_BROWN == brown && TEAM_GRAY == gray,
                "These macros and enums have to match!");
  if(!loaded)
  {
    VERIFY(settings.load());
    loaded = true;
  }
  *this = settings;

#ifdef TARGET_SIM
  if(SystemCall::getMode() == SystemCall::simulatedRobot)
  {
    int index = atoi(RoboCupCtrl::controller->getRobotName().c_str() + 5) - 1;
    teamNumber = index < 6 ? 1 : 2;
    teamPort = 10000 + teamNumber;
    teamColor = index < 6
                ? TeamColor(RoboCupCtrl::controller->gameController.teamInfos[0].teamColor)
                : TeamColor(RoboCupCtrl::controller->gameController.teamInfos[1].teamColor);
    playerNumber = index % 6 + 1;
  }

  headName = bodyName = "Nao";

  ConsoleRoboCupCtrl* ctrl = dynamic_cast<ConsoleRoboCupCtrl*>(RoboCupCtrl::controller);
  if(ctrl)
  {
    std::string logFileName = ctrl->getLogFile();
    if(logFileName != "")
    {
      QRegExp re1("([A-Za-z]*)_([A-Za-z]*)__", Qt::CaseSensitive, QRegExp::RegExp2);
      QRegExp re2("([A-Za-z]*)_([A-Za-z]*)_([A-Za-z0-9]*)_([A-Za-z0-9]*)__");
      QRegExp re3("_([0-9][0-9]*)(_\\([0-9][0-9]*\\)){0,1}\\.");

      int pos1 = re1.indexIn(logFileName.c_str());
      int pos2 = re2.indexIn(logFileName.c_str());
      int pos3 = re3.indexIn(logFileName.c_str());

      if(pos2 != -1)
      {
        headName = re2.capturedTexts()[1].toUtf8().constData();
        bodyName = re2.capturedTexts()[2].toUtf8().constData();
        scenario = re2.capturedTexts()[3].toUtf8().constData();
        location = re2.capturedTexts()[4].toUtf8().constData();
      }
      else if(pos1 != -1)
      {
        headName = re1.capturedTexts()[1].toUtf8().constData();
        bodyName = re1.capturedTexts()[2].toUtf8().constData();
      }
      else
        bodyName = headName = "Default";

      if(pos3 != -1)
        playerNumber = re3.capturedTexts()[1].toUtf8().constData()[0] - '0';
    }
  }
#endif
}