void toResultStorage::poll(void)
{
    try
    {
        if (!toCheckModal(this))
            return ;
        if (Tablespaces && Tablespaces->poll())
        {
            int cols = Tablespaces->describe().size();
            while (Tablespaces->poll() && !Tablespaces->eof())
            {
                for (int i = 0;i < cols && !Tablespaces->eof();i++)
                    toPush(TablespaceValues, QString(Tablespaces->readValue()));
            }
            updateList();
            if (Tablespaces->eof())
            {
                delete Tablespaces;
                Tablespaces = NULL;
            }
        }

        if (Files && Files->poll())
        {
            int cols = Files->describe().size();
            while (Files->poll() && !Files->eof())
            {
                for (int i = 0;i < cols && !Files->eof();i++)
                    toPush(FileValues, QString(Files->readValue()));
            }
            if (Files->eof())
            {
                delete Files;
                Files = NULL;
            }
        }

        if (Tablespaces == NULL && Files == NULL)
        {
            updateList();
            Poll.stop();
        }
    }
    catch (const QString &exc)
    {
        delete Tablespaces;
        Tablespaces = NULL;
        delete Files;
        Files = NULL;
        Poll.stop();
        toStatusMessage(exc);
    }
}
Esempio n. 2
0
std::list<QString> toMain::connections ( void )
{
    std::list<QString> ret;
    for ( std::list<toConnection *>::iterator i = Connections.begin();i != Connections.end();i++ )
        toPush ( ret, ( *i ) ->description() );
    return ret;
}
std::list<toStorageExtent::extentTotal> toStorageExtent::objects(void)
{
    std::list<extentTotal> ret;

    for (std::list<extent>::iterator i = Extents.begin();i != Extents.end();i++)
    {
        bool dup = false;
        for (std::list<extentTotal>::iterator j = ret.begin();j != ret.end();j++)
        {
            if ((*j) == (*i))
            {
                (*j).Size += (*i).Size;
                (*j).Extents++;
                (*j).LastBlock = ( ((*j).LastBlock > (*i).Block) ? (*j).LastBlock : (*i).Block );
                dup = true;
                break;
            }
        }
        if (!dup)
            toPush(ret, extentTotal((*i).Owner, (*i).Table, (*i).Partition, (*i).Block, (*i).Size));
    }

    ret.sort();

    return ret;
}
void toResultStorage::query(void)
{
    if (!handled() || Tablespaces || Files)
        return ;

    try
    {
        saveSelected();
        clear();

        toConnection &conn = connection();

        toQList args;
        toPush(args, toQValue(toSizeDecode(Unit)));

        TablespaceValues.clear();
        FileValues.clear();

        Tablespaces = new toNoBlockQuery(conn, toQuery::Background,
                                         toSQL::string(ShowCoalesced ? SQLShowCoalesced : SQLNoShowCoalesced, connection()), args);
        Files = NULL;
        Files = new toNoBlockQuery(conn, toQuery::Background,
                                   toSQL::string(SQLDatafile, connection()), args);

        Poll.start(100);
    }
    TOCATCH
}
void toStorageExtent::setTablespace(const QString &tablespace)
{
    fileView = false;
    try
    {
        if (Tablespace == tablespace)
            return ;
        Tablespace = tablespace;
        toBusy busy;
        Extents.clear();
        FileOffset.clear();
        toQuery query(toCurrentConnection(this), SQLObjectsTablespace, tablespace);

        // It's used to keep UI "non-freezed".
        // OK, there are better query classes for it but it's enough for now.
        // TODO: rewrite data fetching for this tool
        int progressMax = 1000;
        int progressCurr = 1;
        QProgressDialog progress("Reading Objects...", "Abort", 0, progressMax, this);

        extent cur;
        while (!query.eof())
        {
            if (progressCurr > (progressMax-1))
                progressCurr = 0;
            if (progressCurr % 200 == 0)
            {
                progress.setValue(progressCurr);
                QCoreApplication::processEvents();
            }
            if (progress.wasCanceled())
            {
                Extents.clear();
                break;
            }
            ++progressCurr;

            cur.Owner = query.readValueNull();
            cur.Table = query.readValueNull();
            cur.Partition = query.readValueNull();
            cur.File = query.readValueNull().toInt();
            cur.Block = query.readValueNull().toInt();
            cur.Size = query.readValueNull().toInt();
            toPush(Extents, cur);
        }
        toQuery blocks(toCurrentConnection(this), SQLTablespaceBlocks, tablespace);
        Total = 0;
        while (!blocks.eof())
        {
            int id = blocks.readValueNull().toInt();
            FileOffset[id] = Total;
            Total += blocks.readValueNull().toInt();
        }
    }
    TOCATCH
    Extents.sort();
    update();
}
void toProfiler::changeObject(void)
{
    toTreeWidgetItem *qi = Units->selectedItem();
    toResultViewItem *item = qi ? dynamic_cast<toResultViewItem *>(qi) : NULL;
    if (item)
    {
        toQList par;
        toPush(par, toQValue(item->allText(0)));
        toPush(par, toQValue(item->allText(1)));
        toPush(par, toQValue(item->allText(4)));
        toPush(par, toQValue(item->allText(5)));
        toPush(par, toQValue(item->allText(6)));
        Lines->clearTotals();
        try
        {
            Lines->query(toSQL::string(SQLListSource, connection()), par);
        }
        TOCATCH
    }
}
void toStorageExtent::setFile(const QString &tablespace, int file)
{
    fileView = true;
    try
    {
        toBusy busy;
        Extents.clear();
        FileOffset.clear();
        toQuery query(toCurrentConnection(this), SQLObjectsFile, tablespace, QString::number(file));
        extent cur;

        int progressMax = 1000;
        int progressCurr = 1;
        QProgressDialog progress("Reading Objects...", "Abort", 0, progressMax, this);

        while (!query.eof())
        {
            if (progressCurr > (progressMax-1))
                progressCurr = 0;
            if (progressCurr % 200 == 0)
            {
                progress.setValue(progressCurr);
                QCoreApplication::processEvents();
            }
            if (progress.wasCanceled())
            {
                Extents.clear();
                break;
            }
            ++progressCurr;

            cur.Owner = query.readValueNull();
            cur.Table = query.readValueNull();
            cur.Partition = query.readValueNull();
            cur.File = query.readValueNull().toInt();
            cur.Block = query.readValueNull().toInt();
            cur.Size = query.readValueNull().toInt();
            toPush(Extents, cur);
        }
        toQuery blocks(toCurrentConnection(this), SQLFileBlocks, tablespace, QString::number(file));
        Total = 0;
        while (!blocks.eof())
        {
            int id = blocks.readValueNull().toInt();
            FileOffset[id] = Total;
            Total += blocks.readValueNull().toInt();
        }
    }
    TOCATCH
    Extents.sort();
    update();
}
Esempio n. 8
0
void FSClient::ReceiveFileMsg(istring &message, s32 id)
{
  c08* data = new c08[message.size()];
  memcpy(data, message.c_str(), message.size());
  
  Encoder e(true, (u08*)data, message.size());
  u32 seq;
  e.Read(seq);
  delete[] data;

  if(seq == 0)
  {
    seq = UINT_MAX;
    //don't disconnect right away, might be waiting for dropped packets
    //add con ID on to message so save func can disconnect
    message += std::to_string(id);
  }

  Networking::Message toPush(message);
  toPush.SetSequence(seq);
  LOG("Recieved file transfer packet " << seq);
  messagesReceived_.push(toPush);
  return;
}
Esempio n. 9
0
void toMain::displayMessage ( const QString &str )
{
    toPush ( StatusMessages, str );
    QTimer::singleShot ( 1, this, SLOT ( displayMessage() ) );
}
Esempio n. 10
0
void MainWindow::checkForSaveFile()
{
    QFile file2("autosave.dat");
    QString fileInput = "autosave.dat";

    if (!file2.exists() && !QFile(QString(".autosave.dat")).exists())
        QString fileInput = QFileDialog::getSaveFileName(this, tr("Autosave File"), "", tr("Data File (*.dat)"));

    else if (!file2.exists() && QFile(QString(".autosave.dat")).exists())
        QFile(QString(".autosave.dat")).copy(fileInput);

    QList<QString> asList;

    if (fileInput != "")
    {
        /**
          Load the last save into memory.

          Allows us to extract the serials/class members.
          **/

        QFile file(fileInput);
        if (!file.open(QIODevice::ReadOnly))
        {
            QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
            return;
        }//end if
        QTextStream in(&file);


        while (!in.atEnd())
        {
            asList.push_back(in.readLine());
        }//iterate through the file. All of it. Store.
    }//end if.

    for (int x = 0; x < asList.size(); x++)
    {
        /**
          Now, we segment the file.
          **/
        QString current = asList.at(x);
        QString flipped = reverse(current);
        QList<QString> currentKid;

        int y = x;

        while (asList.at(y) != flipped)
        {
            y++;
        }

        for (int z = x; z < y; z++)
        {
            currentKid.push_back(asList.at(z));
            x++;
        }//end for z.

        if (true)
        {
            QString last = currentKid.at(0);
            QString email = currentKid.at(1);
            int index = email.indexOf(":") + 1;
            email.remove(0, index);
            QString period = currentKid.at(2);
            index = period.indexOf(":") + 1;
            period.remove(0, index);
            QString balance = currentKid.at(3);

            KedighKid toPush(last, period, email);


            for (int i = 4; i < currentKid.size(); i++)
            {
                QString line = currentKid.at(i);
                QString tabLength = "\t\t";
                line.remove(0, tabLength.length());
                int index = line.indexOf(":");
                QString serial = line;
                serial.remove(index, line.size());
                QString denom = line;
                denom.remove(0, serial.size());
                QString toSize = " $";
                denom.remove(0, 3);
                int _denomination = denom.toInt();

                KedighCash money(serial, "Today", _denomination);
                toPush.addMoney(money);
            }
            kids.push_back(toPush);
            x++;
        }
    }

    qSort(kids.begin(), kids.end());
    for (int i = 0; i < kids.size(); i++)
    {
        ui->studentSelect->addItem(kids.at(i).name);
    }

    for (int y = 0; y < kids.size(); y++)
    {
        ui->fileDisplay->addItem(kids.at(y).name);
    }

    countCash();
    displayInfo();
}//open last save.
Esempio n. 11
0
void MainWindow::parseFile(QString fileInput)
{
    if (fileInput != "")
    {
        QFile file(fileInput);
        if (!file.open(QIODevice::ReadOnly))
        {
            QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
            return;
        }//end if
        QTextStream in(&file);
        QList<QString> asList;
        QList<QString> dataList;
        QString email, date;

        while (!in.atEnd())
        {
            asList.push_back(in.readLine());
        }//iterate through the file. All of it. Store.

        ui->fileDisplay->clear();

        for (int x = 0; x < asList.size(); x++)
        {
            if (asList.at(x) == "" && x > 0)
            { asList.removeAt(x); x--; }
            //remove the blank lines
        }//end for x

        for (int z = 0; z < asList.size(); z++)
        {
            /** Order of the file here,
              lastname:
              period:
              version:
              denomination:
              serial:
              Submit: Submit
              HTTP_USER_AGENT:
              WOW64;
              REMOTE_ADDR:
              From: lastname [email]
              Sent: date **/



            if (asList.at(z).contains("From"))
            {
                int index1, index2;
                QString current;
                current = asList.at(z);
                if (current.contains("["))
                {
                    index1 = current.indexOf("[");
                    current.remove(0, index1 + 1);
                    index2 = current.indexOf("]");
                    current.remove(index2, current.size() - 1);
                }//end if

                else
                {
                    index1 = current.indexOf("<");
                    current.remove(0, index1 + 1);
                    index2 = current.indexOf(">");
                    current.remove(index2, current.size() - 1);
                }

                email = current;
                z++;

                current = asList.at(z);

                index1 = current.indexOf(",");
                current.remove(0, index1 + 1);
                index2 = current.indexOf(":");
                current.remove(index2 - 2, current.size() - 1);
                date = current;
                z++;
            }

            else if (asList.at(z).contains("lastname: "))
            {
                QString lastname, period, version, denom,
                        serial, remote;
                //we have a section to extract from.
                QString toSize;
                QString current;
                current = asList.at(z);
                int theSize = 0;
                toSize = "lastname: ";
                theSize = toSize.size();
                current.remove(0, theSize);
                lastname = current;
                z++; //we can go to the next line now

                if (asList.at(z).contains("period: "))
                {
                    toSize = "period: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    period = current;
                    z++;
                }//make sure it exists!
                else
                    period = "invalid";

                if (asList.at(z).contains("version"))
                {
                    current = asList.at(z);
                    toSize = "version: ";
                    current.remove(0, toSize.size() - 1);
                    version = current;
                    z++;
                }

                if (asList.at(z).contains("denomination"))
                {
                    toSize = "denomination: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    denom = current;
                    z++;
                }

                if (asList.at(z).contains("serial"))
                {
                    toSize = "serial: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    serial = current;
                    z += 3; //go to remote line
                }

                if (asList.at(z).contains("REMOTE_ADDR"))
                {
                    toSize = "REMOTE_ADDR: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    remote = current;
                }

                //get email

                bool exists = false;
                int index = -1;

                for (int k = 0; k < kids.size(); k++)
                {
                    if (QString::compare(kids.at(k).name, lastname, Qt::CaseInsensitive) == 0)
                    { exists = true; index = k; break; }
                }

                KedighKid toPush(lastname, period, email);

                if (!exists)
                {
                    kids.push_back(toPush);

                    KedighCash dolla(serial, date, lastname, remote, toInt(denom));
                    kids.last().addMoney(dolla);
                }//end if.

                else
                {
                    KedighCash dolla(serial, date, lastname, remote, toInt(denom));
                    kids.last().addMoney(dolla);
                }//end else
            }

            else if (asList.at(z).contains("denomination"))
            {
                QString lastname, period, version, denom,
                        serial, remote;
                //we have a section to extract from.
                QString toSize; 
                QString current;
                current = asList.at(z);
                int theSize = 0;
                toSize = "denomination: ";
                current = asList.at(z); 
                current.remove(0, toSize.size() - 1);
                denom = current;
                z++; 


                if (asList.at(z).contains("serial"))
                {
                    toSize = "serial: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    serial = current;
                    z ++; //go to remote line
                }

                if (asList.at(z).contains("period"))
                {
                    toSize = "period: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    period = current;
                    z++;
                }//make sure it exists!
                else
                    period = "invalid";


                if (asList.at(z).contains("lastname"))
                {
                    current = asList.at(z);
                    toSize = "lastname: ";
                    theSize = toSize.size();
                    current.remove(0, theSize);
                    lastname = current;
                    z += 3; //we can go to the next line now
                }

                if (asList.at(z).contains("REMOTE_ADDR"))
                {
                    toSize = "REMOTE_ADDR: ";
                    current = asList.at(z);
                    current.remove(0, toSize.size() - 1);
                    remote = current;
                }

                //get email

                bool exists = false;
                int index = -1;

                for (int k = 0; k < kids.size(); k++)
                {
                    if (QString::compare(kids.at(k).name, lastname, Qt::CaseInsensitive) == 0)
                    { exists = true; index = k; break; }
                }

                KedighKid toPush(lastname, period, email);

                if (!exists)
                {
                    kids.push_back(toPush);

                    KedighCash dolla(serial, date, lastname, remote, toInt(denom));
                    kids.last().addMoney(dolla);
                }//end if.

                else
                {
                    KedighCash dolla(serial, date, lastname, remote, toInt(denom));
                    kids.last().addMoney(dolla);
                }//end else
            }//end else if.
        }

        qSort(kids.begin(), kids.end());
        for (int i = 0; i < kids.size(); i++)
        {
            ui->studentSelect->addItem(kids.at(i).name);
        }

        for (int y = 0; y < kids.size(); y++)
        {
            ui->fileDisplay->addItem(kids.at(y).name);
        }

        file.close();
    }//end if

    countCash();
}
Esempio n. 12
0
void MainWindow::addCashFromWindow()
{
    if (!m_loggedIn)
        return;

    QString serial = addCashWindow->serial;
    QString date = "November 12, 2012";
    int denom = addCashWindow->denom.toInt();
    int index = -1;

    for (int x = 0; x < kids.size(); x++)
    {
        KedighKid current = kids.at(x);

        if (current.name == addCashWindow->name)
        {
            index = x;
            break;
        }
    }

    if (index == -1)
    {
        KedighKid toPush(addCashWindow->name, addCashWindow->period, addCashWindow->email);
        KedighCash test(serial, date, denom);
        toPush.addMoney(test);
        if (toPush.name != "")
            kids.push_back(toPush);
    }//end if

    else
    {
        KedighCash test(serial, date, denom);
        KedighKid current = kids.at(index);
        current.addMoney(test);
        kids.replace(index, current);
    }

    ui->studentSelect->clear();
    ui->fileDisplay->clear();

    qSort(kids.begin(), kids.end());
    for (int i = 0; i < kids.size(); i++)
    {
        ui->studentSelect->addItem(kids.at(i).name);
    }

    for (int y = 0; y < kids.size(); y++)
    {
        ui->fileDisplay->addItem(kids.at(y).name);
    }

    displayInfo();
    countCash();

    /** Smtp *newMail  = new Smtp("*****@*****.**","*****@*****.**"," Your Subject","My body text");
        delete newMail; **/

    QStringList receivers;
    receivers.push_back(toAddress);
    //Smtp(server, user, pass, from, to, subject, body);

	QString messageBody; 
	messageBody += "KedighCash Deposit: \n";
	messageBody += "Lastname: " + addCashWindow->name + "\n"; 
	messageBody += "Serial: " + addCashWindow->serial + "\n"; 
    messageBody += "Denomination: $" + addCashWindow->denom;
	
    //Smtp *newMail = new Smtp("smtp.mail.yahoo.com", "*****@*****.**", fromPass, fromAddress, receivers, "Test", messageBody);
 
    MailThread sendMessage(fromAddress, toAddress, fromPass, "New Cash Deposit", messageBody);
    addCashWindow->hide();
    sendMessage.run();
}