~ubuntu-branches/ubuntu/vivid/mediatomb/vivid

« back to all changes in this revision

Viewing changes to src/scripting/import_script.cc

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2008-03-02 13:09:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080302130916-zlljdze3kt7vuq4b
Tags: 0.11.0-1
* New upstream release.
* Include message about which inotify headers will be used when enabling
  inotify runtime support.
* Fixed error with use of INTERFACE in init script. Also removed use of -m
  option.
* Including new config.xml options.
* Added more build dependencies for new upstream release.
* Removed build dependency of libid3-dev, taglib is now preferred.
* mediatomb.xpm and manpage.xml is now included in orig tarball.
* inotify patch is not needed anymore.
* md5 patch has been committed upstream and is no longer needed. Also removed
  README.Debian.
* TwinHelix PNG fix is now used. Removed from TODO.
* Adding dependency of iceweasel for mediatomb package.
* Updated copyright file.
* Updated watch file.
* Updated rules file for proper configure options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
9
9
    
10
 
    Copyright (C) 2006-2007 Gena Batyan <bgeradz@mediatomb.cc>,
 
10
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
11
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
12
                            Leonhard Wimmer <leo@mediatomb.cc>
13
13
    
24
24
    version 2 along with MediaTomb; if not, write to the Free Software
25
25
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
26
    
27
 
    $Id: import_script.cc 1354 2007-06-07 23:02:34Z jin_eld $
 
27
    $Id: import_script.cc 1698 2008-02-23 20:48:30Z lww $
28
28
*/
29
29
 
30
30
/// \file import_script.cc
44
44
ImportScript::ImportScript(Ref<Runtime> runtime) : Script(runtime)
45
45
{
46
46
    String scriptPath = ConfigManager::getInstance()->getOption(CFG_IMPORT_SCRIPTING_IMPORT_SCRIPT); 
47
 
    load(scriptPath);
 
47
 
 
48
#ifdef JS_THREADSAFE
 
49
    JS_SetContextThread(cx);
 
50
    JS_BeginRequest(cx);
 
51
#endif
 
52
 
 
53
    try 
 
54
    {
 
55
        load(scriptPath);
 
56
        root = JS_NewScriptObject(cx, script);
 
57
        JS_AddNamedRoot(cx, &root, "ImportScript");
 
58
    }
 
59
    catch (Exception ex)
 
60
    {
 
61
#ifdef JS_THREADSAFE
 
62
        JS_EndRequest(cx);
 
63
        JS_ClearContextThread(cx);
 
64
#endif
 
65
        throw ex;
 
66
    }
 
67
#ifdef JS_THREADSAFE
 
68
        JS_EndRequest(cx);
 
69
        JS_ClearContextThread(cx);
 
70
#endif
48
71
}
49
72
 
50
73
void ImportScript::processCdsObject(Ref<CdsObject> obj)
51
74
{
52
 
   JSObject *orig = JS_NewObject(cx, NULL, NULL, glob);
53
 
   setObjectProperty(glob, _("orig"), orig);
54
 
   cdsObject2jsObject(obj, orig);
55
 
   execute();
 
75
#ifdef JS_THREADSAFE
 
76
    JS_SetContextThread(cx);
 
77
    JS_BeginRequest(cx);
 
78
#endif
 
79
    try 
 
80
    {
 
81
        JSObject *orig = JS_NewObject(cx, NULL, NULL, glob);
 
82
        setObjectProperty(glob, _("orig"), orig);
 
83
        cdsObject2jsObject(obj, orig);
 
84
        execute();
 
85
    }
 
86
    catch (Exception ex)
 
87
    {
 
88
#ifdef JS_THREADSAFE
 
89
        JS_EndRequest(cx);
 
90
        JS_ClearContextThread(cx);
 
91
#endif
 
92
        throw ex;
 
93
    }
 
94
 
 
95
    gc_counter++;
 
96
    if (gc_counter > JS_CALL_GC_AFTER_NUM)
 
97
    {
 
98
        JS_MaybeGC(cx);
 
99
        gc_counter = 0;
 
100
    }
 
101
#ifdef JS_THREADSAFE
 
102
    JS_EndRequest(cx);
 
103
    JS_ClearContextThread(cx);
 
104
#endif
 
105
}
 
106
 
 
107
ImportScript::~ImportScript()
 
108
{
 
109
#ifdef JS_THREADSAFE
 
110
    JS_SetContextThread(cx);
 
111
    JS_BeginRequest(cx);
 
112
#endif
 
113
    
 
114
    if (root)
 
115
        JS_RemoveRoot(cx, &root);
 
116
 
 
117
#ifdef JS_THREADSAFE
 
118
    JS_EndRequest(cx);
 
119
    JS_ClearContextThread(cx);
 
120
#endif
 
121
 
56
122
}
57
123
 
58
124
#endif // HAVE_JS