2011-06-17 15:57:13 -04:00
# include <retroshare/rsplugin.h>
2012-09-13 16:38:07 -04:00
# include <util/rsversion.h>
2011-11-17 16:17:24 -05:00
# include <QTranslator>
2011-06-17 15:57:13 -04:00
# include "LinksCloudPlugin.h"
# include "LinksDialog.h"
static void * inited = new LinksCloudPlugin ( ) ;
extern " C " {
void * RETROSHARE_PLUGIN_provide ( )
{
static LinksCloudPlugin * p = new LinksCloudPlugin ( ) ;
return ( void * ) p ;
}
2012-09-13 16:38:07 -04:00
// This symbol contains the svn revision number grabbed from the executable.
// It will be tested by RS to load the plugin automatically, since it is safe to load plugins
// with same revision numbers, assuming that the revision numbers are up-to-date.
//
uint32_t RETROSHARE_PLUGIN_revision = SVN_REVISION_NUMBER ;
// This symbol contains the svn revision number grabbed from the executable.
// It will be tested by RS to load the plugin automatically, since it is safe to load plugins
// with same revision numbers, assuming that the revision numbers are up-to-date.
//
uint32_t RETROSHARE_PLUGIN_api = RS_PLUGIN_API_VERSION ;
2011-06-17 15:57:13 -04:00
}
# define IMAGE_LINKS ": / images / irkick.png"
2011-07-05 16:29:07 -04:00
void LinksCloudPlugin : : getPluginVersion ( int & major , int & minor , int & svn_rev ) const
{
major = 5 ;
minor = 1 ;
svn_rev = 4350 ;
}
2011-06-17 15:57:13 -04:00
LinksCloudPlugin : : LinksCloudPlugin ( )
{
mRanking = NULL ;
mainpage = NULL ;
2011-10-08 13:47:36 -04:00
mIcon = NULL ;
mPlugInHandler = NULL ;
mPeers = NULL ;
mFiles = NULL ;
}
void LinksCloudPlugin : : setInterfaces ( RsPlugInInterfaces & interfaces ) {
mPeers = interfaces . mPeers ;
mFiles = interfaces . mFiles ;
2011-06-17 15:57:13 -04:00
}
MainPage * LinksCloudPlugin : : qt_page ( ) const
{
if ( mainpage = = NULL )
2011-10-08 13:47:36 -04:00
mainpage = new LinksDialog ( mPeers , mFiles ) ;
2011-06-17 15:57:13 -04:00
return mainpage ;
}
RsCacheService * LinksCloudPlugin : : rs_cache_service ( ) const
{
if ( mRanking = = NULL )
{
2011-10-08 13:47:36 -04:00
mRanking = new p3Ranking ( mPlugInHandler ) ; // , 3600 * 24 * 30 * 6); // 6 Months
2011-06-17 15:57:13 -04:00
rsRanks = mRanking ;
}
return mRanking ;
}
2011-10-08 13:47:36 -04:00
void LinksCloudPlugin : : setPlugInHandler ( RsPluginHandler * pgHandler ) {
mPlugInHandler = pgHandler ;
}
2011-06-17 15:57:13 -04:00
QIcon * LinksCloudPlugin : : qt_icon ( ) const
{
2011-06-29 18:57:35 -04:00
if ( mIcon = = NULL )
2011-07-05 16:42:28 -04:00
{
2012-10-03 18:59:28 -04:00
Q_INIT_RESOURCE ( LinksCloud_images ) ;
2011-07-05 16:42:28 -04:00
2011-06-29 18:57:35 -04:00
mIcon = new QIcon ( IMAGE_LINKS ) ;
2011-07-05 16:42:28 -04:00
}
2011-06-29 18:57:35 -04:00
2011-06-17 15:57:13 -04:00
return mIcon ;
}
std : : string LinksCloudPlugin : : getShortPluginDescription ( ) const
{
2011-11-17 16:17:24 -05:00
return QApplication : : translate ( " LinksCloudPlugin " , " This plugin provides a set of cached links, and a voting system to promote them. " ) . toUtf8 ( ) . constData ( ) ;
2011-06-17 15:57:13 -04:00
}
2011-11-17 16:17:24 -05:00
std : : string LinksCloudPlugin : : getPluginName ( ) const
{
return QApplication : : translate ( " LinksCloudPlugin " , " LinksCloud " ) . toUtf8 ( ) . constData ( ) ;
}
2012-09-30 09:16:51 -04:00
QTranslator * LinksCloudPlugin : : qt_translator ( QApplication */ * app */ , const QString & languageCode ) const
2011-11-17 16:17:24 -05:00
{
if ( languageCode = = " en " ) {
return NULL ;
}
2012-07-15 17:37:35 -04:00
QTranslator * translator = new QTranslator ( ) ;
2012-10-11 19:46:54 -04:00
if ( translator - > load ( QCoreApplication : : applicationDirPath ( ) + " /translations/LinksCloud_ " + languageCode + " .qm " ) ) {
return translator ;
} else if ( translator - > load ( " :/lang/LinksCloud_ " + languageCode + " .qm " ) ) {
2011-11-17 16:17:24 -05:00
return translator ;
}
2011-06-17 15:57:13 -04:00
2011-11-17 16:17:24 -05:00
delete ( translator ) ;
return NULL ;
}