/*
 * BEGIN FLOCK GPL
 * 
 * Copyright Flock Inc. 2005-2006
 * http://flock.com
 * 
 * This file may be used under the terms of of the
 * GNU General Public License Version 2 or later (the "GPL"),
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 * 
 * END FLOCK GPL
 */

#include "nsISupports.idl"
#include "nsIArray.idl"
#include "nsIChannel.idl"
#include "nsIRDFDataSource.idl"
#include "nsIDOMDocument.idl"
#include "nsISimpleEnumerator.idl"

#include "flockIFeedChannel.idl"

[scriptable, uuid(c931064c-c0be-46b8-a91b-f5f368907e0f)]
interface flockIFeedPost : nsISupports {
    attribute AString link;
    attribute AUTF8String title;
    attribute long long datevalue;
    attribute long indexvalue;
};

[scriptable, uuid(f8b8e2d3-8436-4ea7-8016-f64f18ee0667)]
interface flockIFeedInfo : nsISupports {
    attribute AString url;
    attribute AUTF8String title;
    attribute AString type;
};

[scriptable, uuid(933e6da2-4907-4726-a069-55a76afde545)]
interface flockIFeedCollection : nsISupports {
    attribute AUTF8String urn;
    attribute AUTF8String title;
};

[scriptable, uuid(5bec85a0-8507-4bdd-9efa-0e29b62186fa)]
interface flockIFeedRefreshListener : nsISupports {
    void onProgress(in long current, in long total, in string message);
};

[scriptable, uuid(a805d0e3-2c5b-487b-a934-848eabd809b2)]
interface flockIFeedPrioritizeListener : nsISupports {
    void onComplete(in PRUint32 count, [const,array,size_is(count)] in flockIFeedInfo feeds);
};

[scriptable, uuid(6ad0829e-547f-460e-882b-fc7708ff13b7)]
interface flockIFeedServiceListener : nsISupports {
    void onChanged();
    void onNewCountUpdate(in long count);
};

[scriptable, uuid(e2c1738a-461f-4b07-88f7-9c17c5f20257)]
interface flockIFeedService : nsISupports {
    nsIRDFDataSource getFeed(in AString url);

    void getFeedData(in AString url, inout PRUint32 count, [array,size_is(count),retval] out flockIFeedPost posts);

    void loadFeedView(in AString url, in flockIFeedChannel channel);

    void refreshFeed(in AString url);
    void refreshAllFeeds(in flockIFeedRefreshListener listener);

    void prioritizeFeeds(in PRUint32 len, [const,array,size_is(len)] in string urls, in flockIFeedPrioritizeListener listener);

    void prioritizeFeedsQuick(in PRUint32 len, [const,array,size_is(len)] in flockIFeedInfo feeds, out PRUint32 count, [array,size_is(count),retval] out flockIFeedInfo info);

    string joinFeedsURLs(in PRUint32 len, [const,array,size_is(len)] in string urls);

    boolean isFeed(in nsIDOMDocument dom);
    string getFeedType(in nsIDOMDocument dom);

    void subscribeFeed(in AString url, in AUTF8String target, in long orientation, in boolean defer);
    void unsubscribeFeed(in AString url);
    boolean isSubscription(in AString url);

    void grabNewSubscriptions(in PRUint32 len, [const,array,size_is(len)] in string urls, in FlockIFeedRefreshListener listener);

    void markRead(in AString url, in AString id);
    void markUnread(in AString url, in AString id);
    void markAllRead(in AUTF8String urn);
    void markAllUnread(in AUTF8String urn);

    void flagPost(in AString url, in AString id);
    void unflagPost(in AString url, in AString id);

    long getNewCount();
    void resetNewCount();

    /*
    void addFeed(in AString url, in AUTF8String collection);
    void removeFeed(in AString url, in AUTF8String collection);
    */
    void moveFeed(in AString url, in AUTF8String target, in long orientation);

    void addCollection(in AUTF8String collection);
    void removeCollection(in AUTF8String collection);
    void moveCollection(in AUTF8String collection, in AUTF8String target, in long orientation);

    const long ORIENT_ABOVE  = -1;
    const long ORIENT_INSIDE = 0;
    const long ORIENT_BELOW  = 1;

    void renameItem(in AUTF8String item, in AUTF8String title);

    nsIRDFDataSource getSubscriptions();
    void getCollections(out PRUint32 count, [array,size_is(count),retval] out flockIFeedCollection collection);

    long getTotalUnreadCount();

    void addObserver(in flockIFeedServiceListener listener);
    void removeObserver(in flockIFeedServiceListener listener);

    void setDefaultStyle(in AUTF8String urn, in AString style);
    void setDefaultColumns(in long columns);

    void setShowUnread(in boolean show);
    void setShowRead(in boolean show);
    void setShowFlagged(in boolean show);

    // XXX hack
    string test();
};
