Skip to content

Commit

Permalink
Portable support: Packet Sender looks for local settings file before …
Browse files Browse the repository at this point in the history
…loading default.
  • Loading branch information
dannagle committed Apr 19, 2015
1 parent 398e1cc commit bef1a94
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 33 deletions.
10 changes: 6 additions & 4 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

#define TEMPPATH QDir::toNativeSeparators(QDir::temp().absolutePath()) + QDir::separator() + "PacketSender" + QDir::separator()
#define SETTINGSPATH QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation )+ QDir::separator() +"PacketSender" + QDir::separator()
#define SETTINGSFILE SETTINGSPATH + "ps_settings.ini"
#define PACKETSFILE SETTINGSPATH + "packets.ini"
#define TRAFFICFILE SETTINGSPATH + "traffic.ini"
#define LOGFILE SETTINGSPATH + "packetsender.log"

//Load local file if it exists
#define SETTINGSFILE ((QFile::exists("ps_settings.ini")) ? ("ps_settings.ini") : ((SETTINGSPATH) + "ps_settings.ini"))
#define PACKETSFILE ((QFile::exists("packets.ini")) ? ("packets.ini") : ((SETTINGSPATH) + "packets.ini"))
#define TRAFFICFILE ((QFile::exists("traffic.ini")) ? ("traffic.ini") : ((SETTINGSPATH) + "traffic.ini"))


#define NAMEINIKEY "NAMES"

Expand Down
22 changes: 0 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@
#include "mainwindow.h"
#define DEBUGMODE 0

void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
static QFile logfile(LOGFILE);
Q_UNUSED(context);
if(!logfile.isOpen())
{
logfile.open(QFile::Append);
} else {
// logfile.flush();
}
switch (type) {
default:
logfile.write("\n");
logfile.write(msg.toLatin1());
break;
case QtFatalMsg:
logfile.flush();
abort();
}
}



void myMessageOutputDisable(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Expand Down
5 changes: 5 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ MainWindow::MainWindow(QWidget *parent) :


QDEBUG() << "Load time:" << timeSinceLaunch();

QDEBUG() << "Settings file loaded" << SETTINGSFILE;
QDEBUG() << "Packets file loaded" << PACKETSFILE;
QDEBUG() << "Traffic file loaded" << TRAFFICFILE;

}

QPushButton * MainWindow::generatePSLink()
Expand Down
6 changes: 0 additions & 6 deletions src/packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,6 @@ void Packet::saveToDB()
}


Packet Packet::fetchFromDB(QString thename, QList<Packet> allPackets)
{
Packet fromPacket;
return fromPacket;
}

Packet Packet::fetchFromDB(QString thename)
{
QList<Packet> packets = Packet::fetchAllfromDB("");
Expand Down
1 change: 0 additions & 1 deletion src/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class Packet
void saveToDB();


static Packet fetchFromDB(QString thename, QList<Packet> allPackets);
static Packet fetchFromDB(QString thename);
static QList<Packet> fetchAllfromDB(QString importFile);
static bool removeFromDB(QString thename);
Expand Down

0 comments on commit bef1a94

Please sign in to comment.