author | terytkon |
Thu, 11 Mar 2010 18:39:02 +0200 | |
changeset 0 | 30eb2d538f02 |
child 1 | fe41c66bacc7 |
permissions | -rw-r--r-- |
0
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
1 |
/* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
3 |
* All rights reserved. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
8 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
9 |
* Initial Contributors: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
10 |
* Nokia Corporation - Initial contribution |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
11 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
12 |
* Contributors: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
13 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
14 |
* Description: This file is part of com.nokia.tools.variant.media.ui component. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
15 |
*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
16 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
17 |
package com.nokia.tools.variant.internal.media.ui; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
18 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
19 |
import java.io.File; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
20 |
import java.io.FileOutputStream; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
21 |
import java.io.IOException; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
22 |
import java.io.InputStream; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
23 |
import java.util.Enumeration; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
24 |
import java.util.zip.ZipEntry; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
25 |
import java.util.zip.ZipFile; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
26 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
27 |
import org.eclipse.core.runtime.QualifiedName; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
28 |
import org.eclipse.core.runtime.content.IContentDescriber; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
29 |
import org.eclipse.core.runtime.content.IContentDescription; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
30 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
31 |
import com.nokia.tools.variant.common.core.utils.FileUtils; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
32 |
import com.nokia.tools.variant.media.ui.MediaUIPlugin; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
33 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
34 |
public class ZipDescriber implements IContentDescriber { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
35 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
36 |
public ZipDescriber() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
37 |
super(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
38 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
39 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
40 |
public int describe(InputStream contents, IContentDescription description) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
41 |
throws IOException { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
42 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
43 |
int counter = 0; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
44 |
long length = -1; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
45 |
File temp = File.createTempFile("tempzip", ".zip"); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
46 |
try { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
47 |
FileOutputStream fos = new FileOutputStream(temp); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
48 |
try { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
49 |
length = FileUtils.copyStream(contents, fos); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
50 |
} finally { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
51 |
FileUtils.closeStream(fos); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
52 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
53 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
54 |
ZipFile zis = new ZipFile(temp); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
55 |
Enumeration<? extends ZipEntry> en = zis.entries(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
56 |
while (en.hasMoreElements()) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
57 |
ZipEntry zipEntry = en.nextElement(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
58 |
if (!zipEntry.isDirectory()) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
59 |
counter++; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
60 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
61 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
62 |
} finally { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
63 |
temp.delete(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
64 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
65 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
66 |
if (description != null) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
67 |
description.setProperty(MediaUIPlugin.SIZE, length); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
68 |
description.setProperty(MediaUIPlugin.EMBEDDED_FILE_COUNT, counter); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
69 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
70 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
71 |
return INDETERMINATE; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
72 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
73 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
74 |
public QualifiedName[] getSupportedOptions() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
75 |
return new QualifiedName[] { MediaUIPlugin.SIZE, |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
76 |
MediaUIPlugin.EMBEDDED_FILE_COUNT }; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
77 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
78 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
79 |
} |