protocol.h 2.75 KB
Newer Older
mbriand's avatar
mbriand committed
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
/*

	UBPT Transfert 2

	Copyright (C) 2005,2006 Julien Etelain. Tous droits réservés..
	Copyright (C) 2011 Mathieu Briand.

	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 2
	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, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/
/**
	@addtogroup ubptprococol
	@{
*/
/**
	@file
*/

#ifndef PROTOCOL_H
#define PROTOCOL_H

#include<QStringList>
#include<QMap>

#include <curl/curl.h>
/* In recent version of libcurl, this include doesn't exist anymore, uncomment if it breaks build for you
* #include <curl/types.h>
*/
#include <curl/easy.h>
/**
	UBPT Context
*/
class UbptContext
{
	public:

	QString Name;
	int Id;
	int IdParent;
	QString Group;
	int Rights;

};


/**
	UBPT Session
*/
class UbptSession
{

public:

	UbptSession();
	~UbptSession();

	QString Name;
	QString Message;
	QString Url;
	int userId;

	QStringList Domains;
	QList<UbptContext*> Contexts;
	QStringList UserGroups;
	QMap<QString, int> Clubs;
	QMap<QString, int> Licences;


	int ConnectToServer ( QString url );
	int OpenSession ( QString userName, QString passWord, int domain );
	int FetchUserGroups();
	int FetchClubs();
	int FetchLicences();
	int FetchContexts();

  int UploadImage ( int contextId, int rights, QString group, int photographerUserId, int clubId, int licenceId, QString comment, QString file );
  int UploadVideoFlv ( int contextId, int rights, QString group, int photographerUserId, int clubId, int licenceId, QString comment, QString fileImage, QString fileVideo );

	int SetProgress( curl_progress_callback func, void *clientp );

private:

	CURL *curl;
	QString sessionId;
	int connected;
	char *_url;
};

#define ERR_UBPT_NONE 0

// Errors in use of functions : please respect order and check return codes
#define ERR_UBPT_NOTCONNECTED -4

#define ERR_UBPT_SESSIONREQUIRED -3
#define ERR_UBPT_INIT -2
#define ERR_SYSTEMERROR -5

// Error in connectivity
#define ERR_UBPT_NOCONNECTION -1

// Other errors
#define ERR_UBPT_USERNAMEORPASSWORD 10
#define ERR_UBPT_NEEDTOUPDATE 11
#define ERR_UBPT_INVALIDIMAGEFILE 3
#define ERR_UBPT_MYSQLERROR 2
#define ERR_UBPT_UNKNOWNCONTEXT 8
#define ERR_UBPT_FORBIDDEN 9
#define ERR_UBPT_UPLOADERROR 1


#define ERR_UBPT_VIDEOTRANSCODE -10
#define ERR_UBPT_VIDEOSHOT -11



#endif
/**
@}
*/