Commit 4bba46d1 authored by Edric Milaret's avatar Edric Milaret Committed by Guillaume Roguez

windows: add start on startup feature

Also fix wrong copyright header

Refs #72072

Change-Id: I2920f7f9d7dd8dfdd91f52a46ee33a106781fdbd
parent 3a23e495
......@@ -32,7 +32,8 @@ SOURCES += main.cpp\
aboutdialog.cpp \
pivotviewwidget.cpp \
pivotcontrol.cpp \
videowidget.cpp
videowidget.cpp \
utils.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -46,7 +47,8 @@ HEADERS += mainwindow.h \
aboutdialog.h \
pivotviewwidget.h \
pivotcontrol.h \
videowidget.h
videowidget.h \
utils.h
FORMS += mainwindow.ui \
callwidget.ui \
......@@ -57,6 +59,8 @@ FORMS += mainwindow.ui \
aboutdialog.ui \
pivotviewwidget.ui
win32: LIBS += -lole32 -luuid -lshlwapi
INCLUDEPATH += /home/edric/Documents/CrossWorkspace/ring/binArch/include/libringclient
win32: LIBS += -L/home/edric/Documents/CrossWorkspace/ring/binArch/lib/ -lringclient
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -27,6 +27,7 @@
#include "fallbackpersoncollection.h"
#include "accountmodel.h"
#include "utils.h"
CallWidget::CallWidget(QWidget *parent) :
NavWidget(Main ,parent),
......@@ -91,6 +92,7 @@ CallWidget::findRingAccount() {
if (!found) {
AccountModel::instance()->add("RING", Account::Protocol::RING);
AccountModel::instance()->save();
Utils::CreateStartupLink();
findRingAccount();
}
}
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -23,12 +23,13 @@
#include "video/channel.h"
#include "video/resolution.h"
#include "video/rate.h"
#include "video/previewmanager.h"
#include "accountmodel.h"
#include "protocolmodel.h"
#include "accountdetails.h"
#include <video/previewmanager.h>
#include "utils.h"
ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
NavWidget(Nav, parent),
......@@ -54,6 +55,7 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
ui->accountDetailLayout->addWidget(accountDetails_);
ui->testVideoButton->setCheckable(true);
ui->accountTypeBox->setModel(accountModel_->protocolModel());
ui->startupBox->setChecked(Utils::CheckStartupLink());
}
void ConfigurationWidget::atExit() {
......@@ -155,3 +157,11 @@ ConfigurationWidget::on_addAccountButton_clicked()
ui->accountTypeBox->currentIndex(), 0));
accountModel_->save();
}
void ConfigurationWidget::on_startupBox_toggled(bool checked)
{
if (checked)
Utils::CreateStartupLink();
else
Utils::DeleteStartupLink();
}
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -54,6 +54,8 @@ private slots:
private slots:
void accountSelected(QItemSelection itemSel);
void on_startupBox_toggled(bool checked);
private:
Ui::ConfigurationWidget *ui;
AccountModel* accountModel_;
......
......@@ -19,7 +19,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
......@@ -29,7 +29,7 @@
<attribute name="title">
<string>Video</string>
</attribute>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1" columnstretch="0,0">
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
......@@ -223,6 +223,16 @@
</widget>
</widget>
</item>
<item>
<widget class="QCheckBox" name="startupBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Launch Ring on Startup</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -75,7 +75,8 @@ MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) {
this->show();
}
void MainWindow::onIncomingCall(Call *call) {
void
MainWindow::onIncomingCall(Call *call) {
Q_UNUSED(call);
QWidget::showNormal();
}
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "utils.h"
bool
Utils::CreateStartupLink() {
TCHAR userHome[MAX_PATH];
SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, userHome);
TCHAR workingDirectory[MAX_PATH];
GetCurrentDirectory(MAX_PATH, workingDirectory);
std::wstring programPath(workingDirectory);
programPath += TEXT("\\RingClientWindows.exe");
std::wstring linkPath(userHome);
linkPath += TEXT("\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\Ring.lnk");
return Utils::CreateLink(programPath.c_str(), linkPath.c_str());
}
bool
Utils::CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszPathLink) {
HRESULT hres;
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
psl->SetPath(lpszPathObj);
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres))
{
hres = ppf->Save(lpszPathLink, TRUE);
ppf->Release();
}
psl->Release();
}
return hres;
}
void
Utils::DeleteStartupLink() {
TCHAR userHome[MAX_PATH];
SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, userHome);
std::wstring linkPath(userHome);
linkPath += TEXT("\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\Ring.lnk");
DeleteFile(linkPath.c_str());
}
bool
Utils::CheckStartupLink() {
TCHAR userHome[MAX_PATH];
SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, userHome);
std::wstring linkPath(userHome);
linkPath += TEXT("\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\Ring.lnk");
return PathFileExists(linkPath.c_str());
}
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#ifndef UTILS_H
#define UTILS_H
#include <windows.h>
#include <lmcons.h>
#include <shobjidl.h>
#include <shlguid.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <string>
class Utils
{
public:
static bool CreateStartupLink();
static void DeleteStartupLink();
static bool CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszPathLink);
static bool CheckStartupLink();
};
#endif // UTILS_H
/***************************************************************************
* Copyright (C) 2011-2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment