Debian Codegraph @

components/extension/youtube/scriptutilities.cpp

raw symbols SCIP
1 /* fre:ac - free audio converter
2 * Copyright (C) 2001-2017 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include "scriptutilities.h"
14
15 using namespace smooth::GUI;
16 using namespace smooth::GUI::Dialogs;
17
18 using namespace smooth::Net;
19
20 void BoCA::Alert(const v8::FunctionCallbackInfo<v8::Value> &args)
21 {
22 String text = (char *) *v8::String::AsciiValue(args[0]);
23
24 QuickMessage(text, "Information", Message::Buttons::Ok, Message::Icon::Information);
25 }
26
27 void BoCA::DownloadURL(const v8::FunctionCallbackInfo<v8::Value> &args)
28 {
29 String url = (char *) *v8::String::AsciiValue(args[0]);
30
31 if (url.StartsWith("http://") || url.StartsWith("https://"))
32 {
33 Buffer<UnsignedByte> buffer;
34 Protocols::Protocol *protocol = Protocols::Protocol::CreateForURL(url);
35
36 protocol->DownloadToBuffer(buffer);
37
38 delete protocol;
39
40 if (buffer.Size() > 0)
41 {
42 String result;
43
44 for (Int i = 0; i < buffer.Size(); i++) result[i] = buffer[i];
45
46 args.GetReturnValue().Set(v8::String::New(result));
47 }
48 }
49 }