-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start creating tarnish api in liboxide
- Loading branch information
Showing
9 changed files
with
134 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "tarnish.h" | ||
#include "meta.h" | ||
#include "debug.h" | ||
|
||
#include <QDBusConnection> | ||
|
||
General* api = nullptr; | ||
|
||
bool verifyConnection(){ | ||
if(api == nullptr){ | ||
return false; | ||
} | ||
if(!api->isValid()){ | ||
delete api; | ||
api = nullptr; | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
namespace Oxide::Tarnish { | ||
General* getApi(){ return api; } | ||
QDBusObjectPath requestAPI(std::string name){ | ||
connect(); | ||
return api->requestAPI(QString::fromStdString(name)); | ||
} | ||
void connect(){ connect(qApp->applicationName().toStdString()); } | ||
void connect(std::string name){ | ||
if(verifyConnection()){ | ||
return; | ||
} | ||
auto bus = QDBusConnection::systemBus(); | ||
O_DEBUG("Waiting for tarnish to start up..."); | ||
while(!bus.interface()->registeredServiceNames().value().contains(OXIDE_SERVICE)){ | ||
timespec args{ | ||
.tv_sec = 1, | ||
.tv_nsec = 0, | ||
}, res; | ||
nanosleep(&args, &res); | ||
} | ||
api = new General(OXIDE_SERVICE, OXIDE_SERVICE_PATH, bus, qApp); | ||
api->registerChild(getpid(), QString::fromStdString(name), QDBusUnixFileDescriptor(fileno(stdin)), QDBusUnixFileDescriptor(fileno(stdout))); | ||
} | ||
int tarnishPid(){ | ||
connect(); | ||
return api->tarnishPid(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*! | ||
* \addtogroup Oxide::Tarnish | ||
* \brief The Tarnish module | ||
* @{ | ||
* \file | ||
*/ | ||
#pragma once | ||
#include "liboxide_global.h" | ||
#include "dbus.h" | ||
|
||
using namespace codes::eeems::oxide1; | ||
|
||
namespace Oxide::Tarnish { | ||
/*! | ||
* \brief Get the current General API instance | ||
* \return The current General API instance | ||
*/ | ||
General* getApi(); | ||
QDBusObjectPath requestAPI(std::string name); | ||
/*! | ||
* \brief Connect to the current tarnish instance | ||
*/ | ||
void connect(); | ||
/*! | ||
* \brief Connect to the current tarnish instance | ||
* \param Name of current application | ||
*/ | ||
void connect(std::string name); | ||
/*! | ||
* \brief Get the tarnish PID | ||
* \return The tarnish PID | ||
*/ | ||
int tarnishPid(); | ||
} |