Skip to content

Commit

Permalink
Implemented version command (usage `java -jar threema-msgapi-tool.jar…
Browse files Browse the repository at this point in the history
… -v`) with feature level (also explained in [rugk/threema-msgapi-sdk-php/issues/27](rugk/threema-msgapi-sdk-php#27) ).

NOTE: This is an unofficial implementation in the community edition of the Threema msg-API which has been forwarded to Threema for an official implementation.
  • Loading branch information
simmac committed Feb 28, 2016
1 parent e602aca commit 7da9286
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 2 deletions.
87 changes: 87 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Java template
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### OSX template
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Created by .ignore support plugin (hsz.mobi)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ Fetch the capability of a Threema ID
java -jar threema-msgapi-tool.jar -D <id> <from> <secret> <privateKey> <messageId> <nonce> [outputFolder]
Decrypt a box (box from the stdin) message and download (if the message is a image or file message) the file(s) to the defined directory

## Feature Levels

| Level | Text | Capabilities | Image | File | Credits |
|-------|------|--------------|-------|------|---------|
| 1 | X | | | | |
| 2 | X | X | X | X | |
| 3 | X | X | X | X | X |

You can see the implemented feature level by invoking the following command:

```
$ java -jar threema-msgapi-tool.jar -v
```

## Contributing
Nice to see you want to contribute. We may periodically send patches to Threema to make it possible for them to implement them in the official SDK version.

Expand Down
10 changes: 9 additions & 1 deletion source/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

<groupId>ch.threema.apitool</groupId>
<artifactId>msgapi-sdk-java</artifactId>
<version>1.1.3</version>
<version>1.1.3-CE</version>
<name>Threema MsgApi SDK</name>
<properties>
<source.encoding>UTF-8</source.encoding>
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${source.encoding}</project.reporting.outputEncoding>
<property.featureLevel>3</property.featureLevel>
</properties>

<organization>
Expand Down Expand Up @@ -55,6 +56,13 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
3 changes: 2 additions & 1 deletion source/src/main/java/ch/threema/apitool/ConsoleMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public static void main(String[] args) throws Exception {
.add(new HashEmailCommand(), "-h", "-e")
.add(new HashPhoneCommand(), "-h", "-p")
.add(new GenerateKeyPairCommand(), "-g")
.add(new DerivePublicKeyCommand(), "-p");
.add(new DerivePublicKeyCommand(), "-p")
.add(new VersionCommand(), "-v");

commands.create("Network operations")
.add(new SendSimpleMessageCommand(), "-s")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* $Id$
*
* The MIT License (MIT)
* Copyright (c) 2015 Threema GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE
*/

package ch.threema.apitool.console.commands;

import java.io.InputStream;
import java.util.Properties;

public class VersionCommand extends Command {

public VersionCommand() {
super("Version", "Prints out the current version and feature level. ");
}

@Override
protected void execute() throws Exception {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("app.properties");
Properties p = new Properties();
p.load(inputStream);
System.out.println("Version: "+p.getProperty("version")+"\nFeature level: "+p.getProperty("feature.level"));
}
}
2 changes: 2 additions & 0 deletions source/src/main/resources/app.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=${project.version}
feature.level=${property.featureLevel}

0 comments on commit 7da9286

Please sign in to comment.