This file is indexed.

/usr/include/barry18/barry/connector.h is in libbarry-dev 0.18.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
///
/// \file	connector.h
///		Base class interface for handling Mode connections to device
///

/*
    Copyright (C) 2011-2013, Net Direct Inc. (http://www.netdirect.ca/)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    See the GNU General Public License in the COPYING file at the
    root directory of this project for more details.
*/

#ifndef __BARRY_CONNECT_H__
#define __BARRY_CONNECT_H__

#include "dll.h"
#include "iconv.h"
#include "pin.h"
#include "probe.h"
#include <string>
#include <memory>
#include <time.h>

namespace Barry {

class SocketRoutingQueue;
class Controller;
namespace Mode {
	class Desktop;
}

class BXEXPORT Connector
{
protected:
	std::string m_password;
	bool m_needs_reconnect;
	Barry::IConverter m_ic;
	Barry::ProbeResult m_probe_result;
	int m_connect_count;
	time_t m_last_disconnect;

	// bad password status
	BadPassword m_bpcopy;

protected:
	// helper functions
	static Barry::ProbeResult FindDevice(Barry::Pin pin);

	// required overrides by derived classes
	virtual void StartConnect(const char *password) = 0;
	virtual void RetryPassword(const char *password) = 0;
	virtual void FinishConnect() = 0;
	virtual void DoDisconnect() = 0;
	/// slightly different than IsConnected()... this returns true
	/// even if there is a partial connection in progress...
	/// i.e. this returns true if DoDisconnect() can be safely skipped
	virtual bool IsDisconnected() = 0;

public:
	Connector(const char *password, const std::string &locale,
		Barry::Pin pin = 0);
	Connector(const char *password, const std::string &locale,
		const Barry::ProbeResult &result);
	virtual ~Connector();

	IConverter& GetIConverter() { return m_ic; }
	const IConverter& GetIConverter() const { return m_ic; }
	Barry::ProbeResult& GetProbeResult() { return m_probe_result; }
	const Barry::ProbeResult& GetProbeResult() const { return m_probe_result; }
	const Barry::BadPassword& GetBadPassword() const { return m_bpcopy; }

	virtual void ClearPassword();
	virtual void SetPassword(const char *password);

	/// Returns true if connected, false if user cancelled, throws
	/// Barry exception on error.  Note that in the case of a bad
	/// password, this will return false on the first password try,
	/// unless you override PasswordPrompt() below.  In the default
	/// case, a false here means the password was invalid, and you
	/// should use GetBadPassword() to report the error.
	virtual bool Connect();

	/// Disconnects from the device
	virtual void Disconnect();

	/// Returns same as Connect(), but normally remembers the password
	/// and so avoids prompting the user if possible.  Password prompts
	/// are still possible though, if you have called ClearPassword().
	///
	/// It is valid to call Reconnect() without ever calling Connect(),
	/// since Reconnect() is simply a wrapper that handles retries.
	virtual bool Reconnect(int total_tries = 2);

	/// Calls Reconnect() (and returns it's result) only if you have
	/// called RequireDirtyReconnect().  Otherwise, does nothing, but
	/// returns true.
	virtual bool ReconnectForDirtyFlags();

	/// Returns true if connected, false if not
	virtual bool IsConnected() = 0;

	/// This function flags the Connector object so that a future
	/// call to ReconnectForDirtyFlags() will actually Reconnect().
	/// This is needed in cases where you are updating the device,
	/// and require that the dirty flags on the device itself are
	/// properly cleared and updated.  In this case, you must call
	/// ReconnectForDirtyFlags() before Desktop::GetRecordStateTable().
	/// Disconnecting from the device, or reconnecting, clears the flag.
	virtual void RequireDirtyReconnect();

	//
	// Callbacks, overridden by the application
	//

	/// App should prompt user for password, fill password_result with
	/// what he enters and then return true.  Return false if user
	/// wishes to stop trying.
	///
	/// This function is *not* called from inside a catch() routine,
	/// so it is safe to throw exceptions from it if you must.
	virtual bool PasswordPrompt(const Barry::BadPassword &bp,
					std::string &password_result) = 0;
};

class BXEXPORT DesktopConnector : public Connector
{
	Barry::SocketRoutingQueue *m_router;
	std::auto_ptr<Barry::Controller> m_con;
	std::auto_ptr<Mode::Desktop> m_desktop;
	int m_connect_timeout;

protected:
	virtual void StartConnect(const char *password);
	virtual void RetryPassword(const char *password);
	virtual void FinishConnect();
	virtual void DoDisconnect();
	virtual bool IsDisconnected();

public:
	// Override the timeout due to a firmware issue... sometimes
	// the firmware will hang during a Reconnect, and fail to
	// respond to a Desktop::Open().  To work around this, we
	// set the default timeout to 10 seconds so that we find this
	// failure early enough to fix it within opensync's 30 second timeout.
	// Then if we get such a timeout, we do the Reconnect again and
	// hope for the best... this often fixes it.
	//
	DesktopConnector(const char *password, const std::string &locale,
		Barry::Pin pin = 0, Barry::SocketRoutingQueue *router = 0,
		int connect_timeout = 10000);

	DesktopConnector(const char *password, const std::string &locale,
		const Barry::ProbeResult &result,
		Barry::SocketRoutingQueue *router = 0,
		int connect_timeout = 10000);

	virtual bool IsConnected();

	virtual bool PasswordPrompt(const Barry::BadPassword &bp,
					std::string &password_result)
	{
		// default to only trying the existing password once
		return false;
	}

	//
	// Do not use these functions if IsConnected() returns false
	//

	Controller& GetController() { return *m_con; }
	Mode::Desktop& GetDesktop() { return *m_desktop; }

	const Controller& GetController() const { return *m_con; }
	const Mode::Desktop& GetDesktop()  const{ return *m_desktop; }
};

}

#endif