# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kjs_mozilla.cpp

    00001 // -*- c-basic-offset: 2 -*-
    00002 /*
    00003  *  This file is part of the KDE libraries
    00004  *  Copyright (c) 2003 George Staikos (staikos@kde.org)
    00005  *
    00006  *  This library is free software; you can redistribute it and/or
    00007  *  modify it under the terms of the GNU Library General Public
    00008  *  License as published by the Free Software Foundation; either
    00009  *  version 2 of the License, or (at your option) any later version.
    00010  *
    00011  *  This library is distributed in the hope that it will be useful,
    00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  *  Library General Public License for more details.
    00015  *
    00016  *  You should have received a copy of the GNU Library General Public
    00017  *  License along with this library; if not, write to the Free Software
    00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00019  */
    00020
    00021 #include <klocale.h>
    00022 #include <kdebug.h>
    00023
    00024 #include "kjs_mozilla.h"
    00025 #include "kjs/lookup.h"
    00026 #include "kjs_binding.h"
    00027 #include "khtml_part.h"
    00028 #include "kjs_mozilla.lut.h"
    00029
    00030 using namespace KJS;
    00031
    00032 namespace KJS {
    00033
    00034 const ClassInfo MozillaSidebarExtension::info = { "sidebar", 0, &MozillaSidebarExtensionTable, 0 };
    00035 /*
    00036 @begin MozillaSidebarExtensionTable 1
    00037   addPanel  MozillaSidebarExtension::addPanel   DontDelete|Function 0
    00038 @end
    00039 */
    00040 }
    00041 IMPLEMENT_PROTOFUNC_DOM(MozillaSidebarExtensionFunc)
    00042
    00043 MozillaSidebarExtension::MozillaSidebarExtension(ExecState *exec, KHTMLPart *p)
    00044   : ObjectImp(exec->interpreter()->builtinObjectPrototype()), m_part(p) { }
    00045
    00046 Value MozillaSidebarExtension::get(ExecState *exec, const Identifier &propertyName) const
    00047 {
    00048 #ifdef KJS_VERBOSE
    00049   kdDebug(6070) << "MozillaSidebarExtension::get " << propertyName.ascii() << endl;
    00050 #endif
    00051   return lookupGet<MozillaSidebarExtensionFunc,MozillaSidebarExtension,ObjectImp>(exec,propertyName,&MozillaSidebarExtensionTable,this);
    00052 }
    00053
    00054 Value MozillaSidebarExtension::getValueProperty(ExecState *exec, int token) const
    00055 {
    00056   Q_UNUSED(exec);
    00057   switch (token) {
    00058   default:
    00059     kdDebug(6070) << "WARNING: Unhandled token in MozillaSidebarExtension::getValueProperty : " << token << endl;
    00060     return Value();
    00061   }
    00062 }
    00063
    00064 Value MozillaSidebarExtensionFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
    00065 {
    00066   KJS_CHECK_THIS( KJS::MozillaSidebarExtension, thisObj );
    00067   MozillaSidebarExtension *mse = static_cast<MozillaSidebarExtension*>(thisObj.imp());
    00068
    00069   KHTMLPart *part = mse->part();
    00070   if (!part)
    00071     return Undefined();
    00072
    00073   // addPanel()  id == 0
    00074   KParts::BrowserExtension *ext = part->browserExtension();
    00075   if (ext) {
    00076     QString url, name;
    00077     if (args.size() == 1) {  // I've seen this, don't know if it's legal.
    00078       name = QString::null;
    00079       url = args[0].toString(exec).qstring();
    00080     } else if (args.size() == 2 || args.size() == 3) {
    00081       name = args[0].toString(exec).qstring();
    00082       url = args[1].toString(exec).qstring();
    00083       // 2 is the "CURL" which I don't understand and don't think we need.
    00084     } else {
    00085       return Boolean(false);
    00086     }
    00087     emit ext->addWebSideBar(KURL( url ), name);
    00088     return Boolean(true);
    00089   }
    00090
    00091   return Undefined();
    00092 }
    00093
    00094

This file is part of the documentation for khtml Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:33:18 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003