aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_wire/Wire.cpp
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Library/ml_wire/Wire.cpp
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/Library/ml_wire/Wire.cpp')
-rw-r--r--Src/Plugins/Library/ml_wire/Wire.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/Src/Plugins/Library/ml_wire/Wire.cpp b/Src/Plugins/Library/ml_wire/Wire.cpp
new file mode 100644
index 00000000..e8069f19
--- /dev/null
+++ b/Src/Plugins/Library/ml_wire/Wire.cpp
@@ -0,0 +1,99 @@
+#include "Main.h"
+
+#include "./subscriptionView.h"
+#include "FeedsDialog.h"
+#include "Feeds.h"
+
+#include <algorithm>
+
+
+ChannelList channels;
+
+//CategoryIndex sourceByCategory;
+using namespace Nullsoft::Utility;
+//LockGuard /*feedGuard, */channelGuard, categoryGuard;
+
+void WireManager::BeginChannelSync()
+{
+ // TODO something better than this =)
+ // like making 'touched' flags and delete untouched ones
+ //sources.clear();
+ //sourceByCategory.clear();
+}
+
+void WireManager::NewChannel(const Channel &newChannel)
+{
+ AutoLock lock (channels LOCKNAME("NewChannel"));
+ for (ChannelList::iterator itr=channels.begin();itr!=channels.end(); itr++)
+ {
+ if (*itr == newChannel)
+ {
+ itr->UpdateFrom(newChannel);
+ return;
+ }
+ }
+ channels.push_back(newChannel);
+
+}
+
+void WireManager::EndChannelSync()
+{
+ //SubscriptionView_RefreshChannels(NULL, TRUE);
+}
+
+bool ChannelTitleSort(Channel &channel1, Channel &channel2)
+{
+ return (CSTR_LESS_THAN == CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, channel1.title, -1, channel2.title, -1));
+}
+
+void ChannelList::SortByTitle()
+{
+ AutoLock lock (channelGuard LOCKNAME("SortByTitle"));
+ std::sort(channelList.begin(), channelList.end(), ChannelTitleSort);
+}
+
+void ChannelList::push_back(const Channel &channel)
+{
+ channelList.push_back(channel);
+}
+
+bool ChannelList::AddChannel(Channel &channel)
+{
+ ChannelList::iterator found;
+ for (found=channels.begin(); found!=channels.end(); found++)
+ {
+ if (!wcscmp(found->url, channel.url))
+ break;
+ }
+
+ if (found == channels.end()){
+ channel.needsRefresh=true;
+ push_back(channel);
+ SaveChannels(*this);
+ return true;
+ }
+
+ return false;
+}
+
+size_t ChannelList::GetNumPodcasts()
+{
+ return channels.size();
+}
+
+ifc_podcast *ChannelList::EnumPodcast(size_t i)
+{
+ if (i < channels.size())
+ return &channels[i];
+ else
+ return 0;
+}
+
+#undef CBCLASS
+#define CBCLASS ChannelList
+START_DISPATCH;
+CB(API_PODCASTS_GETNUMPODCASTS, GetNumPodcasts)
+CB(API_PODCASTS_ENUMPODCAST, EnumPodcast)
+END_DISPATCH;
+#undef CBCLASS
+