kjs_mozilla.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
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 
00037 
00038 
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 DOMEvent::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   
00074   KParts::BrowserExtension *ext = part->browserExtension();
00075   if (ext) {
00076     QString url, name;
00077     if (args.size() == 1) {  
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       
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.2.0.