summaryrefslogtreecommitdiffstats
path: root/Compass.h
blob: 5ef22f0dc37df0553a065044c450987a6c4e5e8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef COMPASS_H
#define COMPASS_H

#include <iostream>
#include <string>

#ifdef WIN32
#include <windows.h>
#else
#include <cstdlib>
#include <unistd.h>
#endif // WIN32

#include "Options.h"
#include "Keychain.h"
#include "Cryptor.h"
#include "Help.h"

#define COMPASS_VERSION "v0.1"

#define ALLOW_WALK 0
#define SECONDS_PSWD_CLEANUP 30
#define CLEAN_STRING "compass-cleared"

#define WARN_CANT_CLEANUP "Warning: automatic clipboard cleanup failed to start."
#define WARN_WONT_CLEANUP "Warning: automatic clipboard cleanup squelched"

#define ERR_NO_ACTION "Error: no action specified."
#define ERR_RH_NOT_ALLOWED "Error: this action does not support the remote-host option."
#define ERR_REQ_PARAMS_MISSING "Error: required parameters are missing."
#define ERR_INVALID_ACTION "Error: action not recognized."
#define ERR_CLIPBOARD "Error placing password in clipboard. Try using the -pp option."
#define ERR_INPUT "Error: formatting problem with input text."
#define ERR_GENERIC "There was a problem reading/writing the keychain. You may have typed your master password incorrectly, the file may be currupt or missing, you may not have permissions in this directory, or a network error may have occoured."

#define MSG_CLIPBOARD "Password was placed in clipboard."

class Compass {
public:
	Compass();
	virtual ~Compass();

	void perform(int argc, char* argv[]);

private:
	Options opt;

	void initNoArgs(int argc, char* argv[]);
	std::string initOneArg(int argc, char* argv[]);

	void showResult(Credential c);
	void pasteClipboard(std::string text, bool clean, bool recur);

	// Help
	void help();

	// Actions
	void initialize();
	void create(std::string service);
	void walk();
	void rekey();
	void get(std::string service);
	void _delete(std::string service);
	void show(std::string service, bool like);
	void random();
	void markReset(std::string service);
	void checkReset(std::string service);
	void ruser(std::string service);
	void rpass(std::string service);
};

#endif // COMPASS_H