sungo 11 years ago
commit
c4741986a0
7 changed files with 162 additions and 0 deletions
  1. 27 0
      LICENSE
  2. 13 0
      Makefile.PL
  3. 0 0
      README
  4. 1 0
      VERSION
  5. 80 0
      lib/Net/Dropbox.pm
  6. 41 0
      lib/Net/Dropbox/Command.pm
  7. 0 0
      t/.keep

+ 27 - 0
LICENSE

@@ -0,0 +1,27 @@
+Copyright (c) 2008, Matt Cashner
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
+ * Neither the name of Matt Cashner nor the names of its
+   contributors may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 13 - 0
Makefile.PL

@@ -0,0 +1,13 @@
+use inc::Module::Install;
+
+name            ('Net-Dropbox');
+author          ('Matt Cashner (sungo@pobox.com)');
+version_from    ('VERSION');
+license         ('bsd');
+
+requires        ('Test::More');
+requires        ('File::HomeDir');
+
+build_requires  ('Test::Distribution');
+
+WriteAll();

+ 0 - 0
README


+ 1 - 0
VERSION

@@ -0,0 +1 @@
+our $VERSION = '0.01';

+ 80 - 0
lib/Net/Dropbox.pm

@@ -0,0 +1,80 @@
+package Net::Dropbox;
+
+use warnings;
+use strict;
+
+use File::HomeDir;
+use Net::Dropbox::Command;
+
+our $VERSION = '0.01';
+
+sub new {
+	my $class = shift;
+	my %args = @_;
+
+	my $self = bless {
+		command_socket => $args{command_socket} || File::HomeDir->my_home.'/.dropbox/command_socket',
+	}, $class;
+
+	unless(-S $self->{command_socket}) {
+		warn "$self->{command_socket} is not a socket";
+		$self = undef;
+	}
+
+	return $self;
+}
+
+
+
+
+
+1;
+__END__
+
+=pod
+
+=head1 NAME
+
+Net::Dropbox - communicate with local dropbox daemon
+
+=head1 DESCRIPTION
+
+
+
+=head1 AUTHOR
+
+Matt Cashner (sungo@pobox.com)
+
+=head1 LICENSE
+
+Copyright (c) 2008, Matt Cashner
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
+ * Neither the name of Matt Cashner nor the names of its
+   contributors may be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+=cut
+

+ 41 - 0
lib/Net/Dropbox/Command.pm

@@ -0,0 +1,41 @@
+package Net::Dropbox::Command;
+
+use warnings;
+use strict;
+
+our $VERSION = '0.01';
+
+# This is hardcoded into the official C client so I'm mirroring it
+sub MAX_ARGS () { 20 }
+
+sub new { return bless({}, shift); }
+
+
+sub build_command {
+	my $self = shift;
+	my $command = shift;
+	my $args = shift;
+
+	my $output = "$command\n";
+	foreach my $arg (keys %$args) {
+		$output .= "$arg\t$args->{$arg}\n";
+	}
+	$output .= "done\n";
+}
+
+sub parse_response {
+	my $self = shift;
+	my $text = shift;
+
+	my @lines = split("\n", $text);
+
+
+	my $args = 0;
+
+	if($text =~ s/^ok\n//s) {
+
+	}
+}
+
+1;
+__END__

+ 0 - 0
t/.keep