+
+void LatitudeGUI::mode_buzz() {
+ maps->load(QUrl::fromEncoded("http://www.google.com/maps/m?l-view=map&l-lci=m,com.google.latitudepublicupdates&ac=f,s,l"));
+}
+
+void LatitudeGUI::mode_latitude() {
+ maps->load(QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude"));
+}
+
+void LatitudeGUI::mode_demonio() {
+ if ( ! system("killall -0 GoogleLatitudeDaemon 2> /dev/null" ) ) {
+ system("killall GoogleLatitudeDaemon 2> /dev/null");
+ demonio->setText(tr("&Start Daemon"));
+ } else {
+ QProcess *cli = new QProcess(this);
+ cli->startDetached(QCoreApplication::applicationDirPath()+QDir::separator()+"GoogleLatitudeDaemon");
+ qDebug() << "LatitudeGUI: demonio" << QCoreApplication::applicationDirPath()+QDir::separator()+"GoogleLatitudeDaemon";
+ if ( ! system("killall -0 GoogleLatitudeDaemon 2> /dev/null" ) ) {
+ demonio->setText(tr("&Stop Daemon"));
+ }
+ }
+}
+
+void LatitudeGUI::config() {
+ gps->forcestop();
+
+ QDialog *dialoglogin = new QDialog(this);
+
+ QLineEdit *login_user = new QLineEdit(setting->value("user","my_username").toString());
+ QLineEdit *login_pass = new QLineEdit(setting->value("pass","my_password").toString());
+ login_pass->setEchoMode(QLineEdit::Password);
+
+ QLineEdit *gps_interval = new QLineEdit(setting->value("interval",1800).toString());
+ QLineEdit *gps_wait = new QLineEdit(setting->value("wait",30).toString());
+
+ QCheckBox *daemon_use = new QCheckBox();
+ if ( setting->value("daemon",false).toBool() ) {
+ daemon_use->setCheckState(Qt::Checked);
+ } else {
+ daemon_use->setCheckState(Qt::Unchecked);
+ }
+
+ QRadioButton *gps_cell = new QRadioButton(tr("&Cell Tower"));
+ QRadioButton *gps_both = new QRadioButton(tr("&Both"));
+ QRadioButton *gps_agps = new QRadioButton(tr("Only &Gps"));
+
+ QString gps_setting = setting->value("method","cell").toString();
+ if ( gps_setting == QString("cell") ) {
+ gps_cell->setChecked(true);
+ } else if ( gps_setting == QString("both") ) {
+ gps_both->setChecked(true);
+ } else if ( gps_setting == QString("agps") ) {
+ gps_agps->setChecked(true);
+ } else {
+ gps_cell->setChecked(true);
+ }
+
+ QFormLayout *layout_form = new QFormLayout();
+
+ layout_form->addRow(tr("&Username"), login_user);
+ layout_form->addRow(tr("&Password"), login_pass);
+ connect(login_user, SIGNAL(textEdited(QString)), this, SLOT(save_user(QString)));
+ connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus()));
+ connect(login_pass, SIGNAL(textEdited(QString)), this, SLOT(save_pass(QString)));
+ connect(login_pass, SIGNAL(returnPressed()), dialoglogin, SLOT(accept()));
+
+ layout_form->addRow(tr("&Interval for Updates"), gps_interval);
+ layout_form->addRow(tr("&Wait for a Fix"), gps_wait);
+ layout_form->addRow(tr("&Daemon at Boot"), daemon_use);
+ connect(gps_interval, SIGNAL(textEdited(QString)), this, SLOT(save_interval(QString)));
+ connect(gps_wait, SIGNAL(textEdited(QString)), this, SLOT(save_wait(QString)));
+ connect(daemon_use, SIGNAL(stateChanged(int)), this, SLOT(save_daemon(int)));
+
+ QHBoxLayout *layout_gps = new QHBoxLayout;
+ layout_gps->addWidget(gps_cell);
+ layout_gps->addWidget(gps_both);
+ layout_gps->addWidget(gps_agps);
+ layout_form->addRow(layout_gps);
+ connect(gps_cell, SIGNAL(clicked()), this, SLOT(save_gps_cell()));
+ connect(gps_both, SIGNAL(clicked()), this, SLOT(save_gps_both()));
+ connect(gps_agps, SIGNAL(clicked()), this, SLOT(save_gps_agps()));
+
+ dialoglogin->setLayout(layout_form);
+ dialoglogin->exec();
+
+ if ( setting->value("interval",1800).toInt() < 300 )
+ setting->setValue("interval", 300);
+ if ( setting->value("interval",1800).toInt() > 3600 )
+ setting->setValue("interval", 3600);
+
+ if ( QString("agps") == setting->value("method","cell").toString() ) {
+ if ( setting->value("wait",30).toInt() < 15 )
+ setting->setValue("wait", 15);
+ } else {
+ if ( setting->value("wait",30).toInt() < 5 )
+ setting->setValue("wait", 5);
+ }
+ if ( setting->value("wait",30).toInt() > 120 )
+ setting->setValue("wait", 120);
+
+ set_config();
+ glatitude->reset();
+ gps->refresh();
+
+ mode_latitude();
+}
+