
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * 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.
 * 
 * The Original Code is Komodo code.
 * 
 * The Initial Developer of the Original Code is ActiveState Software Inc.
 * Portions created by ActiveState Software Inc are Copyright (C) 2000-2010
 * ActiveState Software Inc. All Rights Reserved.
 * 
 * Contributor(s):
 *   ActiveState Software Inc
 * 
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */


#include "nsISupports.idl"
#include "nsIObserverService.idl"
#include "nsITreeView.idl"
#include "koIFileEx.idl"
#include "koIAsyncOperations.idl"

[scriptable, uuid(358650d5-7fc8-4438-9f41-401761f11f1e)]
interface koIPlaceTreeView: nsITreeView {

    void initialize();
    void terminate();

    void setCurrentPlaceWithCallback(in wstring uri,
                                     in koIAsyncCallback callbackObj);    
    // What goes into the original tree.
    void setMainFilters(in wstring exclude_patterns,
                        in wstring include_patterns);
    
    attribute wstring currentPlace; // a URI
    
    attribute nsIObserver statusObserver;

    // refreshes the rows in the tree.  This is not the same as invalidate, it
    // actually removes rows from the tree and regenerates the row list
    void refresh(in wstring uri);

    long getRowIndexForURI(in wstring uri);
    void getSelectedURIs([array, size_is(count)] out wstring uris,
                          out unsigned long count);
    wstring getSelectedURI();
    void selectURI(in wstring uri);
    wstring getURIForRow(in long index);

    const short COPY_MOVE_OK = 0;
    const short MOVE_SAME_DIR = 1;
    const short MOVE_OTHER_DIR_FILENAME_CONFLICT = 2;
    const short COPY_FILENAME_CONFLICT = 3;
    const short COPY_MOVE_WOULD_KILL_DIR = 4;
    const short SRC_CONTAINS_TARGET = 4;
    
    void treeOperationWouldConflict_MultipleSrc
        (
         [array, size_is(count_srcURIs)] in wstring srcURIs,
         in unsigned long count_srcURIs,
         in wstring targetURI,
         in boolean copying,
         out unsigned long count,
         [array, size_is(count)] out long res,
         [array, size_is(count)] out koIFileEx srcFileInfo,
         [array, size_is(count)] out koIFileEx targetFileInfo);
    
    void doTreeOperation(in wstring sourceURI,
                         in wstring targetURI,
                         in long targetIndex,
                         in boolean copying,
                         in koIAsyncCallback callbackObj);
    void doTreeOperationToRootNode(in long sourceIndex, in wstring to_uri,
                         in boolean copying,
                         in koIAsyncCallback callbackObj);
    void doTreeCopyWithDestName(in long sourceIndex, in long targetIndex,
                                in wstring newPath,
                                in koIAsyncCallback callbackObj);
    void doTreeCopyWithDestNameAndURI(in wstring sourceURI,
                                      in wstring targetURI,
                                      in long targetIndex,
                                      in wstring newPath,
                                      in koIAsyncCallback callbackObj);
    boolean canUndoTreeOperation();
    void do_undoTreeOperation();

    void addNewFileAtParent(in wstring name, in long parentIndex);
    void addNewFolderAtParent(in wstring name, in long parentIndex);
    boolean itemIsNonEmptyFolder(in long sourceIndex);
    void deleteItems(in unsigned long count_indices, 
                     [array, size_is(count_indices)] in long indices,
                     in unsigned long count_srcURIs, 
                     [array, size_is(count_srcURIs)] in wstring srcURIs);
    void markRow(in long sourceIndex);
    void refreshView(in long sourceIndex);
    void refreshFullTreeView();
    void renameItem(in long sourceIndex, in wstring baseName, in boolean forceClobber);

    const short SORT_DIRECTION_NAME_NATURAL = 1;
    const short SORT_DIRECTION_NAME_ASCENDING = 2;
    const short SORT_DIRECTION_NAME_DESCENDING = 3;

    void sortBy(in wstring key, in long direction);
    void sortRows();

    // Augment the tree API
    long getNextSiblingIndex(in long index);

    // See other API parts in koIKPFTreeView.idl
    // internal api
    void invalidate();

    attribute boolean handleNextToggleOpenState;
    // XBL isn't letting me set properties, so expose the setter.
    void set_handleNextToggleOpenState(in boolean val);
    
    void handleCallback(in wstring callback,
                        in wstring rv,
                        in long requestID);
};

[scriptable, uuid(64c32667-e3d0-497c-840c-0c339caf7ec7)]
interface koIPlaceToolboxTreeView: nsITreeView {
    void loadFromFileSystem(in wstring uri); // remote or local
};



