blob: 54dcca1b7fdfcee243dfb95c4eba1d63478c3fe6 [file] [log] [blame]
Edric Milaretfe390942015-08-04 13:41:03 -04001/***************************************************************************
Anthony LĂ©onard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2017 by Savoir-faire Linux *
Edric Milaretfe390942015-08-04 13:41:03 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#include "shmclient.h"
20
21#include <QTextStream>
22
23ShmClient::ShmClient(QSharedMemory* shm, QSystemSemaphore *sem) :
24 shm_(shm),
25 sem_(sem)
26{
27 start();
28}
29
30void ShmClient::run()
31{
32 while (true) {
33
34 sem_->acquire();
35
36 shm_->lock();
37
38 char const *from = (char const*)shm_->data();
39
40 QString uri = "";
41 QTextStream stream(&uri);
42
43 while (from && *from)
44 {
45 stream << *from;
46 ++from;
47 }
48
49 shm_->unlock();
50
51 emit RingEvent(uri);
52 }
53}