From a57632c1b4dee9bd0bd0e53c06e9d304a8fcab9d Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 1 Mar 2020 20:13:18 +0100 Subject: [PATCH 1/4] fixing the Album create icon --- retroshare-gui/src/gui/PhotoShare/PhotoShare.ui | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui b/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui index 5a6204006..c09770572 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui +++ b/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui @@ -38,8 +38,8 @@ Create Album - - :/images/add_image24.png:/images/add_image24.png + + :/images/album_create_64.png:/images/album_create_64.png @@ -61,7 +61,7 @@ Edit Album Details - + :/images/add_image24.png:/images/add_image24.png @@ -283,7 +283,7 @@ 0 0 804 - 197 + 208 @@ -319,7 +319,7 @@ 0 0 804 - 196 + 208 From 08e3401503fc01842b2f7dea225453bbc8a57081 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 2 Mar 2020 19:40:44 +0100 Subject: [PATCH 2/4] attempting to fix layout issues --- .../src/gui/PhotoShare/AlbumDialog.ui | 465 +++++++++--------- .../src/gui/PhotoShare/AlbumItem.ui | 58 ++- .../src/gui/PhotoShare/PhotoShare.ui | 7 +- 3 files changed, 283 insertions(+), 247 deletions(-) diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.ui b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.ui index b73f55d3d..2d1e7de4e 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.ui +++ b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.ui @@ -16,262 +16,259 @@ true - - + + - QFrame::StyledPanel + QFrame::NoFrame - QFrame::Raised + QFrame::Plain - + + + + + + + 64 + 64 + + + + TextLabel + + + + + + + Qt::Vertical + + + + 20 + 12 + + + + + + + + + + 6 + + + + + false + + + + 0 + 0 + + + + + + + + false + + + + 0 + 0 + + + + + + + + Category: + + + + + + + Caption + + + + + + + Album Title: + + + + + + + false + + + + 0 + 0 + + + + + + + + Qt::Vertical + + + + 568 + 6 + + + + + + + - + 0 - 0 + 1 - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 10 - 0 - - - - - 6 - - - 2 - - - - - false - - - - 0 - 0 - - - - - - - - Category: - - - - - - - false - - - - 0 - 0 - - - - - - - - - 0 - 1 - - - - - - - - 64 - 64 - - - - TextLabel - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - false - - - - 0 - 0 - - - - - - - - Caption - - - - - - - Album Title: - - - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + + 0 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;"> Drag &amp; Drop to insert pictures. Click on a picture to edit details below.</span></p></body></html> - - - - - - - - 0 - 10 - - - - true - - - Qt::ScrollBarAsNeeded - - - true - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - 0 - 0 - 737 - 315 - - - - - 0 - 10 - - - - QWidget#scrollAreaWidgetContents{border: none;} - - - - - - + - - - - - - Add Photo - - - - - - - Edit Photo - - - - - - - Delete Photo - - - - - - - Qt::Horizontal - - - - 68 - 17 - - - - - - - - QDialogButtonBox::Cancel - - - - - - - Publish Photos - - - - + + + + + 0 + 10 + + + + true + + + Qt::ScrollBarAsNeeded + + + true + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + 0 + 0 + 757 + 395 + + + + + 0 + 10 + + + + QWidget#scrollAreaWidgetContents{border: none;} + + + + + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + Add Photo + + + + + + + Edit Photo + + + + + + + Delete Photo + + + + + + + Qt::Horizontal + + + + 68 + 17 + + + + + + + + QDialogButtonBox::Cancel + + + + + + + Publish Photos + + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumItem.ui b/retroshare-gui/src/gui/PhotoShare/AlbumItem.ui index 88ef3770d..9e5d36378 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumItem.ui +++ b/retroshare-gui/src/gui/PhotoShare/AlbumItem.ui @@ -6,8 +6,8 @@ 0 0 - 229 - 234 + 230 + 217 @@ -28,15 +28,51 @@ border-radius: 10px} QFrame::Raised - - - - - TextLabel - - + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 18 + 20 + + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 18 + 20 + + + + + - + @@ -91,7 +127,7 @@ p, li { white-space: pre-wrap; } - + Qt::Vertical diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui b/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui index c09770572..19230a67f 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui +++ b/retroshare-gui/src/gui/PhotoShare/PhotoShare.ui @@ -61,8 +61,8 @@ Edit Album Details - - :/images/add_image24.png:/images/add_image24.png + + :/images/edit_16.png:/images/edit_16.png @@ -73,6 +73,9 @@ Qt::ToolButtonTextBesideIcon + + true + From 0529c5d1aacf214d3ee4db4eec085a1d6fcc955f Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 2 Mar 2020 21:47:18 +0100 Subject: [PATCH 3/4] added some icons for photos --- .../src/gui/PhotoShare/PhotoDialog.cpp | 9 ++++ .../src/gui/PhotoShare/PhotoDialog.ui | 50 +++++++++++++++--- .../src/gui/PhotoShare/PhotoSlideShow.cpp | 5 ++ .../src/gui/PhotoShare/PhotoSlideShow.ui | 5 +- retroshare-gui/src/gui/icons.qrc | 2 + .../src/gui/icons/fullscreen-exit.png | Bin 0 -> 1336 bytes retroshare-gui/src/gui/icons/fullscreen.png | Bin 0 -> 1331 bytes 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 retroshare-gui/src/gui/icons/fullscreen-exit.png create mode 100644 retroshare-gui/src/gui/icons/fullscreen.png diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp index 6251dc38f..004c5d4cf 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp @@ -25,6 +25,11 @@ #include "retroshare/rsidentity.h" #include "gui/gxs/GxsCommentDialog.h" +#define IMAGE_FULLSCREEN ":/icons/fullscreen.png" +#define IMAGE_FULLSCREENEXIT ":/icons/fullscreen-exit.png" +#define IMAGE_SHOW ":/icons/png/down-arrow.png" +#define IMAGE_HIDE ":/icons/png/up-arrow.png" + PhotoDialog::PhotoDialog(RsPhoto *rs_photo, const RsPhotoPhoto &photo, QWidget *parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), ui(new Ui::PhotoDialog), mRsPhoto(rs_photo), mPhotoQueue(new TokenQueue(mRsPhoto->getTokenService(), this)), @@ -76,8 +81,10 @@ void PhotoDialog::toggleDetails() { if (ui->frame_details->isVisible()) { ui->frame_details->setVisible(false); + ui->detailsButton->setIcon(QIcon(IMAGE_SHOW)); } else { ui->frame_details->setVisible(true); + ui->detailsButton->setIcon(QIcon(IMAGE_HIDE)); } } @@ -182,9 +189,11 @@ void PhotoDialog::setFullScreen() show(); raise(); #endif + ui->fullscreenButton->setIcon(QIcon(IMAGE_FULLSCREENEXIT)); } else { setWindowState( windowState() ^ Qt::WindowFullScreen ); show(); + ui->fullscreenButton->setIcon(QIcon(IMAGE_FULLSCREEN)); } } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui index b8ab9d67b..8a0adf7c9 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui @@ -7,7 +7,7 @@ 0 0 790 - 824 + 509 @@ -52,11 +52,24 @@ 0 0 - 558 - 551 + 540 + 318 + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -74,8 +87,24 @@ TextLabel + + Qt::AlignCenter + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -92,8 +121,8 @@ ... - - :/images/window_fullscreen.png:/images/window_fullscreen.png + + :/icons/fullscreen.png:/icons/fullscreen.png true @@ -103,7 +132,11 @@ - Details \/ + Details + + + + :/icons/png/down-arrow.png:/icons/png/down-arrow.png @@ -136,6 +169,10 @@ <N> Comments >> + + + :/icons/png/comment.png:/icons/png/comment.png + @@ -255,6 +292,7 @@ + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp index 7e5fb6d00..3965bb79a 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp @@ -22,6 +22,9 @@ #include "gui/PhotoShare/PhotoDrop.h" #include "gui/gxs/GxsIdDetails.h" +#define IMAGE_FULLSCREEN ":/icons/fullscreen.png" +#define IMAGE_FULLSCREENEXIT ":/icons/fullscreen-exit.png" + #include /** Constructor */ @@ -300,10 +303,12 @@ void PhotoSlideShow::setFullScreen() show(); raise(); #endif + ui.fullscreenButton->setIcon(QIcon(IMAGE_FULLSCREENEXIT)); } else { setWindowState( windowState() ^ Qt::WindowFullScreen ); show(); + ui.fullscreenButton->setIcon(QIcon(IMAGE_FULLSCREEN)); } } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui index bc771eec0..50d031e4e 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui @@ -98,8 +98,8 @@ - - :/images/window_fullscreen.png:/images/window_fullscreen.png + + :/icons/fullscreen.png:/icons/fullscreen.png false @@ -157,6 +157,7 @@ + diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 94a8129ef..53b572552 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -316,5 +316,7 @@ icons/textedit/smile.png icons/textedit/font-increase.png icons/textedit/code.png + icons/fullscreen.png + icons/fullscreen-exit.png diff --git a/retroshare-gui/src/gui/icons/fullscreen-exit.png b/retroshare-gui/src/gui/icons/fullscreen-exit.png new file mode 100644 index 0000000000000000000000000000000000000000..eb0d29385c10343d4f8eedd1ef6dc1875d800cec GIT binary patch literal 1336 zcmZ`(Yfuwc6u!GjBnc2A$fMHAb}EQfObGajmL!@;K;#jjK1Y|Q;)84j6_5%FB6R=>sSrStY|;(WKmE~}d(L;xcfRkQA9v;+ zkB^OXXU=5;0NkUbVi}3JGw2jDoBPg8lR(`i+8_d;y3o~@Oe1?FRVv#6z`-C=_Z0vZ zr+yHC16%-xQ2_YG0Qh31wF#@qK}LK`qJ%_nxtnsagIdx7zIzPHS}7$R!f(y+g z50iW;$#hbkxdUA40_U6sIhs*+k{Q0(PRb}V0_w%5Gdy|WQ|g5o3jhJHCj-evh(Z>- z5wOnUuIz>f$C&kxJnw58-Q9jEuG7C#s(-!BA2SPA)1w=YkXk5ZeWVy1qkSYL8wMub zk^=y%(HYRWMJ#`kbWucYkhly`U@wHWDd^;004SMJVo_r5b7S{gSvQwmki1sL+@D$c z^Kr>R;gtH^dv?Hl;~u@FB>8GN;Udlph+!=&4{zZqrl2@K%30aEQdIbm` z|Cx$HC@bq8+q(-qiCD~q;#G+#q_gS_z%UUiT8W$1YEp!ih4g4>`Y>n33m!ELiBfgX|_|8sN69cb@a9>2_3Krm& zAg~pm*bj=ph(9EQp5KNW;TriYIxV-CRplLQDZrC-L)+kt{O{$=Vrp%D2+9t&J^%x5 zS7I;m4-B_o+gR~$G2RuxAUZ(%q9*)XQ3RmxBvZ>j6Kdm<)vW4q#vpcvBhPMGfsB<}_ zg{$Nggu1(zuBD&m476m`+_DDdCS@FUtSzYzy9S-^?s*BT`s)&0G25iwXRrbeG^E2f zk?uGuAO9nWe6m8?r-p3%nc2q(sSeurNS)j8wN3PXe(1E$ixBI>^$xmTt#HGH3VYEwtRLBAr_h(qY5x)TjkkINDW4TDIC193E0;O zp~0j!Vc-x^J$s+kUzFug9ff(%1SgOYj>cwpuqbIa^p%<#wYRiPFv!L+Vmb4PJyza0S>{A9nUx~L35US%l*PI=N}ZPkZe|@B`ebTsoCiy03Mge z4dI4`aCwQLEBRqOK6mLNE|<^c61}%S`;TG2JS{UL@Ba-aH6Hn-;REM}jq(hIGC4aP jD3!`3nOS>tQj@XtCGzZDC8Mk7k|Gc#i4|9_K{fvXL2fpI literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/icons/fullscreen.png b/retroshare-gui/src/gui/icons/fullscreen.png new file mode 100644 index 0000000000000000000000000000000000000000..3b14cbe356d7591c2eefde5ad36311e9c71dde8b GIT binary patch literal 1331 zcmZ`&eN>Wn6#l^rs0gCDP@yKdla{2uprvV{6c()1{K))hCVpgAOQw`$E-|d5$CXyP zA()USw{mG_W|m8^>}#3JN|&*YUo71!1?}U-O!jh4XXosXopbN+x%auxbMIfjl1<_3 z$wV3v06-S-c~K}zEolv*@0+3HCKPZP+%PTx7t3sCg?O}Qr1GP}0LXJkbwvQoSoGrn z?1cgNI~jmLIRH+g>T8j!(7{)mHpYaah*kDs6;B{#AE@kul>Ok;Q&8J$DbDCn@>3}K zKvg$d<32I{P_<=*t45H?Nl$w}b>;c{4STX-Ytan3N6cd7v1-kdHPtB7S@h0CruL#8fiv=qPC=7KDXb z=^?D+BHMF^%e?@AL;@Z+M)K^nayV88lh&F zH1xp@{M{>0v{#iX!%J!wH0k6KbP*P)maB0LPNvpcn%^U}mzpXt-XR7TC{8-!NH`1b z-64ly6cl^3Nb^S2-++-3G7h5LRR3Gq>AOCbmnUG{55_~IzU2`q-+D9jnyNyhSGjvHXTJUPWS2I8a`&V} zLtUabGojIq0aWU74t2>yup2a*08^bV&UtPcFfSvJg4xc@(j5g3XD2j0garjG=buX@ z=0)mP=9+`fNQNv@;5L(s*=yeKH)QgVMLth>m*XToofH;t9DS)aTWhcE=&cPcrFtc_ zd@ANX$ls_)!3FW_4hDhEH4h)ucN$>x3g=%wVmxbxKYme}BJx~hB&_d9$|1X|{;DU8 z&7IiPS^f*fqCE^E!4nRUBdtgP1oo$ho|$wl;yfhL@A3>X*P7%rsCzm)nb=-<{SsC9&Ke(TX*9AuM^2HG7#xLz3kl{_J3b;XT!RgKnmT{vu17kUu3CGc z2-EY^v5z+hI8_irqQUu7 Date: Wed, 4 Mar 2020 19:17:09 +0100 Subject: [PATCH 4/4] fixed 2 bugs causing forums and channels to be notified when already known and added notification list for posted --- libretroshare/src/rsitems/rsserviceids.h | 3 + libretroshare/src/rsserver/rsinit.cc | 1 + libretroshare/src/services/p3gxschannels.cc | 14 +-- libretroshare/src/services/p3gxsforums.cc | 14 +-- libretroshare/src/services/p3postbase.cc | 111 ++++++++++++++++++-- libretroshare/src/services/p3postbase.h | 46 ++++---- 6 files changed, 148 insertions(+), 41 deletions(-) diff --git a/libretroshare/src/rsitems/rsserviceids.h b/libretroshare/src/rsitems/rsserviceids.h index 3f690cf45..21c399fc0 100644 --- a/libretroshare/src/rsitems/rsserviceids.h +++ b/libretroshare/src/rsitems/rsserviceids.h @@ -64,6 +64,7 @@ enum class RsServiceType : uint16_t GXS_TRANS = 0x0230, JSONAPI = 0x0240, FORUMS_CONFIG = 0x0315, + POSTED_CONFIG = 0x0316, CHANNELS_CONFIG = 0x0317, RTT = 0x1011, /// Round Trip Time @@ -123,7 +124,9 @@ RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_GXS_TYPE_REPUTATION RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_TYPE_GXS_RECOGN = 0x0220; RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_TYPE_GXS_TRANS = 0x0230; RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_TYPE_JSONAPI = 0x0240; +/// used to save notification records in GXS and possible other service-based configuration RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_GXS_TYPE_FORUMS_CONFIG = 0x0315; +RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_GXS_TYPE_POSTED_CONFIG = 0x0316; RS_DEPRECATED_FOR(RsServiceType) const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS_CONFIG = 0x0317; // Experimental Services. diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 5de23251a..a4e652c4c 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1632,6 +1632,7 @@ int RsServer::StartupRetroShare() mConfigMgr->addConfiguration("gxschannels_srv.cfg", mGxsChannels); mConfigMgr->addConfiguration("gxscircles.cfg" , gxscircles_ns); mConfigMgr->addConfiguration("posted.cfg" , posted_ns); + mConfigMgr->addConfiguration("gxsposted_srv.cfg", mPosted); #ifdef RS_USE_WIKI mConfigMgr->addConfiguration("wiki.cfg", wiki_ns); #endif diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 2a63b3cdb..2d141f57e 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -136,14 +136,14 @@ uint32_t p3GxsChannels::channelsAuthenPolicy() static const uint32_t GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months static const uint8_t GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ; -struct RsGxsGroupNotifyRecordsItem: public RsItem +struct RsGxsChannelNotifyRecordsItem: public RsItem { - RsGxsGroupNotifyRecordsItem() + RsGxsChannelNotifyRecordsItem() : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_CHANNELS_CONFIG,GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD) {} - virtual ~RsGxsGroupNotifyRecordsItem() {} + virtual ~RsGxsChannelNotifyRecordsItem() {} void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) @@ -167,7 +167,7 @@ public: switch(item_sub_id) { - case GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsGroupNotifyRecordsItem(); + case GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsChannelNotifyRecordsItem(); default: return NULL; } @@ -178,7 +178,7 @@ bool p3GxsChannels::saveList(bool &cleanup, std::list&saveList) { cleanup = true ; - RsGxsGroupNotifyRecordsItem *item = new RsGxsGroupNotifyRecordsItem ; + RsGxsChannelNotifyRecordsItem *item = new RsGxsChannelNotifyRecordsItem ; { RS_STACK_MUTEX(mKnownChannelsMutex); @@ -198,7 +198,7 @@ bool p3GxsChannels::loadList(std::list& loadList) rstime_t now = time(NULL); - RsGxsGroupNotifyRecordsItem *fnr = dynamic_cast(item) ; + RsGxsChannelNotifyRecordsItem *fnr = dynamic_cast(item) ; if(fnr) { @@ -206,7 +206,7 @@ bool p3GxsChannels::loadList(std::list& loadList) mKnownChannels.clear(); for(auto it(fnr->records.begin());it!=fnr->records.end();++it) - if( it->second + GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE < now) + if( now < it->second + GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE) mKnownChannels.insert(*it) ; } diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index b8c414df0..5a6b0e568 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -96,14 +96,14 @@ uint32_t p3GxsForums::forumsAuthenPolicy() static const uint32_t GXS_FORUMS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months static const uint8_t GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ; -struct RsGxsGroupNotifyRecordsItem: public RsItem +struct RsGxsForumNotifyRecordsItem: public RsItem { - RsGxsGroupNotifyRecordsItem() + RsGxsForumNotifyRecordsItem() : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_FORUMS_CONFIG,GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD) {} - virtual ~RsGxsGroupNotifyRecordsItem() {} + virtual ~RsGxsForumNotifyRecordsItem() {} void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) @@ -127,7 +127,7 @@ public: switch(item_sub_id) { - case GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsGroupNotifyRecordsItem(); + case GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsForumNotifyRecordsItem(); default: return NULL; } @@ -138,7 +138,7 @@ bool p3GxsForums::saveList(bool &cleanup, std::list&saveList) { cleanup = true ; - RsGxsGroupNotifyRecordsItem *item = new RsGxsGroupNotifyRecordsItem ; + RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ; item->records = mKnownForums ; @@ -155,14 +155,14 @@ bool p3GxsForums::loadList(std::list& loadList) rstime_t now = time(NULL); - RsGxsGroupNotifyRecordsItem *fnr = dynamic_cast(item) ; + RsGxsForumNotifyRecordsItem *fnr = dynamic_cast(item) ; if(fnr != NULL) { mKnownForums.clear(); for(auto it(fnr->records.begin());it!=fnr->records.end();++it) - if( it->second + GXS_FORUMS_CONFIG_MAX_TIME_NOTIFY_STORAGE < now) + if( now < it->second + GXS_FORUMS_CONFIG_MAX_TIME_NOTIFY_STORAGE) mKnownForums.insert(*it) ; } diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index faaa1efb3..8dd48c174 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -157,15 +157,26 @@ void p3PostBase::notifyChanges(std::vector &changes) const std::list& grpList = grpChange->mGrpIdList; for (auto git = grpList.begin(); git != grpList.end(); ++git) - { + { + if(mKnownPosted.find(*git) == mKnownPosted.end()) + { + mKnownPosted.insert(std::make_pair(*git, time(nullptr))); + IndicateConfigChanged(); + + auto ev = std::make_shared(); + ev->mPostedGroupId = *git; + ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP; + rsEvents->postEvent(ev); + #ifdef POSTBASE_DEBUG - std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git; - std::cerr << std::endl; + std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git; + std::cerr << std::endl; #endif - auto ev = std::make_shared(); - ev->mPostedGroupId = *git; - ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP; - rsEvents->postEvent(ev); + } + else + RsInfo() << __PRETTY_FUNCTION__ + << " Not notifying already known forum " + << *git << std::endl; } } break; @@ -828,3 +839,89 @@ void p3PostBase::handleResponse(uint32_t token, uint32_t req_type) } } +static const uint32_t GXS_POSTED_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months +static const uint8_t GXS_POSTED_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ; + +struct RsGxsPostedNotifyRecordsItem: public RsItem +{ + + RsGxsPostedNotifyRecordsItem() + : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_POSTED_CONFIG,GXS_POSTED_CONFIG_SUBTYPE_NOTIFY_RECORD) + {} + + virtual ~RsGxsPostedNotifyRecordsItem() {} + + void serial_process( RsGenericSerializer::SerializeJob j, + RsGenericSerializer::SerializeContext& ctx ) + { RS_SERIAL_PROCESS(records); } + + void clear() {} + + std::map records; +}; + +class GxsPostedConfigSerializer : public RsServiceSerializer +{ +public: + GxsPostedConfigSerializer() : RsServiceSerializer(RS_SERVICE_GXS_TYPE_POSTED_CONFIG) {} + virtual ~GxsPostedConfigSerializer() {} + + RsItem* create_item(uint16_t service_id, uint8_t item_sub_id) const + { + if(service_id != RS_SERVICE_GXS_TYPE_POSTED_CONFIG) + return NULL; + + switch(item_sub_id) + { + case GXS_POSTED_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsPostedNotifyRecordsItem(); + default: + return NULL; + } + } +}; + +bool p3PostBase::saveList(bool &cleanup, std::list&saveList) +{ + cleanup = true ; + + RsGxsPostedNotifyRecordsItem *item = new RsGxsPostedNotifyRecordsItem ; + + item->records = mKnownPosted ; + + saveList.push_back(item) ; + return true; +} + +bool p3PostBase::loadList(std::list& loadList) +{ + while(!loadList.empty()) + { + RsItem *item = loadList.front(); + loadList.pop_front(); + + rstime_t now = time(NULL); + + RsGxsPostedNotifyRecordsItem *fnr = dynamic_cast(item) ; + + if(fnr != NULL) + { + mKnownPosted.clear(); + + for(auto it(fnr->records.begin());it!=fnr->records.end();++it) + if( now < it->second + GXS_POSTED_CONFIG_MAX_TIME_NOTIFY_STORAGE) + mKnownPosted.insert(*it) ; + } + + delete item ; + } + return true; +} + +RsSerialiser* p3PostBase::setupSerialiser() +{ + RsSerialiser* rss = new RsSerialiser; + rss->addSerialType(new GxsPostedConfigSerializer()); + + return rss; +} + diff --git a/libretroshare/src/services/p3postbase.h b/libretroshare/src/services/p3postbase.h index 8fc305b45..d90f94a8a 100644 --- a/libretroshare/src/services/p3postbase.h +++ b/libretroshare/src/services/p3postbase.h @@ -63,39 +63,44 @@ bool encodePostCache(std::string &str, const PostStats &s); bool extractPostCache(const std::string &str, PostStats &s); -class p3PostBase: public RsGenExchange, public GxsTokenQueue, public RsTickEvent +class p3PostBase: public RsGenExchange, public GxsTokenQueue, public RsTickEvent, public p3Config { - public: +public: p3PostBase(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs, - RsSerialType* serviceSerialiser, uint16_t serviceType); + RsSerialType* serviceSerialiser, uint16_t serviceType); -virtual void service_tick(); + virtual void service_tick(); - protected: +protected: -virtual void notifyChanges(std::vector& changes); + virtual void notifyChanges(std::vector& changes); - // Overloaded from GxsTokenQueue for Request callbacks. -virtual void handleResponse(uint32_t token, uint32_t req_type); + // Overloaded from GxsTokenQueue for Request callbacks. + virtual void handleResponse(uint32_t token, uint32_t req_type); - // Overloaded from RsTickEvent. -virtual void handle_event(uint32_t event_type, const std::string &elabel); + // Overloaded from RsTickEvent. + virtual void handle_event(uint32_t event_type, const std::string &elabel); - public: + // overloads p3Config + virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser() + virtual bool saveList(bool &cleanup, std::list&saveList) override; // @see p3Config::saveList(bool &cleanup, std::list&) + virtual bool loadList(std::list& loadList) override; // @see p3Config::loadList(std::list&) - ////////////////////////////////////////////////////////////////////////////// +public: -virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read); + ////////////////////////////////////////////////////////////////////////////// + + virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read); - protected: +protected: - p3GxsCommentService *mCommentService; + p3GxsCommentService *mCommentService; - private: +private: -static uint32_t postBaseAuthenPolicy(); + static uint32_t postBaseAuthenPolicy(); // Background processing. void background_tick(); @@ -116,13 +121,14 @@ static uint32_t postBaseAuthenPolicy(); bool background_cleanup(); - RsMutex mPostBaseMtx; + RsMutex mPostBaseMtx; bool mBgProcessing; bool mBgIncremental; - std::list mBgGroupList; - std::map mBgStatsMap; + std::list mBgGroupList; + std::map mBgStatsMap; + std::map mKnownPosted; }; #endif