Exemplo n.º 1
0
int irc_recv_nick(void *data)
{
    struct irc_msgdata *msgdata = (struct irc_msgdata *) data;
    char prefix[MAX_NICK_LEN + 1];
    char *params[1];

    irc_get_prefix(msgdata->msg, prefix, MAX_NICK_LEN + 1);

    if (irc_parse_paramlist(msgdata->msg, params, 1) != 1)
    {
        slog(LOG_ERR, "Mensaje NICK mal formado: %s", msgdata->msg);
        return OK;
    }

    messageText("%s cambió su apodo a %s", prefix, params[0]);

    if (!strncmp(prefix, msgdata->clientdata->nick, MAX_NICK_LEN))
    {
        msgdata->clientdata->connected = 1;
        strncpy(msgdata->clientdata->nick, params[0], MAX_NICK_LEN);
        setApodo(params[0]);
        saveUserSettings(params[0], getNombre(), getNombreReal());
    }


    return OK;
}
Exemplo n.º 2
0
MainWindow::~MainWindow()
{
    saveUserSettings(pModel->getUserSettingsManager()->getGlobalSettings());

    m_Presenters.reset(nullptr);

    delete ui;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  EvalMainWindow *w;
  DataAccumulator *dac;
  SoftwareUpdater *updater;
  int aRet;

  setOpenMPThreads();

  QCoreApplication::setOrganizationName(Globals::ORG_NAME);
  QCoreApplication::setApplicationName(Globals::SOFTWARE_NAME);
  QCoreApplication::setApplicationVersion(Globals::VERSION_STRING());

  EMT::registerAll();

  CrashHandler::install();

  DoubleToStringConvertor::initialize();

  try {
    w = new EvalMainWindow(nullptr);
    dac = new DataAccumulator(w->plot(), nullptr);
    updater = new SoftwareUpdater(nullptr);
  } catch (...) {
    QMessageBox::critical(nullptr, QObject::tr("Initialization"), QObject::tr("Unable to allocate basic data structures"));
    aRet = EXIT_FAILURE;
    goto out;
  }

  HVLCalculator::initialize();

  setupBindings(w, dac);

  w->show();
  dac->announceDefaultState();
  loadUserSettings(dac, updater);

  setDefaultState(w);

  dac->checkForCrashRecovery();

  updater->checkAutomatically();
  w->connectToSoftwareUpdater(updater);

  aRet =  a.exec();

  saveUserSettings(dac, updater);

out:
  CrashHandler::uninstall();

  return aRet;
}
Exemplo n.º 4
0
void connectToServer(const char *server, const char* port)
{
    char *nick = getApodo();
    char *user = getNombre();
    char *name = getNombreReal();
    int sock;
    const char *err;
    char addr_str[100];
    int retval;
    struct serv_info serv;

    if (!server || strlen(server) == 0)
    {
        errorText("Error: servidor inválido.");
        return;
    }

    if (!port || strlen(port) == 0)
    {
        errorText("Error: puerto inválido.");
        return;
    }

    if (!nick || !user || !name || strlen(nick) == 0 || strlen(user) == 0 || strlen(name) == 0)
    {
        errorWindow("Rellene los datos de nombre/usuario/apodo");
        return;
    }   

    if(client->connected)
        disconnectClient(NULL);

    messageText("Conectando con %s...", server);

    retval = client_connect_to(server, port, addr_str, 100);

    if (retval == ERR_SYS)
        err = strerror(errno);
    else if (retval == ERR_AIR)
        err = "no se ha podido resolver la dirección";
    else if (retval == ERR_NOTFOUND)
        err = "no se ha podido conectar.";
    else
        err = "error desconocido.";

    if (retval <= 0)
    {
        errorText("Error resolviendo %s: %s", server, err);
        return;
    }

    sock = retval;

    if (send_message(rcv_sockcomm, &sock, sizeof(int)) == ERR_SOCK)
    {
        errorText("Error al configurar la nueva conexión: %s", strerror(errno));
        close(sock);
        return;
    }

    irc_send_message(snd_qid, sock, "NICK %s", getApodo());
    irc_send_message(snd_qid, sock, "USER %s %s %s :%s", getNombre(), "0", "*", getNombreReal());

    client->connected = 1;
    strncpy(client->nick, nick, MAX_NICK_LEN);
    client->serv_sock = sock;

    setUserConnectionState(TRUE);

    strncpy(serv.servname, server, SERV_NAMELEN);
    strncpy(serv.port, port, MAX_PORT_LEN);
    serv_save_connection(&serv);

    client->connected = 1;
    messageText("Conectado a %s", addr_str);
    saveUserSettings(nick, user, name);
}