-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
136 additions
and
2 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
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
Examples/PosturePerfection/PosturePerfection_receiver_deb_version.cpp
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,31 @@ | ||
/** | ||
* @file PosturePerfection_receiver.cpp | ||
* @brief Program for running a notification receiver | ||
* | ||
* @copyright Copyright (C) 2021 Conor Begley | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#include <RemoteNotifyReceive.h> | ||
int main(int argc, char *argv[]) { | ||
char current_d[1024]; | ||
getcwd(current_d, sizeof(current_d)); | ||
std::string image = "/usr/local/share/PosturePerfection/posture-logo-no-text.png" ; | ||
RemoteNotify::Receive receiver(121121, true, "Posture Perfection", image); | ||
while (1) { | ||
receiver.run(); | ||
} | ||
return 1; | ||
} |
Binary file added
BIN
+18.5 KB
Examples/PosturePerfection/debPackage/PosturePerfectionReceiver_1.0_amd64.deb
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
Examples/PosturePerfection/debPackage/PosturePerfectionReceiver_1.0_amd64/DEBIAN/control
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,5 @@ | ||
Package: PosturePerfectionReceiver | ||
Version: 1.0 | ||
Architecture: amd64 | ||
Maintainer: ESE-Peasy | ||
Description: A UDP receiver from messages generated by the main PosturePerfection program |
96 changes: 96 additions & 0 deletions
96
...on/debPackage/PosturePerfectionReceiver_1.0_amd64/usr/local/include/RemoteNotifyReceive.h
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,96 @@ | ||
/** | ||
* @file RemoteNotifyReceive.h | ||
* @brief For listening and receiving notifications from | ||
* `RemoteNotify::Broadcast` | ||
* | ||
* @copyright Copyright (C) 2021 Conor Begley | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef REMOTENOTIFYRECEIVE_H_ | ||
#define REMOTENOTIFYRECEIVE_H_ | ||
|
||
#include <arpa/inet.h> | ||
#include <errno.h> | ||
#include <netinet/in.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/socket.h> | ||
#include <unistd.h> | ||
|
||
#include <cstring> | ||
#include <iostream> | ||
#include <string> | ||
|
||
namespace RemoteNotify { | ||
/** | ||
* @brief Error handler for socket connections | ||
* | ||
* @param num The result of socket function | ||
* @param msg Message to be printed also default error message | ||
*/ | ||
int err_msg(int num, std::string msg); | ||
|
||
/** | ||
* @brief Return result from system command as a string | ||
* @param cmd The system command | ||
*/ | ||
std::string GetStringFromCommand(std::string cmd); | ||
|
||
/** | ||
* @brief A `RemoteNotify::Receive` for listening and receiving notifications | ||
* from `RemoteNotify::Broadcast` | ||
* | ||
*/ | ||
class Receive { | ||
private: | ||
int receive_fd; ///< Receive socket file descriptor | ||
struct sockaddr_in address, ///< Receive address | ||
Broadcast_address; ///< Specific address details for received messages | ||
int addr_len = sizeof(address); ///< Length of address structure | ||
int Broadcast_len = | ||
sizeof(Broadcast_address); ///< Length of Broadcast address structure | ||
std::string command = "notify-send -t 0"; ///< Notify-send command | ||
///< and flags | ||
std::string title; ///< Title of Notify Send message | ||
std::string image; ///< Absolute path of image | ||
std::string middle = "--icon"; | ||
char quote = '"'; | ||
char space = ' '; | ||
|
||
public: | ||
char buffer[1024]; ///< Returned result from broadcasted message | ||
/** | ||
* @brief Constructor for `RemoteNotify::Receive` | ||
* | ||
* @param port Port number to listen on (default is 121121) | ||
* @param ignore Boolean to ignore location where Notify::NotifyReceive is | ||
* running | ||
* @param check_env If `true` will check current desktop environment and | ||
* change notify-send command if needed | ||
*/ | ||
Receive(int port = 121121, bool check_env = true, | ||
std::string title = "Remote Notify Send Receive", | ||
std::string image = ""); | ||
~Receive(); | ||
|
||
/** | ||
* @brief Sets the `Notify::NotifyReceive` to start listening | ||
*/ | ||
void run(); | ||
}; | ||
} // namespace RemoteNotify | ||
#endif // SRC_NOTIFICATIONS_Receive_H_ |
Binary file added
BIN
+8.42 KB
...onReceiver_1.0_amd64/usr/local/share/PosturePerfection/posture-logo-no-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.