skauth.cpp 2.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*  ____  _          _ _          __  __
 * / ___|| | ___   _| (_)_   _____\ \/ /
 * \___ \| |/ / | | | | \ \ / / _ \\  / 
 *  ___) |   <| |_| | | |\ V /  __//  \ Remote Telescopes
 * |____/|_|\_\\__, |_|_| \_/ \___/_/\_\ For the masses
 *             |___/               
 *
 * Copyright (C) 2013 Franco (nextime) Lanza <nextime@nexlab.it>
 * Copyright (C) 2013 Ivan Bellia <skylive@skylive.it>
 *
 * All rights reserved.
 *
 * This file is part of SkyliveX.
 *
 * SkyliveX 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.
 *
 * Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *
 ********************************************************************
 *
 * File: 
 * 
 * Purpose:
 *
 */
#include "pluginsinterfaces.h"
36
#include "ipcmsg.h"
37 38
#include <iostream>
#include "skauth.h"
39
#include "sksettings.h"
40 41 42

void SkyliveAuth::startPlugin()
{
43
   std::cout << "SkyliveAuth initialized in thread " << thread() << std::endl;
44 45

   registerHandler((QString)"getlogin", &SkyliveAuth::handle_getlogin);
46 47
}

48

49 50 51 52 53
void SkyliveAuth::pluginKicked()
{

}

root's avatar
root committed
54
void SkyliveAuth::receiveMessage(SKMessage msg)
55
{
56
   std::cout << "SkyliveAuth msg received: " << msg.handle.toStdString() << std::endl;
57 58 59 60 61 62
   if(_handlers.contains(msg.handle) && msg.sender != SENDER)
   {
     SKHandlerFunction mf =_handlers[msg.handle];
     (this->*mf)(msg);
   }    

63 64
}

65

root's avatar
root committed
66
void SkyliveAuth::sendMessage(SKMessage msg)
67
{
68
   msg.sender=SENDER;
69 70 71
   emit putMessage(msg);
}

72 73 74 75 76 77
void SkyliveAuth::registerHandler(QString type, SKHandlerFunction handler)
{
  _handlers[type] = handler;
   
}  

root's avatar
root committed
78
void SkyliveAuth::handle_getlogin(SKMessage msg)
79 80 81 82 83 84 85 86
{
   std::cout << "Auth module handle Login by " << msg.sender.toStdString() << std::endl;
   /*
    * XXX: This is, for the moment, a dummy plugin.
    * Here we should check if we have a saved user and pass,
    * and ask the main process only if we donesn't yet have one
    * or if the user has logged out.
    */
root's avatar
root committed
87
    SKMessage smsg("asklogin");
88 89 90 91 92
    sendMessage(smsg);

    
}