+
+void ProfilesWindow::on_actionEditDefaultProfile_triggered(){
+ org::maemo::vicar::Profile profile;
+ bool result = d->databaseUtility->getDefaultProfile(&profile);
+ qDebug() << "Default profile exits? " <<result;
+ if (result){
+ //Default profile does not exist - edit it
+ ProfileSettingsDialog *dialog = new ProfileSettingsDialog(this,&profile);
+ int response = dialog->exec();
+ if (response == QDialog::Accepted){
+ qDebug() << "Updating default profile record";
+ bool result = d->databaseUtility->updateProfile(profile);
+ if (!result){
+ d->dbusUtility->displayNotification("Unable to update default profile.");
+ qDebug() << "Error updating default profile."<< d->databaseUtility->lastError();
+ }
+ else{
+ ui->profilesListWidget->clear();
+ this->loadProfilesList();
+ }
+ }
+ }
+ else{
+ //Create new default profile
+ profile.phoneNumberPattern = "%";
+ ProfileSettingsDialog *dialog = new ProfileSettingsDialog(this,&profile);
+ int result = dialog->exec();
+ if (result == QDialog::Accepted){
+ qDebug() << "Inserting new default profile record";
+ int result = d->databaseUtility->insertProfile(profile);
+ if (result == -1){
+ d->dbusUtility->displayNotification("Unable to create default profile.");
+ qDebug() << "Error inserting new default profile record. "<< d->databaseUtility->lastError();
+ }
+ else{
+ QString strProfileDetails = QString("No profile found, then call via %1")
+ .arg(profile.gatewayNumber);
+ QListWidgetItem *item = new QListWidgetItem(strProfileDetails,ui->profilesListWidget);
+ item->setData(Qt::UserRole,result);
+ }
+ }
+ }
+}